[antlr-interest] keywords and arbitrary text

Peter Hull peterhull90 at gmail.com
Wed Jul 7 12:57:35 PDT 2010


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


More information about the antlr-interest mailing list