[antlr-interest] Newbie : help please

Xavier Benveniste xavier.benveniste at free.fr
Mon Jul 25 03:52:46 PDT 2005


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/fe4375ca/attachment.html


More information about the antlr-interest mailing list