[antlr-interest] Imaginary tokens in AST
Marcin Rzeźnicki
marcin-rzeznicki at wp.pl
Wed Oct 27 17:24:39 PDT 2004
Hello
Consider the tree building rule
A : .... |
! LBRACKET (VAR_ID|NUMBER|STRING)(COMMA (VAR_ID|NUMBER|STRING))*
RBRACKET | ...
which I use for parsing aggregate type constructor which instance may
look like [1,'whatever',x]. I would like to build a tree with imaginary
token type telling me it is an aggregation (which should look like
#(AGGREGATION NUMBER STRING VAR_ID), considering my previous example of
type instance). I know that to achieve this I must turn off automatic
tree construction but what goes next? In documentation I have read that
I can use syntax like :
//doc part
stat:
ID EQUALS^ expr // auto construction
... some alternatives ...
|! RETURN expr
{#stat = #([IMAGINARY_TOKEN_TYPE] expr);}
... more alternatives ...
;
to build wanted tree by-hand, but it does not help me in my case, as I
do not have any subrule there, just bunch of tokens. Is there any way it
could be done? Thank you for answers in advance
--
Greetings
Marcin Rzeźnicki
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list