[antlr-interest] Grammar Perplexity in v3.0 (More)
Randall R Schulz
rschulz at sonic.net
Sun Nov 12 08:44:44 PST 2006
Hello again,
I've found what appears to be a genuine anomaly. Using ANTLRworks, I've
shown that the AtomicWord lexical rule works properly when explicitly
applied to inputs that it describes.
When applied to the production rule "plainTerm" that directly addresses
AtomicWord, ANTLRworks reports "MismatchedTokenException(4!=6)" as the
direct descendant of plainTerm:
- [plainTerm]
[MismatchedTokenException(4!=6)]
When the test input (the two characters "gt") is applied to AtomicWord,
the expected derivation occurs. but when the same input is submitted to
plainTerm:
plainTerm
: AtomicWord ( '(' arguments ')' ) ?
... the aforementioned error occurs.
Surely this is a bug? Or am I confused about something?
Here are the pertinent rules:
plainTerm
: AtomicWord ( '(' arguments ')' ) ?
AtomicWord
: LowerWord
;
fragment
LowerWord
: LowerAlpha ( Alphanumeric * )
;
fragment
Alphanumeric
: ( LowerAlpha | UpperAlpha | Numeric | '_' )
;
fragment
LowerAlpha
: ( 'a'..'z' )
;
fragment
UpperAlpha
: ( 'A'..'Z' )
;
fragment
Numeric
: ( '0'..'9' )
;
Am I missing something, or is this some kind of parser (or parser
generator) error?
Randall Schulz
More information about the antlr-interest
mailing list