[antlr-interest] CPP parser

Samuel Goto samuelgoto at gmail.com
Wed Jan 11 11:00:52 PST 2006


Hi,

         This is my first message to the list. It is about cpp parsing and I
have tried the list archieves and google ... hope I don't make any mistake
... heheheh

          Well, ok. So I want to parse C++. I am writing a SystemC ( witch
is C++ ) to Verilog ( or VHDL ) translator.

          All I need is a C++ parser with an AST, or a suggestion on a
technique to make code analysis.

          I am using with sucess the GnuC grammar with antrl. I wrote a
SystemC ( a subset of C++ ) extension of the GnuC ( wich extends StdC ), and
this is doing great for now !!! It actually translates a lot of SystemC
models to Verilog !!! But I want the full expression power of C++. So I need
to change to a C++ front end.

        The problem is : the c++ grammar that comes with antlr is great, but
it doesn't come with an AST. I have tried many things to substitute the AST,
like a tree walker, a tree parser and string template. The thing is : they
just don't do the job for me, i can't use them or they take more work to
build than I expected.

         I tried other tools too : bison, elsa, sablecc, yacc, etc. They
don't have what I need : an AST or something similar.

        Well, since c++ is a very common language, and I was sure the
community at this point would have written a ( easy to use ) c++ front end
with an AST, I am starting to think that I am the one who is having a bad
idea about what I really need ( hehehe ... this is usually the case ...
heheheh ... ).

        Therefore, I am asking : how can I use the c++ grammar for a
translator ?

        I tried a tree parser, but it is more work than I was expecting ...
isn't there an easier way to do this ? Perhaps I am missing something ....

        Any ideas ?

       PS By the way : GREAT job at antlr !!! Congratulations !!!

--
f u cn rd ths u cn b a gd prgmr !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060111/f80831fd/attachment.html


More information about the antlr-interest mailing list