tags:

views:

46

answers:

0

hi,

i have a problem setting/getting the right return values in my antlr grammar. I tried:

expressionExp returns [String ref]
:   Number {$ref = null; }
|   ident=Identifier {$ref = $ident.text;} 
|   '(' innerExpressionExp ')' 
;

.. and thought if it now have somethin like

ref=expressionExp

i get a null if i match a number and the identifier text if i match an identifier, but it returns the number too.

Number
:   ('0'..'9')+
;

Identifier
:   ('a'..'z' | 'A'..'Z')('a'..'z' | 'A'..'Z' | '0'..'9')*
;

thx