[antlr-interest] different behavior java vs c?
Martin Kortmann
email at kortmann.de
Fri Aug 3 13:26:32 PDT 2007
Hi,
I think that i have found and error in the C-target.
It is possible that this is really my fault (i am
absolutely new to ANTLR) but please check this:
The following grammar works fine with the java target:
grammar java_vs_c;
options{
output=AST;
filter=true;
// language=C;
ASTLabelType=CommonTree;
}
// Start Rule
test : testentry secondentry
;
testentry
: 'TEST' num1=INT num2=INT
;
secondentry
: 'SECOND' num1=INT
;
INT : ('0' | '1'..'9') '0'..'9'*
;
WS : (' '|'\t'|'\r'|'\n')+ {$channel=HIDDEN;}
;
ANYOTHER: . ;
Input text:
TEST 1 2
SECOND 3
but it fails with language=C.
The C-Lexer recgnized die tokens, but fillBuffer
(in antlrtokenstream.c) adds only the first
three tokens to the tokenStream ('TEST', ' ' and INT)
and then ignores everything that follows.
I have testet this with GCC and MSVC .Net 2003.
Martin
More information about the antlr-interest
mailing list