mixing AST option and literals
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

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

Hi. I'm using ANTLR with a grammar which makes a lot of use of literals (for keywords) and in which I also want to make heavy use of custom AST classes. It seems that attaching an AST option to a quoted literal in the parser grammar works fine, although I tend to think it clutters the grammar description. It also seems to work if you use the following form in the tokens section: FOO = "foo" ; However, the following is also accepted, but doesn't seem to have the desired effect: "foo" ; Is this a known bug? Have I just misunderstood something? -- Ian    More>>

Hi. I'm using ANTLR with a grammar which makes a lot of use of literals (for keywords) and in which I also want to make heavy use of custom AST classes.



It seems that attaching an AST option to a quoted literal in the parser grammar works fine, although I tend to think it clutters the grammar description. It also seems to work if you use the following form in the tokens section:



			
FOO = "foo" ;


However, the following is also accepted, but doesn't seem to have the desired effect:



			
"foo" ;



Is this a known bug? Have I just misunderstood something?



			
-- Ian
   <<Less

Re: mixing AST option and literals

Posted By:   Ric_Klaren  
Posted On:   Thursday, October 11, 2001 12:57 AM

The first syntax should work. With the second
syntax there could be problems. I recently
found a discrepancy between the java and C++
codegenerator with respect to that. In my
development release both syntaxes work. (this
one is not on my page though)

FWIW I'd prefer the first syntax anyday =)

Re: mixing AST option and literals

Posted By:   Terence_Parr  
Posted On:   Wednesday, October 10, 2001 04:36 PM

HMm...should work in both cases. Using C++? If so, I'm not sure if that is fully implemented yet in C++ output.
About | Sitemap | Contact