[antlr-interest] How to ignore TOKEN in a String
Hiten R
antlr3 at gmail.com
Mon Mar 21 10:00:11 PDT 2011
Hi All,
ANTLR grammar acts funny when it encounters a TOKEN in a String. How should
I make the ANTLR escape the letter found in the String is not a TOKEN.
Help will be appreciated.
Thanks
Hiten
Example
text_content.txt
funny boys are Tom Hardy Donald
serious guys are not funny either
grammar
options {
language=Java;
k=1;
}
start
: 'funny' call_funny_parse
| 'serious' call_serious_parse
;
call_funny_parse
@init {
ArrayList<String> person = new ArrayList<String>(); //this should contain
Tom Hardy Donald
}
: jackT=TOKEN //boys
macT=TOKEN //are
(nextPersonT=TOKEN { person.add($nextPersonT.text); })* // Tom Hardy
Donald
;
call_serious_parse
@init {
String line = "";
}
: (stringT=TOKEN { line = line + $stringT.text; })* // This is where is
fails and says 'funny' is expecting something else
More information about the antlr-interest
mailing list