以下は私の文法です:
arithmetic_expression : expression + expression
| expression - expression
expression : constant
| ID
| arithmetic_expression
| ternary
ternary : expression ? expression : expression
この状態で shift-reduce エラーが発生します。
state 126
(19) ternary -> expression QUESTION_MARK expression COLON expression .
(27) arithmetic_exp -> expression . PLUS expression
(28) arithmetic_exp -> expression . MINUS expression
(19) ternary -> expression . QUESTION_MARK expression COLON expression
! shift/reduce conflict for PLUS resolved as shift
! shift/reduce conflict for MINUS resolved as shift
! shift/reduce conflict for QUESTION_MARK resolved as shift
PLUS shift and go to state 86
MINUS shift and go to state 88
QUESTION_MARK shift and go to state 85
! PLUS [ reduce using rule 19 (ternary -> expression QUESTION_MARK expression COLON expression .) ]
! MINUS [ reduce using rule 19 (ternary -> expression QUESTION_MARK expression COLON expression .) ]
! QUESTION_MARK [ reduce using rule 19 (ternary -> expression QUESTION_MARK expression COLON expression .) ]
私は紛争がそれであると信じています
true ? 1 : false ? 3 : 2
true ? 1 : (false ? 3 : 2)
またはとして解釈できます(true ? 1 : false) ? 3 : 2
。
、 の優先順位を+
左結合で、 (右結合に設定した)-
よりも高いレベルに設定しました。?
私は何を間違っていますか?