rewrite tree using []

34 views
Skip to first unread message

afran...@gmail.com

unread,
Aug 20, 2013, 8:47:54 AM8/20/13
to antlr-di...@googlegroups.com
I am trying to rewrite my AST and output semantic warnings.

If i use [] with a lexer rule it accepts but not with a parser rule why ?
I have a parser rule called "var" and i will like to test the value if declared by doing something like this:

-> ^(DECLARATION type var[Main.symbols.test_declared($var.text)] expression?);

but i get :

unexpected token: Main.symbols.test_declared($var.text)

is there a way to get around this ?


Most tutorials i have seen, only LEXER rules are used, but i can't based on my grammar,IDENTIFIER is a part of var.

Jim Idle

unread,
Aug 20, 2013, 11:04:51 PM8/20/13
to antlr-di...@googlegroups.com
Don't do it :)

tokens { VAR; }

->^(DECLARATION type VAR[...

or you can rewrite it within var itself and just use var in the rewrite.
But are you sure that you want to lose the information in var in to one
blob in your tree?


Jim
> --
> You received this message because you are subscribed to the Google
> Groups "antlr-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to antlr-discussi...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages