The tree printer uses the trees build by the same ANTLR.g3 that I'm using to 
parse the grammars in the C# port of the tool. This grammar is different from 
the ANTLRv3.g that's located in Prof. Parr's P4, notably in the fact that it's 
built to provide the full compiler functionality currently in the v2 grammar 
that's part of the reference Tool. However, that copy of ANTLR.g3 is quite 
flexible, for example I use it without changes (through an assembly reference 
to ANTLR3.exe) to provide core IntelliSense in our ANTLR language service for 
Visual Studio.

Sam

-----Original Message-----
From: Johannes Luber [mailto:[email protected]] 
Sent: Wednesday, February 18, 2009 5:51 AM
To: Sam Harwell; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: RE: [antlr-dev] ANTLR v3 grammar

> 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

Reply via email to