[antlr-interest] beginner to ANTLR
Rana Rahal
rrahal at protecode.com
Thu Dec 1 12:54:34 PST 2011
Hi,
I am new to ANTLR and I cannot figure out how to read a tag:value file,
where value can span multiple lines.
I have the following:
TOKEN
: ( TAG ':' ) => TAG ':'' ' {$setType(TAG);}
| ( '\n' {newline();}
| '\r' '\n' {newline();}
| .
)
{$setType(CHAR);}
;
What I'm trying to figure out is how I would stop reading into CHAR when I
reach a comment
TOKEN
: ( TAG ':' ) => TAG ':'' ' {$setType(TAG);}
| EXTCHAR
;
protected
CHAR
: ( '\n' {newline();}
| '\r' '\n' {newline();}
| .
)
;
EXTCHAR: CHAR ~LINE_COMMENT ; //I know I can't do this but how can I have
that behavior?
Also What's the best way to define this so that only the first : in a line
is the token others are ignored. Ex: date: YYYY/MM/DD:HH:MM:SS
Thanks.
More information about the antlr-interest
mailing list