I am trying to implement a feature in my language where you can execute a statement after returning in a function by doing return someVal then someCode()
.
I have the following grammar for return statements:
ReturnStatement:
'RETURN' { $$ = new yy.ReturnStatement(null).pos(@$)}
| 'RETURN' Expression { $$ = new yy.ReturnStatement($2).pos(@$)}
| 'RETURN' Expression 'THEN' Statement %prec 'AFTER' { $$ = new yy.ReturnStatement($2, $4).pos(@$)}
;
In the header of the Jison file I have the following precedence rules:
%nonassoc 'NAME'
%right ':'
%nonassoc 'IF'
%nonassoc 'ENDLN'
%nonassoc 'ELSE'
%nonassoc 'DEF'
%right 'ASSIGN' ''
%left 'YIELD'
%left 'OR'
%left 'AND'
%left '==' '!=' '<' '>' '<=' '>='
%left '+' '-' '&'
%left '*' '//' '%' '/'
%right 'UMIN' 'UPLUS'
%left '^'
%left 'AWAIT'
%right 'TYPEOF'
%right 'UB_FUNC' 'B_FUNC'
%left 'ACCESS'
%nonassoc 'INDEX_LEFT' 'INDEX_RIGHT'
%left 'CALL_LEFT' 'CALL_RIGHT'
%right 'NEW'
%nonassoc 'AFTER'
%%
I am aware that Jison will shift by default when a conflict exists, but I would like to set up precedence rules such that I do not get shift/reduce conflict warnings in Jison. I thougt setting precedence to the last rule over all others would do that, but I get this instead:
Conflict in grammar: multiple actions possible when lookahead token is - in state 53
- reduce by rule: Continuation -> YIELD
- shift token (then go to state 63)
Conflict in grammar: multiple actions possible when lookahead token is + in state 53
- reduce by rule: Continuation -> YIELD
- shift token (then go to state 64)
Conflict in grammar: multiple actions possible when lookahead token is - in state 54
- reduce by rule: Continuation -> AWAIT
- shift token (then go to state 63)
Conflict in grammar: multiple actions possible when lookahead token is + in state 54
- reduce by rule: Continuation -> AWAIT
- shift token (then go to state 64)
Conflict in grammar: multiple actions possible when lookahead token is CALL_LEFT in state 131
- reduce by rule: Expression -> MemberExpression
- shift token (then go to state 91)
Conflict in grammar: multiple actions possible when lookahead token is CALL_LEFT in state 132
- reduce by rule: Expression -> Identifier
- shift token (then go to state 91)
Conflict in grammar: multiple actions possible when lookahead token is % in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 87)
Conflict in grammar: multiple actions possible when lookahead token is // in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 86)
Conflict in grammar: multiple actions possible when lookahead token is / in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 85)
Conflict in grammar: multiple actions possible when lookahead token is * in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 84)
Conflict in grammar: multiple actions possible when lookahead token is - in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 83)
Conflict in grammar: multiple actions possible when lookahead token is + in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 82)
Conflict in grammar: multiple actions possible when lookahead token is & in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 81)
Conflict in grammar: multiple actions possible when lookahead token is >= in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 80)
Conflict in grammar: multiple actions possible when lookahead token is <= in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 79)
Conflict in grammar: multiple actions possible when lookahead token is > in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 78)
Conflict in grammar: multiple actions possible when lookahead token is < in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 77)
Conflict in grammar: multiple actions possible when lookahead token is != in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 76)
Conflict in grammar: multiple actions possible when lookahead token is == in state 134
- reduce by rule: Continuation -> YIELD Expression
- shift token (then go to state 75)
Conflict in grammar: multiple actions possible when lookahead token is % in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 87)
Conflict in grammar: multiple actions possible when lookahead token is // in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 86)
Conflict in grammar: multiple actions possible when lookahead token is / in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 85)
Conflict in grammar: multiple actions possible when lookahead token is * in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 84)
Conflict in grammar: multiple actions possible when lookahead token is - in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 83)
Conflict in grammar: multiple actions possible when lookahead token is + in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 82)
Conflict in grammar: multiple actions possible when lookahead token is & in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 81)
Conflict in grammar: multiple actions possible when lookahead token is >= in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 80)
Conflict in grammar: multiple actions possible when lookahead token is <= in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 79)
Conflict in grammar: multiple actions possible when lookahead token is > in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 78)
Conflict in grammar: multiple actions possible when lookahead token is < in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 77)
Conflict in grammar: multiple actions possible when lookahead token is != in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 76)
Conflict in grammar: multiple actions possible when lookahead token is == in state 135
- reduce by rule: Continuation -> AWAIT Expression
- shift token (then go to state 75)
Conflict in grammar: multiple actions possible when lookahead token is == in state 151
- reduce by rule: UnaryExpression -> - Expression
- shift token (then go to state 75)
Conflict in grammar: multiple actions possible when lookahead token is != in state 151
- reduce by rule: UnaryExpression -> - Expression
- shift token (then go to state 76)
Conflict in grammar: multiple actions possible when lookahead token is < in state 151
- reduce by rule: UnaryExpression -> - Expression
- shift token (then go to state 77)
Conflict in grammar: multiple actions possible when lookahead token is > in state 151
- reduce by rule: UnaryExpression -> - Expression
- shift token (then go to state 78)
Conflict in grammar: multiple actions possible when lookahead token is <= in state 151
- reduce by rule: UnaryExpression -> - Expression
- shift token (then go to state 79)
Conflict in grammar: multiple actions possible when lookahead token is >= in state 151
- reduce by rule: UnaryExpression -> - Expression
- shift token (then go to state 80)
...
Any help on solving this through precedence rules will be greatly appreciated.
Thank you in advance!