[antlr-interest] Newbie : help please
Alexey Demakov
demakov at ispras.ru
Mon Jul 25 04:12:18 PDT 2005
Rule 'atom' referenced in ExprTreeParser should be defined in tree parser, not only in ExprParser.
Regards,
Alexey
-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com
----- Original Message -----
From: Xavier Benveniste
To: antlr-interest at antlr.org
Sent: Monday, July 25, 2005 2:52 PM
Subject: [antlr-interest] Newbie : help please
Hi,
can someone tell me what is wrong with this vers simple grammar ? ( error is : "Rule 'atom' is not defined") Thanks.
class ExprParser extends Parser;
options {
buildAST = true;
defaultErrorHandler = false;
}
atom: INT
;
class ExprLexer extends Lexer;
options {
k = 2; // two characters of lookahead
testLiterals = false; // don't automatically test for literals
charVocabulary = '\u0003'..'\uFFFF'; // allow UNICODE
}
/* Integers */
INT : ('0'..'9')+ ;
/* Comparison operators */
EQUALS : "==";
NOT_EQUALS : "<>";
GT : ">";
GTE : ">=";
LT : "<";
LTE : "<=";
class ExprTreeParser extends TreeParser;
options {
importVocab=ExprParser;
}
expr returns [boolean r=false]
{ int a,b; }
: #(EQUALS a=atom b=atom) {r = (a == b);}
| #(NOT_EQUALS a=atom b=atom) {r = (a != b);}
| #(GT a=atom b=atom) {r = (a > b);}
| #(GTE a=atom b=atom) {r = (a >= b);}
| #(LT a=atom b=atom) {r = (a < b);}
| #(LTE a=atom b=atom) {r = (a <= b);}
;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050725/16e060bc/attachment.html
More information about the antlr-interest
mailing list