Git Product home page Git Product logo

c-code-creation-preprocessor's Introduction

C Code Creation Preprocessor

CCCP generates C code using Lua scripts that are embedded in the C source files. An example of a generate fragment is shown below.

/*cccp generate
    -- Lua code goes here.
    return '\n\tputs("Hello, world!");\n'
*/
/*cccp begin*/
    // Generated code goes here. This comment will be deleted when cccp is run.
    puts("Hello, world!");
/*cccp end */

Anything in the cccp generate comment will be executed in a Lua interpreter. The generated code is returned to cccp as a string which is then inserted between cccp begin and cccp end. Unless otherwise described, this syntax must be followed exactly, otherwise the program will throw errors, and the fragment will not be generated.

An important note is that the space on the end of cccp end is currently required to successfully run cccp. The reason for this is simply bad coding practice, but its purpose is to make room for a checksum at the end. Anything between cccp end (after the space) and the closing */ will be interpreted as a checksum. When cccp is run, it first checks for the checksum. If it is present, it checks to see if the generated C code was modified. If it was, the program skips generation of that fragment. If no checksum exists (like above), operation will proceed as if a good checksum exists. This can be used to override bad checksums.

The goals of this project are to remain fully compatible with most versions of C and to prevent it from becoming a dependency that code will not compile without. This is why cccp commands are commented out, and both generator and generated code is left in the source file.

While this program was written to make C easier to write in certain situations, there is no reason that it couldn't be modified to work with other languages as well.

c-code-creation-preprocessor's People

Contributors

oitzujoey avatar

Stargazers

chunhui avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.