I am new to ANTLR. I started exploring ANTLR tutorials. I have seen example where return type have been defined for perticular rule(see below example ).
Can I pass argument to rule as well ? I just have throught in my mind, i wanted to change the behavior of rule at a pertucular state based on argument provided to it .
please help me if it passible in ANTLR or is it a good idea to do that ?
atom returns [int value]
:
INT
{
$value = Integer.parseInt($INT.text);
}
| ID // variable reference
{
Integer v = (Integer) memory.get($ID.text);
if (v != null)
$value = v.intValue();
}
;