antlr “java.lang.NoSuchFieldError” on grammar action

9 views
Skip to first unread message

maxpow...@gmail.com

unread,
Oct 2, 2013, 10:20:17 PM10/2/13
to antlr-di...@googlegroups.com
I was trying to use rule reference in grammar action.

string_decl_list : (string_decl)+;
string_decl : ('STRING' id ':=' str ';')
{//table.currentScope().define(new BaseDescriptor(), id.text, ValueType.STRING);
System.out.println($str.text);
};
str : STRINGLITERAL;

My grammar looks like this. The compilation is fine. But when I try to parse my file.

There's an exception coming out.

Exception in thread "main" java.lang.NoSuchFieldError: str
at MicroParser.string_decl(MicroParser.java:368)
at MicroParser.string_decl_list(MicroParser.java:312)
at MicroParser.decl(MicroParser.java:246)
at MicroParser.pgm_body(MicroParser.java:187)
at MicroParser.program(MicroParser.java:107)
at Compiler.main(Compiler.java:32)
Java Result: 1

I guess I am doing it right for the rule reference, could anyone help me about this? I don't know how to solve it

Reply all
Reply to author
Forward
0 new messages