0
(defvar foo-smie-grammar
  (smie-prec2->grammar
   (smie-bnf->prec2
    '((exp (exp "+" exp)
           (exp "*" exp)
           ("let" let-decls "in" exp))
      (let-decls (let-decls ";" let-decls)
                 (exp)))
    '((assoc ";") (assoc "+") (assoc "*")))))

The above gives warnings:

Warning (smie): Conflict: in >/< *
Warning (smie): Conflict: in >/< +
Warning (smie): Total: 2 warnings

Without the let-decls non-terminal, all is fine. How do I fix this? The grammar isn't obviously problematic to me.

1

I need to add an associativity level for in, making it weaker/looser than the other binary operators. E.g., changing the last line to

    '((assoc "in") (assoc ";") (assoc "+") (assoc "*")))))

This is because the parser needs to be able to see that

  let e1 in e2 + e3

should be parsed as

  let e1 in (e2 + e3)

rather than

  (let e1 in e2) + e3
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.