I'm having some trouble trying to work out the best approach for some 
ambiguity.

If I have an identifier token defined as:

IDENTIFIER: ('A'..'Z' | 'a'..'z' | '_') ('A'..'Z' | 'a'..'z' | '_' | 
'0'..'9')* ('$' | '!' | '&')?

Were the last part of the rule indicates an optional implicit type 
character.

Unfortunately, "!" is also a binary operator that works with 
identifiers. For example, the following is valid: 

foo!bar

and indicates a ! operator with a left side of foo and right of bar. 
This is only possible when the left side identifier doesn't end with a 
implicit type character.

I was initially thinking of doing some token re-writing to determine if 
an identifier (without an implicit type char)  followed by a "!" is 
followed by another identifier and then emit a separate "!" so that can 
be picked up by the parser. But I'm not keen on doing this, as (as far 
as I can see, please correct me if i'm wrong) this takes some of my 
lexing rules out of my grammar and into another place, complicating any 
maintenance on the grammar itself.

Is there a cleaner/different way to achieve this?

Cheers

-- 
David Chipping
Anubex

Direct Tel.: +32 3 4504263
General Fax: +32 3 4504251
Web Address: http://www.anubex.com
Reply To: [email protected] 


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to