[antlr-interest] NoViableAltException in Grammar
Bhisham Dutt
bhisham13 at hotmail.com
Fri Oct 22 15:42:32 PDT 2010
Hi,
I have the following grammar, If i pass the following expression everything looks ok -- formula=-0.79*VAR+45.0
But if formula=-0.79*VAR-45.0 (With Negative operator is passed, I am getting NoViableAltException)
grammar Sample1;
options
{
language = Java;
output = AST;
}
rule
: 'formula' '=' ((DOUBLE | NEGDOUBLE) '*')? 'VAR' (('-' | '+') DOUBLE)?
;
fragment DIGIT : '0'..'9';
DOUBLE : (DIGIT)* ('.' (DIGIT)*)?
;
NEGDOUBLE : '-'(DIGIT)* ('.' (DIGIT)*)?
;
WS : (' ' | '\t' | '\n' | '\r' | '\f')+ {$channel = HIDDEN;};
COMMENT : '//' .* ('\n'|'\r') {$channel = HIDDEN;};
Thanks for your help.
More information about the antlr-interest
mailing list