[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange error



pieter@West.NL wrote:
I get a strange error in the following grammar:
Tokens
	star   = '*';
	plus   = '+';
	semi   = ';';
	int    = (['0'..'9'])+;
	blank  = (' ' | 13 | 10 | 9)+;

Ignored Tokens
	blank;

Productions
	expr  = mexpr (plus mexpr)* semi;

mexpr = atom (star atom)*;

atom = int;

You are using parentheses; this is not supported (see documentation and past mailing-list discussions).


Anyway, you are writing your grammar the as if you didn't have an LALR parser.

You probably want to write:

prog = expr semi;

expr =
  {plus} expr plus mexpr |
  {mexpr} mexpr;

mexps =
  {star} mexpr star atom |
  {atom} atom;

atom = int;


Etienne


--
Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/