Flex / Yacc sources for C parser

Discussion in 'C Programming' started by Wolfgang Draxinger, Dec 25, 2007.

  1. I'm currently working on a laguange similair in concept to Vala
    (google for it on the Gnome project site). A (very) high level
    language is translated into intermediary C, which is then
    compiled to target.

    I want to be able to "include" C headers, so that I don't have to
    write bindings. That however means, that I have to parse them. I
    could now of course write my own Flex / Yacc code, but I
    presume, that there are ready to use C parser frameworks, which
    can be filled with own code. Mostly it's about to get the
    symbols. Preprocessor macros will be handed down into the
    generated C code, but my compiler shall understand them to
    enable compile time static type checking.

    Wolfgang Draxinger
    --
    E-Mail address works, Jabber: , ICQ: 134682867
    Wolfgang Draxinger, Dec 25, 2007
    #1
    1. Advertising

  2. Wolfgang Draxinger

    santosh Guest

    Wolfgang Draxinger wrote:

    > I'm currently working on a laguange similair in concept to Vala
    > (google for it on the Gnome project site). A (very) high level
    > language is translated into intermediary C, which is then
    > compiled to target.
    >
    > I want to be able to "include" C headers, so that I don't have to
    > write bindings. That however means, that I have to parse them. I
    > could now of course write my own Flex / Yacc code, but I
    > presume, that there are ready to use C parser frameworks, which
    > can be filled with own code. Mostly it's about to get the
    > symbols. Preprocessor macros will be handed down into the
    > generated C code, but my compiler shall understand them to
    > enable compile time static type checking.


    Try lcc, which is touted as a re-targetable C compiler. It's often
    praised for code clarity and modularity, so you may be able to rip out
    the relevant pieces for your use.

    <http://www.cs.princeton.edu/software/lcc/>
    <http://www.kernel.org/pub/software/devel/sparse/>
    santosh, Dec 25, 2007
    #2
    1. Advertising

  3. Wolfgang Draxinger wrote:
    > I'm currently working on a laguange similair in concept to Vala
    > (google for it on the Gnome project site). A (very) high level
    > language is translated into intermediary C, which is then
    > compiled to target.
    >
    > I want to be able to "include" C headers, so that I don't have to
    > write bindings. That however means, that I have to parse them. I
    > could now of course write my own Flex / Yacc code, but I
    > presume, that there are ready to use C parser frameworks, which
    > can be filled with own code. Mostly it's about to get the
    > symbols. Preprocessor macros will be handed down into the
    > generated C code, but my compiler shall understand them to
    > enable compile time static type checking.
    >
    > Wolfgang Draxinger


    I managed to produce a C99 (mostly GNUC compatible) grammar via some C89
    samples on the net.

    http://c-faq.com/resources/grammars.html

    See also:
    http://www.lysator.liu.se/c/ANSI-C-grammar-y.html

    That page has a lexer for C, and CPP.

    GNUC is difficult to parse entirely and properly with Yacc-based
    parsers. GNU's C compiler doesn't seem to use Yacc as much as the
    typical compiler (lots of hand written parsing from what I saw).



    George
    George Peter Staplin, Dec 25, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Wahler
    Replies:
    2
    Views:
    524
    John Harrison
    Jul 8, 2003
  2. c/c++ÐÂÎÅ×é

    flex and yacc

    c/c++ÐÂÎÅ×é, Apr 10, 2007, in forum: C++
    Replies:
    1
    Views:
    552
    Ian Collins
    Apr 10, 2007
  3. Robert
    Replies:
    1
    Views:
    301
    Martin v. Löwis
    Apr 16, 2008
  4. Robert
    Replies:
    2
    Views:
    148
    Ron Fox
    Apr 23, 2008
  5. Robert
    Replies:
    3
    Views:
    116
    Ben Bullock
    Apr 17, 2008
Loading...

Share This Page