我正在使用 Jison 编写解析器。这是我的语法:
{
"program": [
["statements EOF", "return $1;"]
],
"statements": [
["statement", "$$ = $1;"],
["statements statement", "$$ = $1 + '\\n' + $2;"]
],
"statement": [
["expression NEWLINE", "$$ = $1 + ';';"]
],
"expression": [
["NUMBER", "$$ = yytext;"],
["expression expression", "$$ = $1 + ', ' + $2;"]
]
}
但是,当我运行它时,我收到以下错误消息:
Conflict in grammar: multiple actions possible when lookahead token is NUMBER in
state 9
- reduce by rule: expression -> expression expression
- shift token (then go to state 5)
States with conflicts:
State 9
expression -> expression expression . #lookaheads= NEWLINE NUMBER
expression -> expression .expression
expression -> .NUMBER
expression -> .expression expression
我应该如何处理此调试消息?你会如何用简单的英语解释这条信息?中的期间expression -> expression expression .
是什么意思?.expression
和是什么.NUMBER
?它们expression
分别有什么不同NUMBER
?