[antlr-interest] C++0x Parser with ANTLR as a Tree Grammar

Jim Idle jimi at temporal-wave.com
Thu Oct 14 06:52:31 PDT 2010


This will work for all languages, but you have to make multiple passes until
everything is resolved with something like C++. Perhaps using different tree
walkers.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Christopher Guntli
> Sent: Thursday, October 14, 2010 3:59 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] C++0x Parser with ANTLR as a Tree Grammar
> 
> 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
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list