[antlr-interest] Possible Antlr defect?
Stuart Dootson
stuart.dootson at gmail.com
Sat Jun 9 17:07:25 PDT 2007
I've found what appears to be a bug when using separate grammars -
Antlr doesn't appear to give a warning or (preferably) error when
using an undefined token type. I had the following token types:
WS=6
IDENTIFIER=4
NUMERIC_LITERAL=5
SL_COMMENT=7
'='=9
';'=8
and the following parser grammar was processed by Antlr without
warning or error:
parser grammar TestP;
options
{
tokenVocab = Test;
output=AST;
language = C;
}
grammarMain
: (statement ';'!) +
;
statement
: ID '=' value -> ^('=' IDENTIFIER value)
;
value
: IDENTIFIER
| NUMERIC_LITERAL
;
You'll note the 'statement' rule uses 'ID' rather than 'IDENTIFIER' -
I would expect Antlr to complain about that...but it doesn't (BTW -
it's the 3.0 release, on OS X 10.4.9).
I can't really believe I'm the first person to see this - but I didn't
see any mention in mailing list or bug list...
Stuart Dootson
More information about the antlr-interest
mailing list