parsing - JavaCC grammar conflict -


i have grammar defined this.

token:{         <t_int: "int"> |         <t_string: ["a"-"z"](["a"-"z"])*> }  skip: { " " | "\t" | "\n" | "\r" }  /** main production. */ simplenode start() : {} {         (lookahead(declaration()) declaration() | function())   { return jjtthis; } }  void declaration() #decl: {} {         <t_int> <t_string> ";" }  void function() #func: {} {         <t_string> "();" } 

this works fine stuff like:

int a; foo(); 

but when try int();, legal me , should parsed function(), goes declaration instead. how fix "conflict"? tried various combinations.

the javacc faq's section on titled "how deal keywords aren't reserved?".

what allowing keywords alternatively identifiers, i.e.

(<t_string> | <t_int>) "();" 

when there many keywords, beneficial create identifier production allows them all, along general identifier token.

by way, might want "(" ")" ";" instead of "();".


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -