You just need:
TITLE : 'Title' (~('\n'|'\r'))* ;
Then look for TITLE in your parser.
Jim
> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Peter Hull
> Sent: Wednesday, July 07, 2010 12:58 PM
> To: [email protected]
> Subject: [antlr-interest] keywords and arbitrary text
>
> Hi all, here is a quick question from a new user.
> I have a simple language I want to parse. Each line is a separate
> command and each command looks something like
> KEYWORD param param...
> e.g.
> SetGate 10 4.5
> However there's a title command that can take any text up to the end
> of line, e.g
> Title Configuration 1
> or even
> Title This is a Title
> I had a rule
> TEXT: ~('\n'|'\r')+
> but this (I think) matched all the keywords too, even if I used tokens
> {...}
> Is there a way to say that the TEXT token is only to be used after
> Title? I saw something on island grammars but I couldn't understand it
> to be honest.
>
> Pete
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address
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.