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
Post a Comment