[antlr-interest] Puzzling Problem
Sam Barnett-Cormack
sdb at geekworld.co.uk
Sun Apr 9 11:21:44 PDT 2006
Sam Barnett-Cormack wrote:
> Scott Amort wrote:
>
>> On Sun, 2006-04-09 at 17:07 +0100, Sam Barnett-Cormack wrote:
>>
>>> And that would be a little odd... but I could instead statically
>>> define the "0" literal in the lexer, I think... I just didn't think
>>> of the effect of literals in the subgrammar. In fact, to be simpler,
>>> I could define
>>>
>>> zero
>>> : "0"
>>> ;
>>
>>
>>
>> I don't think that will work - you will just end up with a ZERO token
>> type, and then a non-determinism error between ZERO and FLOAT_OR_INT.
>
>
> I was actually suggesting zero being a parser rule in the supergrammar.
> However, I think your other suggestion may be simpler, and also of
> course do it with "-99999" as well.
>
> Sam
>
>> I think you could instead try adding:
>>
>> tokens {
>> "0";
>> }
>>
>> After the options in your lexer.
Adding this caused all of the grammars that used that lexer to
completely die. Which was annoying.
I tried adding the rule
zero
: "0"
;
to the super grammar (that is, a parser rule) and it made no difference
to the result whatsoever, even though that should have made the "0" a
literal known to the lexer.
Anyone got any more ideas? I'm going to look at the lexer-generator docs
some more anyway...
Sam
More information about the antlr-interest
mailing list