I'm using Jison to write a parser. This is my grammar:
{
"program": [
["statements EOF", "return $1;"]
],
"statements": [
["statement", "$$ = $1;"],
["statements statement", "$$ = $1 + '\\n' + $2;"]
],
"statement": [
["expression NEWLINE", "$$ = $1 + ';';"]
],
"expression": [
["NUMBER", "$$ = yytext;"],
["expression expression", "$$ = $1 + ', ' + $2;"]
]
}
When I run it however I get the following error message:
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
What am I supposed to make of this debug message? How would you explain this message in simple English? What does the period in expression -> expression expression .
mean? What are .expression
and .NUMBER
? How are they different from expression
and NUMBER
respectively?