[antlr-interest] chat message parser rule?
ian eyberg
ian at telematter.com
Mon Jan 26 12:16:22 PST 2009
Oh awesome antlr apostles:
I've been stuggling with a parser rule and
am hoping you might be able to help me.
I'm have a bit of data I'm trying to parse that
looks something like this:
username: the rain in spain stays....
Running this through antlrworks I am hitting my 'chatrule'
every time but it will start chopping up the
player's message into other tokens that I have defined.
My question: why wouldn't the ALPHA token always be
chosen over the other tokens?
For example say I have a token of:
LAMB : 'rack';
and my player's chat message comes across as:
joeblow: the rain in spain
my abbr. grammar:
--------------------------------------------------------
chatrule : player COLON_SPACE ~NEWLINE+;
player : (INT | ALPHA | WS)+ ;
fragment LOWER_LETTER : 'a'..'z' ;
fragment UPPER_LETTER : 'A'..'Z' ;
ALPHA : (LOWER_LETTER | UPPER_LETTER)+ ;
COMMA_SP : ',' ' ' ;
COLON_SP : ': ';
fragment DIGIT : ('0'..'9')+ ;
INT : DIGIT COMMA_SP?;
COMMA_INT
NEWLINE : '\r'? '\n' ;
--------------------------------------------------------
thanks,
Ian
More information about the antlr-interest
mailing list