简体   繁体   English

SableCC期望:EOF

[英]SableCC expecting: EOF

I'm doing an assignment on Compilers for my university, and I am using SableCC 3.7 for the first time. 我正在为我的大学做编译器作业,并且是第一次使用SableCC 3.7。 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 “ 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]-['*'+'/']]*'*''/';

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. 您必须用逗号而不是分号分隔被Ignored Tokens

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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