I'm trying SMIE to describe the Nix language. Unfortunately when I use it, I have the following problems:
- There are 4 messages saying:
Warning (smie): token } is both closer and neither
. Which I do not understand. - A message asks you for a comment syntax : but the syntax table has a comment character. So again, I don't understand
- If you enter
#
as comment character, you will see that indentation is 28 instead of the expected 2.
I put all my code on Github | nix-mode. You can reproduce by cloning the repository, running cask
and then running cask exec ecukes
.
Here is the SMIE grammar for Nix:
(defvar nix+-smie-grammar
(smie-prec2->grammar
(smie-bnf->prec2
'((id)
(expr (exprfunction))
(exprfunction ("{" formals "}" ":" exprfunction)
(exprassert))
(exprassert ("assert" expr ";" exprassert)
(exprif))
(exprif ("if" expr "then" expr "else" expr)
(exprop))
(exprop ("!" exprop)
(exprop "==" exprop)
(exprop "!=" exprop)
(exprop "&&" exprop)
(exprop "||" exprop)
(exprop "->" exprop)
(exprop "//" exprop)
(exprop "~" exprop)
(exprop "?" id)
(exprapp))
(exprapp (exprapp "." exprselect)
(exprselect))
(exprselect (exprsimple))
(exprsimple (id)
("true")
("false")
("null")
("(" expr ")")
("{" binds "}")
("let" "{" binds "}")
("rec" "{" binds "}")
("[" exprselects "]"))
(binds (binds ";" binds)
(bind))
(exprselects (expreselect))
(bind (id "=" expr)
("inherit" exprp))
(exprp ("(" expr ")"))
(formals (formals "," formals)
(formal))
(formal (id)
(id "?" expr)))
'((assoc ";"))
'((assoc ","))
'((assoc "==")
(assoc "!=")
(assoc "&&")
(assoc "||")
(assoc "->")
(assoc "//")
(assoc "~")
(assoc "?")
(assoc "!")))))