(defvar foo-smie-grammar
    '((exp (exp "+" exp)
           (exp "*" exp)
           ("let" let-decls "in" exp))
      (let-decls (let-decls ";" let-decls)
    '((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 Answer 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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