0

我正在为我的大学做编译器的作业,我是第一次使用 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;

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

4

1 回答 1

1

大概是这样的:

Ignored Tokens

    line_comment,
    multiline_comment;

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

于 2014-11-18T16:06:00.813 回答