Hi,
I'm working on a parser for a file format that can contain text and delimiters. 
One of the delimiters is a ':', and you can escape the delimiter by following 
it with a '?' such as ':?'.

I'd like to have the lexer consider the ':?' as part of the TEXT token, and ':' 
match the SEPARATOR token. So I tried this:
file        : contents+ EOF ;

contents    : TEXT
        | CSEP
        ;

CSEP:  ':';
TEXT: ('a'..'z'|'A'..'Z'|'0'..'9'|' '|'-'|','|'.'|'/'|COLON)+ ;
fragment COLON: ':?' ;

This didn't work, as the input "hello:" caused an error. I guess it was 
expecting to continue a TEXT token (next char would be '?'), and met with an 
EOF instead.

I imagine there's a way to do this, perhaps with predicates, but I'm not 
experienced enough to see the obvious solution. Can anyone help?

Thanks,

Rob

_________________________________________________________________
Create a cool, new character for your Windows Liveā„¢ Messenger. 
http://go.microsoft.com/?linkid=9656621
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

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

Reply via email to