[antlr-interest] beginner to ANTLR
Rana Rahal
rrahal at protecode.com
Fri Dec 2 05:39:03 PST 2011
I figured out the comment issue
EXTCHAR: CHAR (LINE_COMMENT!)?
But if I can get some help on how I can set TAG to be up to the first ":" in
a line and any other ":" on that same line will be part of the VALUE portion
would be very appreciated.
Thanks
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Rana Rahal
Sent: Thursday, December 01, 2011 3:55 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] beginner to ANTLR
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.
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