[antlr-interest] C++0x Parser with ANTLR as a Tree Grammar
Christopher Guntli
cguntli at hsr.ch
Thu Oct 14 03:59:06 PDT 2010
Hello
For a term project at the University of Applied Science in Rapperswil
(Switzerland www.hsr.ch) I am refactoring a C++0x parser written with
ANTLR. The Parser uses lot of inline java logic to create the symbol
table. As I read in your book Language Implementation Patterns there is a
nicer and cleaner looking way of parsing a language using tree grammars and
tree walkers.
My question is, does this also work for a non-trivial language like C++
where a statement like Identifier(a,b); can have multiple meanings
according whether Identifier is a type name or not. There might be a lot
more statements, where it is not clear without looking up the symbols what
it means.
>From my point of view, there are two implementations concepts to create the
parser either leave it the way it is and live with one big and more
complicated grammar file or making a very lean grammar where a lot of rules
are defined as something like function_like_statement or
constructor_or_function_call and do all the rest in tree walkers and
rewrite it after you created a symbol table
We know that the first option works, but what about the other, do you think
that it is possible and if so, is it reasonable and worth the overhead of
rewriting a lot of the existing grammar?
Kind regards,
christopher
More information about the antlr-interest
mailing list