简体   繁体   中英

SableCC expecting: EOF

I'm doing an assignment on Compilers for my university, and I am using SableCC 3.7 for the first time. I am trying to define my grammar file, but when I try to run it (via command line) I get this error:

"ParserException: [51,5] expecting: EOF

Helpers

letter = ['a' .. 'z'];
digit = ['0' .. '9'];
plus = '+';
minus = '-';
mult = '*';
div = '/';
star = '*';
equals = '=';
leftbrack = '(';
rightbrack = ')';
leftcurly  = '{';
rightcurly = '{';
tab = 9;
cr = 13;
space = 32;
nl = 10;
eol = cr nl | cr | nl |;
func = 'func';
identifier = (letter|'_')(letter|'_'|digit)*;
float = minus ? digit ( digit ) * '.' digit ( digit ) * ( ( 'E' | 'e' ) ( '+' | '-' ) ? digit ( digit ) * ) ?;
combination = (tab|cr|eol|space|nl)+;
line_comment    ='/''/'[[ 0 .. 0xffff]-[cr+nl]]*eol|';'[[0..0xffff]-[cr+nl]]*eol;
multiline_comment   ='/''*'[[0..0xffff]-['*'+'/']]*'*''/';

Tokens

func = 'FUNC';
plus = plus;
minus = minus;
mult = mult;
div = div;
equals = equals;
leftbrack = leftbrack;
rightbrack = rightbrack;
leftcurly  = leftcurly;
rightcurly = rightcurly;
identifier = ('ID,')(identifier);
float = ('ID,')(float);
number = digit+;
line_comment = 'COMMENT';
multiline_comment = 'COMMENT';
combination = 'WHITESPACE';

Ignored Tokens

line_comment;
multiline_comment;

Does anyone know how to solve this? The documentation online is not the best.

Probably this:

Ignored Tokens

    line_comment,
    multiline_comment;

You have to separate the Ignored Tokens by comma and not semicolon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM