[antlr-interest] Grammar for End of Line.
din_wins
din_wins at yahoo.com
Wed Aug 25 22:01:39 PDT 2004
The grammar for which i need to write requires for checking end of
the line and end of the record. i need to check for X or x
respectively.
How I need to go about in writing the gramar for the above. I am here
with producing my grammar file also. When I write rule for checking X
then i am getting lots of errors.
Request any immediate help in this regard.
======================================================================
options {
language = "CSharp";
}
class BMSParser1 extends Parser;
options
{
buildAST = true;
}
file : (line (NEWLINE line)* EOF!) ;
line : (lineexpr)+ ;
lineexpr : (recordexpr ENDLINE)+ ;
recordexpr : ((assignexpr)COMMA)+ ;
assignexpr : aexpr (ASSIGN^ assignexpr)+ ;
aexpr : parenargs (aexpr)+ ;
parenargs : LPAREN
(
assignexpr
(
COMMA!
assignexpr
)*
)
RPAREN
;
class BMSLexer1 extends Lexer;
ENDLINE : 'X';
LPAREN : '(';
RPAREN : ')';
ASSIGN : '=';
COMMA : ',';
WS : (' '
| '\t'
| )
{ _ttype = Token.SKIP; }
;
STREXPR : ('a'..'z' | 'A'..'Z')+ ;
DIGIT : ('0'..'9')+ ;
NEWLINE : ('\r''\n')=> '\r''\n' //DOS
| '\r' //MAC
| '\n' //UNIX
{ newline(); }
;
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list