[antlr-interest] Help with grammar file

mzukowski at yci.com mzukowski at yci.com
Wed Aug 27 10:13:01 PDT 2003

Try putting EOF in your start rule.  What exactly is the error message?
Does it say what rule it was in.


-----Original Message-----
From: solmalik [mailto:boy_wonder48 at hotmail.com] 
Sent: Saturday, August 23, 2003 6:10 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Help with grammar file

Hi have greated a grammar file, which is to be used to parse any 
expressions entered bya user.  The expressions are of process 
algebra and a typical expression looks like:
a[0,2];b[0,1], meaning that (a) is to be executed befroe (b) and (a) 
can be executed by no later than of time 2 units.  Below is the file 
I haved used to try and accept an eqxpression of this form, but When 
I come to running it, I get the error message unexpected token:null  
any help is much appreciated. Thanks.

class P extends Parser;

//rule one or more equations forllowed by newline
: ( equation NEWLINE )+

//a mineqn followed by zero or more operations and mineqns
equation: mineqn (operation mineqn)*

//mineqn is eith ID or an eqn in brackets
mineqn : ID TIME
| OPEN equation CLOSE


class L extends Lexer;

options {
testLiterals = true;

// tokens required for synchronisation and restriction
tokens {
SY_OP = "sy";
RS_OP = "rs";

TIME: '[' ('0' .. '9') ',' ('0' .. '9') ']';

OPEN: '(' ;

CLOSE: ')' ;

BAR_BAR : "|";
CARET : '^' ;

//ID any letter from a to z
ID : ('a' .. 'z' | 'A' .. 'Z');

NEWLINE : ('\r''\n')=> '\r''\n' //DOS
| '\r' //MAC
| '\n' //UNIX
{ newline(); }

WS : (' '|'\t') { $setType(Token.SKIP); } ;


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list