more on ASTs and literals
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ian_Young
Posted On:   Saturday, September 29, 2001 06:31 AM

Further to my previous question, a second observation is that, if you use this option: FOO = "foo" ; ...then ANTLR successfully recognises all references to "foo" in your parser and generates code referencing the new token name you've assigned, so that from a parsing point of view FOO and "foo" have become equivalent. The bad news is that although references to FOO get the correct behaviour (instantiate the Foo class on the token), references to "foo" continue to be passed to the AST factory and therefore get the wrong AST class. If the answer to the previous question is "bug", then this one may well be related (I guess it might explain why my attempt to at   More>>

Further to my previous question, a second observation is that, if you use this option:


			
FOO = "foo" ;

...then ANTLR successfully recognises all references to "foo" in your parser and generates code referencing the new token name you've assigned, so that from a parsing point of view FOO and "foo" have become equivalent.



The bad news is that although references to FOO get the correct behaviour (instantiate the Foo class on the token), references to "foo" continue to be passed to the AST factory and therefore get the wrong AST class.



If the answer to the previous question is "bug", then this one may well be related (I guess it might explain why my attempt to attach an AST option to a bare literal in the tokens section didn't appear to work).



			
-- Ian
   <<Less

Re: more on ASTs and literals

Posted By:   Ric_Klaren  
Posted On:   Tuesday, October 2, 2001 01:22 AM

Java or C++ mode? Anyway, for C++ mode there's at least
a partial fix for this, which I'm lobbying to get
accepted for Java as well. Heterogeneous AST
support is very shaky per default (in Java mode
slighlty less as in C++). The tree building syntax
with #([FOO])) will not work correctly in this
case. The automatic construction will probably work
but other things might break.

My advice for now don't use heterogenous AST stuff
unless you really know what's happening or are
willing to risk some frustration.

About | Sitemap | Contact