[antlr-interest] Access AST created by parser

Johannes Luber jaluber at gmx.de
Mon Aug 27 11:21:23 PDT 2007


a.k.n.s wrote:
> I am very, very new to antlr, so perhaps I'm missing something simple -
> but I seem to be unable to access the AST representation of my input file.
> 
> The basics of my grammar are as follows:
> 
> grammar Model;
> 
> options {
>     language=CSharp;
>     output=AST;
> }
> 
> deck
>     :   (statement)+
>     ;
> 
> statement
>     :   (welldef|modelSize)
>     ;
> 
> welldef
>     :   'WELLDEF'^ declarator+ EOL
>     ;
>    
> modelSize: 'MODELSIZE'^ xSize ySize zSize EOL
>     ;
> 
> ....
> 
> I use AntlrWorks to generate the Parser and Lexer.
> 
> My input file looks like this:
> 
> WELLDEF SS001
> WELLDEF PN001 ERER001 P33001 AA001
> MODELSIZE  53  79  67
> WELLDEF PN0014444
> 
> I'm only able to access the tree of the first row (by calling
> parser.deck()) - is there a parser function I can call to get a tree
> representation of the entire file? I would really appreciate it if
> someone could point me in the right direction.
> 
> Thanks!

I can distantly remember that someone mentioned doing something like
this on this list. Unfortunately, I can only recommend to search the
list. IIRC, Ter confused the question with the DOT file generation.
Maybe this helps to find the correct thread.

Best regards,
Johannes Luber


More information about the antlr-interest mailing list