Christos Asa
Christos Asa

Reputation: 155

Return a value in generated java code in ANTLR

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. ?

Upvotes: 1

Views: 157

Answers (1)

Terence Parr
Terence Parr

Reputation: 5962

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

Upvotes: 2

Related Questions