Is there a good parser/lexer that generates valid C++ code because all I've found was just C ones and I don't want to rely on dependencies like antlr does with java . And has good cross-platform support? and well documented?
Is there a good parser/lexer that generates valid C++ code because all I've found was just C ones and I don't want to rely on dependencies like antlr does with java . And has good cross-platform support? and well documented?
Are you looking for a parser, a parser generator or a code generator ? (your question is not clear about that...)
Writing a fully correct parser for C++ is *extremely hard*, if possible at all. However if you only need to understand a subset of C++, or to extract for some pieces of data (for, e.g, class browsing) it is doable. Depends on your requirement really.
Some potentially useful references :
- A parser GLR generator, which comes with a C++ parser generated with it (claims to fully parse Qt and Mozilla sources among other things) : http://www.cs.berkeley.edu/~smcpeak/elkhound/
- Ctags parses C and derived languages (which includes C++) http://ctags.sf.net
I've written some C++ parsers myself but they don't qualify as full parsers : they were either just lexers (for syntax highlighting) or permissive extractors (for code browsing and code completion)
Current Qt projects : QCodeEdit, RotiDeCode
Using ANTLR one can choose target language as C++/Python etc.
Sorry. I wanted to write a little basic scripting language in C++.
So you want a parser generatorApart from sources already given you can search for bison or qlalr (the latter if you use Qt).
Bookmarks