[antlr-interest] need help with predicates

Andy Tripp antlr at jazillian.com
Fri Aug 10 13:20:45 PDT 2007


Johannes Luber wrote
>> Why don't you test, when you encounter at the identifier the bang, if
>> input.LT(1) is a space? If not then it can't be a suffixed bang. (What
>> does "a!" actually mean in VB?)
>>     
Yes, Alexandre pointed out that spacing does matter in VB.
The "!" operator can't be followed by a space.
On the other hand, the "!" suffix isn't necessarily followed by a space 
either.
So, I've added a simple syntactic predicate. If the character after the "!"
is a letter, I assume the "!" is the binary operator, otherwise its the 
suffix:

Identifier:
         ...
          ('!' ~(LETTER)) => '!'
        ...

Thanks Johannes, Tom, and Alexandre!
Andy


More information about the antlr-interest mailing list