> On 30 Nov 2016, at 22:40, Simon Richter <simon.rich...@hogyros.de> wrote: > >>> %token IF "if" >>> %token ELSE "else" > >> This can be resolved by adding >> %nonassoc "then" >> %nonassoc "else" > > Yes, that is what I'm doing, except that I need to give a precedence to > the closing parenthesis because there is no explicit "then" keyword. > > This is why I'd like to use %prec here, in order to avoid inadvertently > introducing a precedence in an unrelated place and hiding errors.
The Bison precedence system looks at the output state and compares the token before the parsing dot ".". So that is probably why you still get an shift/reduce conflict with > if_statement: > "if" /* expr omitted */ statement %prec LOWER | > "if" /* expr omitted */ statement "else" statement %prec HIGHER; as the ";" is not part of it. The workaround is transforming the grammar. The Bison manual section 5.4 Context-Dependent Precedence does not seem to help here. _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison