> ANTLRTreePrinter.g3 is a simple ANTLR v3 tree walker for the ANTLR.g3 > primary parse tree in the C# port.
(An aside: Please use lower case for acronyms for all letters except the first, when the acronym is at least three letters long (e.g. Antlr instead of ANTLR). This is a .NET convention to make names more readable.) I take it that ANTLRTreePrinter.g3 is requiring a separate grammar for creating the parse tree than ANTLRv3.g? I actually mean a standard way to combine parse tree grammars and normal AST grammars in such a way that one can change the output via a simple switch. That way only one grammar has to be maintained while not losing much readability (depending on the exact way of implementation). Johannes > A new tree parser based on that code > but parameterized on the options listed below would be *very* > straightforward. I'm guessing 1, maybe 2 days work at the very most to > create one that fully supports the V3 grammar syntax. We already know > the parse tree from ANTLR.g3 is correct since it's currently being used > to compile the V3 grammars. > > Prof. Parr: I'll get that form faxed back tomorrow morning. > > Sam > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of Johannes Luber > Sent: Wednesday, February 18, 2009 12:34 AM > To: Terence Parr > Cc: Leon Su; ANTLR-dev Dev > Subject: Re: [antlr-dev] ANTLR v3 grammar > > Terence Parr schrieb: > > Ok,I'm trying to integrate a v3 ANTLR parser into the mainline. We > > need this eventually as the new front end to ANTLR itself but also I > > wanted to integrate Leon's cool Strip program that knows how to print > > > grammars back out with lots of different things stripped: > > > > usage: java org.antlr.morph.Strip [args] file.g [file2.g [file3.g > ...]] > > -strip-rewrite strip off rewrites and rule/token reference > > labels > > -strip-label strip off rule/token reference labels > > -grammar-option keep grammar options > > -grammar-action keep grammar actions, e.g. header, members. > > -globalscope keep global scopes > > -rule-argument keep rule arguments > > -rule-returnvalue keep rule return values > > -rule-throws keep rule throws specification > > -rule-option keep rule options > > -rule-scope keep rule scope > > -rule-action keep rule actions, e.g. @init, @after. > > -rule-exception keep rule exception group > > -alt-action keep alternative actions > > -alt-ruleargument keep alternative rule reference arguments > > -alt-tokenargument keep alternative token reference arguments > > -label keep rule/token reference labels > > you need to provide a grammar file. > > > > I have make sure that the grammar in org/antlr/grammar/v3 is the > > latest version we have. thanks to everyone including Leon gave me > > fixes. The problem I have is that I will need only ASTs out of the > > grammar but Leon's strip program needs parse trees, which requires - > > debug option. It uses the debug events to build parsers. I have the > > tree grammar that walks an ANTLR AST. I don't want to have two > > versions of the grammar; well, actually a single version but with two > > > different builds: one with and one without debugging. > > That would be a good place to be able to switch between parse trees and > ASTs via a parameter (whichever way is used to pass it). It would be > dumb if there is no general way to solve this problem. > > Johannes > > > > So, perhaps I adapt Leon's tool to use the rewrite stream and ASTs > > with the tree grammar rather than the parse tree. I think I can get a > > > lot of his logic into the tree grammar from a parse tree. that is the > > > direction I'm going. > > > > With luck, all future stuff can see directly off of a generic AST and > > > the grammar can stay pristine. > > > > Ter > > > > _______________________________________________ > > antlr-dev mailing list > > [email protected] > > http://www.antlr.org/mailman/listinfo/antlr-dev > > > > _______________________________________________ > antlr-dev mailing list > [email protected] > http://www.antlr.org/mailman/listinfo/antlr-dev -- Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a _______________________________________________ antlr-dev mailing list [email protected] http://www.antlr.org/mailman/listinfo/antlr-dev
