1
votes

i am writing a grammar in ANTLR and i want to make a question about return values. I have this rule:

mainParser returns [int test]
    :
    triple EOF 
         {
            $test = 0;
         }
    ;

When i call it from generated java code i can't take back the test value, because it returns me a "parser object": enter image description here

How to make it to return Integer, String etc. ?

1

1 Answers

2
votes

Since mainParser must return a tree and an int, it must use an object. That mainParser_return object has both, if you look inside.