Reputation: 11
If I have a ANTLR grammar where I have rules like this with a 'returns' statement:
string_decl returns [Pair s] : STR id EQUAL ex=str_literal ';'{$s = new Pair($id.text, $ex.text);} ;
And then in my main I have code like this:
Lexer lexer = new Lexer(CharStreams.fromFileName(inputFileName));
CommonTokenStream tokens = new CommonTokenStream(lexer);
Parser parser = new Parser(tokens);
System.out.println(parser.program()); //prints out empty array ?
How do I print out a list of all of my 'returns'?
Upvotes: 0
Views: 321
Reputation: 53337
The returns
value is modeled as member of the rule context. See if you have a String_declContext.s
member. See also Rule Attribute Definitions in the ANTLR4 documentation.
Upvotes: 1