Code Monkey home page Code Monkey logo

cparser's Introduction

CParser

CParser is a standalone C parser library written in C++, that can be easily embedded in other software projects. The library is contained of reusable set of classes.

Demo usage of the library

See src/cformat.cpp, include/GenCVisitor.h and src/GenCVisitor.cpp for the demo source which uses the C parser library. cformat is an implementation of a simple C code style formatter. To clone the project and build the demo, type:

$ git clone https://github.com/jkolek/cparser.git
$ cd cparser
$ make

To run the demo with example C file, type:

$ ./cformat test/example1.c

How to use the library

To use the library you can simply implement your own visitor class by inheriting TreeVisitor class similarly like GenCVisitor (used by the cformat) does. Then with this visitor you can traverse abstract syntax tree generated by parser.

Current work

My current objectives are to make the parser to be able to parse preprocessed files like for example test/cpp_out_example.c, and to finish the GenCVisitor implementation.

Thank you for your interest in my project. Any feedback would be highly appreciated!

References

http://www.quut.com/c/ANSI-C-grammar-l-2011.html

http://www.quut.com/c/ANSI-C-grammar-y.html

https://github.com/antlr/grammars-v4/blob/master/c/C.g4

https://github.com/antlr/grammars-v3/blob/master/ANSI-C/C.g

cparser's People

Contributors

jkolek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cparser's Issues

Parser Rules

Fix the CParser::AbstractDeclarator() and CParser::DirectAbstractDeclarator() according the grammar.

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.