[antlr-interest] simple grammar with wildcard
jason zhang
jasonzhang2002 at gmail.com
Wed Apr 23 07:46:25 PDT 2008
Hi, All
I have a simple grammar. I can not get it work. Help is appreciated.
My input text is like this
name:"value". The value can span multiple line.
My grammar is like this
-------------------
grammar Test;
program : attribute*;
attribute : n=ID ':' '"' e=ATTRVALUE '"' LINEBREAK{
System.out.println("match attrname==============="+$n.text+"
attrvalue="+$e.text);};
ATTRVALUE:NONQUOTE*;
ID :('a'..'z'|'A'..'Z'|'0'..'9'|'-'|'_')+;
WS : ( '\t' | ' ' )+ { $channel = HIDDEN; } ;
LINEBREAK
: '\r'?'\n';
//printable ASCII character except ", including \r and \n.
fragment
NONQUOTE
:' '..'!'|'#'..'~'|'\r'|'\n';
---------------------
When I check this grammar through antlrWorks, I got the error like " The
following token definitions are unreachable: ID,LINEBREAK".
-jason
More information about the antlr-interest
mailing list