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: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Christopher Guntli > Sent: Thursday, October 14, 2010 3:59 AM > To: [email protected] > 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 List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
