[antlr-interest] NoViableException with semantic predicates
Bertalan Fodor
lilypondtool at organum.hu
Mon Feb 25 14:24:21 PST 2008
Hello, I would need help in the following. I have grammar rules like this:
program: (definition)=>definition | expression;
expression: variable | { isMacro(input.LT(1))}? macro;
macro: keyword body;
definition: 'define' body;
Syntactically 'define' can be a keyword, and anything that can be a
keyword can be a variable. That's why I'm using the semantic predicate.
I get NoViableAlt exception. If I run the debugger it doesn't go into
the syntactic predicate checking, and the dfa.predict method of
program() throws NoViableAltException. The semantic predicate is not
called at all. It seems I'm misunderstanding something. Could you explain?
Thank you,
Bertalan Fodor
More information about the antlr-interest
mailing list