[antlr-interest] Help! AST thing is driving me nuts!

Ross Bencina rbencina at iprimus.com.au
Sat Mar 22 12:44:57 PST 2003


It's a while since I did this, so i'm just going on code I wrote at the
time, but I think what you want is:

Tokens { IMAG_TOK;}

start_rule!:   a:rules  EOF! {#start_rule=#([IMAG_TOK], #a);};

rules:            (rule)+

Best wishes,

Ross.


----- Original Message -----
From: Jorge Scandaliaris
To: antlr-interest at yahoogroups.com
Sent: Sunday, March 23, 2003 6:42 AM
Subject: [antlr-interest] Help! AST thing is driving me nuts!


Hi,
            Yeah, I am at the point where you start tearing out your hair!
Ok, here it goes. I have built the recognizer and I am now moving into AST.
I turned the option on in the parser and to start I generated just the
linked list (no ^ nor !). Now I want to complicate things up, but besides ^
and ! operators I would like to use actions to insert imaginary tokens and
change the tree structure. I have not worked with the treewalker yet, just
the parser, but it seems I am missing the picture big time. Example:
Tokens { IMAG_TOK;}
start_rule:   (rule)+  EOF! {#start_rule=#(#[IMAG_TOK], #start_rule);};

This either doesn't do what I wanted (create an IMAG_TOK node and set it as
root of the tree) or I get fancy compile errors about not being able to
convert 1 parameter from void (void) to antlr::ASTRefCount<class
antlr::AST>. I have tried several changes, but I must be missing something
big.
Last thing, I can´t find anywhere in the doc about the use of ## for actions
(I picked this from some examples) and it does have an effect over generated
code.
I would appreciate some help, especially in directing me towards the good
approach and documentation/examples about this. Thanks,

Jorge Scandaliaris


Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list