[antlr-interest] keywords and arbitrary text

Mikesell, Darin B. Darin.Mikesell at gd-ais.com
Wed Jul 7 13:14:57 PDT 2010


What if you place all your keyword rules before the TEXT rule?

I can't remember if ordering matters in ANTLR like it does in Xtext.  I'm assuming it does since Xtext uses ANTLR.


- Darin


-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Peter Hull
Sent: Wednesday, July 07, 2010 12:58 PM
To: antlr-interest at antlr.org
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


More information about the antlr-interest mailing list