[antlr-interest] ANTLRWorks problem
Shmuel Siegel
ssiegel at finjan.com
Tue Apr 10 08:58:47 PDT 2007
A quick and dirty fix for you to continue. Write a lexer rule that
generates FLOAT_CONST on something that can't happen. Something like
FLOAT_CONST: '\u0001';
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Lucio Biondi
Sent: Tuesday, April 10, 2007 4:15 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] ANTLRWorks problem
Ok, I could safely ignore a warning in the combined lexer/parser grammar
I'm working on,
but it prevents me from using ANTLRWorks. And, admitting I can't live
by now without it
(great work Terence & Jean, it's very handy :-), I just need to resolve
the error.
So, that's the matter
I'm getting a "no lexer rule corresponding to token: FLOAT_CONST" error
message, but
don't know how to overcome this. All things seem right in the grammar,
and it works even ;-)
The token FLOAT_CONST is present in all files generated by antlr, and I
have tried as well
different ways for setting the rule type
setType(FLOAT_CONST)
$type = FLOAT_CONST
but the error message persists.
Googling I found this old answer by Ter but it doesn't help me.
>> I also don't know what to do about the 'no lexer rule corresponding
>> to token: >> VISIT_IDENTIFIER' warning.
> Hmm...yes, should not get a warning in this case...added to list.
Any hints ? Am I missing some new antlr3 rule ?
thanks in advance
Lucio
grammar Givvy;
...
tokens {
FLOAT_CONST; // Imaginary
}
...
atom
: FLOAT_CONST
...
;
/**** LEXER ****/
INT_CONST
: '1'..'9' ('0'..'9')* ((IS_FLOAT_CONST) => { _type = FLOAT_CONST;
})?
...
;
fragment
IS_FLOAT_CONST
: '.' { input.LA(1) >= '0' && input.LA(1) <= '9'}? => DIGITS
EXPONENT? FLOAT_SUFFIX?
| EXPONENT FLOAT_SUFFIX?
| FLOAT_SUFFIX
;
More information about the antlr-interest
mailing list