Loading ...
Sorry, an error occurred while loading the content.

9373Re: Help with grammar file

Expand Messages
  • solmalik
    Sep 1, 2003
    • 0 Attachment
      hi the exact error msg I am getting is "line 1:1: unexpected token:
      null". Any ideas? and what exactly do you mean placing EOF in the
      start rule? I am totally new to this, so don't really have a clue,
      any help much aprreciated thanks.
      --- In antlr-interest@yahoogroups.com, mzukowski@y... wrote:
      > Try putting EOF in your start rule. What exactly is the error
      message?
      > Does it say what rule it was in.
      >
      > Monty
      >
      > -----Original Message-----
      > From: solmalik [mailto:boy_wonder48@h...]
      > Sent: Saturday, August 23, 2003 6:10 AM
      > To: antlr-interest@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
      > startRule
      > : ( 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
      > ;
      >
      > //operations
      > operation
      > : SEMICOLN
      > | BAR_BAR
      > | CARET
      > | ASTERISK
      > | SY_OP
      > | RS_OP
      > ;
      >
      > 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: ')' ;
      >
      > SEMICOLN: ';' ;
      > BAR_BAR : "|";
      > CARET : '^' ;
      > ASTERISK: '*' ;
      >
      >
      > //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/
    • Show all 6 messages in this topic