[antlr-interest] How to remove the rules ambiguity here?
Johannes Luber
jaluber at gmx.de
Mon Oct 29 03:57:18 PDT 2007
Michael LeBlanc wrote:
> I don't know anything about C# but, if the target were Java, I would try
> the following change to compare strings, not references to them.
>
> On Oct 28, 2007, at 1:37 PM, Johannes Luber wrote:
>
>> // For contextual keywords like get, set and yield
>> contextual_keyword[string identifier]
>> : { input.LT(1).Text == $identifier }? IDENTIFIER
>> ;
>
> becomes
>
>> // For contextual keywords like get, set and yield
>> contextual_keyword[string identifier]
>> : { input.LT(1).Text*.equals*($identifier) }? IDENTIFIER
>> ;
In C#, the ==-operator is overloaded for the string class so it results
in the correct behaviour. It is more intuitive in that way.
Johannes
More information about the antlr-interest
mailing list