[antlr-interest] (newbie) Unsolved lexer problem
ali azimi
aliaazimi at yahoo.com
Thu Aug 16 17:07:24 PDT 2007
Hi,
Thank you so much for any help you might give me. I have a long grammar and tree walker which work fine. However I have some problems at lexer level which I have not managed to solve for ages.
The grammar at the bottom of this page, is a small part of the grammar which I have written. When debugging:
1) If I give a pair of digit in the form of (x,y), I receive a mismatched error. So I need to remove Decimaldigit from Alphanumeric ( which I dont want to). If I remove it, and give the input (x,y) where x or y or both of them are a single digit, It gives me mismatched error.
2) Rule textinTextSymbol give me mismatched error with any text at any time.
Could you please help me?
1) I need my grammar to match (x,y) where x and y are integers which start from 0.
2)I need my grammar to match texts.
3)I need my grammar to match names.
I appreciate so much.
Best regards,
Al
grammar Crazy;
textInTextSymbol:Text ;
name :NAME;
b26 :'('INT ',' INT ')';
Decimaldigit:'0'..'9';
INT :Decimaldigit+;
NAME: Word ( '_' Word )*;
fragment Special :('+'|'-'|'!'|'>'|';'|'('|')'|'<'|'='|':'|'?'|'&'|'%'|'.'|'_'|',')+;
fragment Word: '.'* AlphaNumeric+ '.'* ;
Text :(AlphaNumeric|Special|'.'|'_'|Space|'\'')*;
fragment Space :' ';
fragment AlphaNumeric :(Uppercase|National|Lowercase|Decimaldigit);
fragment National :'#'|'@'|'"'|'$'|'['|']'|'{'|'}'|'^'|'~' ;
fragment CharacterString :'\'' ( options{greedy=false;}: (~('\''|'\r'|'\n')| '\'' '\''))* '\'';
fragment Lowercase :'a'..'z' ;
fragment Uppercase :'A'..'Z' ;
fragment Apostrophe :'\'';
fragment NEWLINE:'\r' ? '\n' {skip();};
WS : (' ' |'\t' |'\n' |'\r' )+ {skip();} ;
---------------------------------
Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070816/04fc2e1a/attachment-0001.html
More information about the antlr-interest
mailing list