SableCC期待:EOF

时间:2014-09-14 17:49:56

标签: java compiler-construction grammar sablecc

我正在为我的大学做编译工作,我第一次使用SableCC 3.7。我正在尝试定义我的语法文件,但是当我尝试运行它(通过命令行)时,我收到此错误:

“ParserException:[51,5]期待: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]-['*'+'/']]*'*''/';

令牌

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';

忽略的代币

line_comment;
multiline_comment;

有谁知道如何解决这个问题?在线文档并不是最好的。

1 个答案:

答案 0 :(得分:1)

可能这个:

Ignored Tokens

    line_comment,
    multiline_comment;

您必须用逗号分隔Ignored Tokens而不是分号。