bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16416: 24.3; [SMIE] Assertion failure in smie-prec2->grammar


From: Raphael Cauderlier
Subject: bug#16416: 24.3; [SMIE] Assertion failure in smie-prec2->grammar
Date: Tue, 14 Jan 2014 11:03:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> (smie-prec2->grammar (smie-bnf->prec2 '((name) (l ("a" name)))))
>> This raised the following error message:
>> (cl-assertion-failed (numberp (car cons)))
>
> Hmm..indeed.  The assertion can be removed, but then we bump into
> another signal.  The problem is that the grammar is simply "too
> trivial" and smie.el seems to bump into invalid assumptions in
> that case.  As soon as you add some other terminal to the "l" rule, or
> the "name" rule, or you use "l" somewhere, the problem disappears.
>
> Intuitively this problem might manifest itself in a more realistic
> grammar,

I don't know if you would call it realistic but I actually got it with
the following grammar:

  (smie-prec2->grammar
   (smie-bnf->prec2
    '((id)
      (prelude ("#NAME" id))
      (line ("#IMPORT" id)
            (term ".")
            (term ":=" term ".")
            (rule)
            (rule ".")
            ("#ASSERT" term "=~" term "."))
      (rule ("[" context "]" term "-->" term))
      (decl (id ":" term))
      (context (decl "," context)
               (decl))
      (term (id)
            ("{" id "}")
            (decl)
            ("_")
            (term "->" term)
            (decl "=>" term)))
    '((assoc ":")
      (assoc "->" "=>"))))

which I find a bit more complicated than the example grammar given in
the manual section `SMIE Grammar'.

I wrote this from Dedukti BNF grammar.  Dedukti
(https://www.rocq.inria.fr/deducteam/Dedukti/index.html) is a simple
language for which I am writing a major mode
(https://github.com/rafoo/dedukti-mode/blob/master/dedukti-mode.el).

I then minimized the example before reporting, keeping only the `id'
empty rule and the first `line' rule.

> As soon as you add some other terminal to the "l" rule, or
> the "name" rule, or you use "l" somewhere, the problem disappears.

Thank you for your suggestion, I added "\n" at the end of, the first
`line' rule and the problem is solved for me; I can continue to play
with SMIE :)

> yet I don't quite see in which case, and for that reason
> I don't really see yet what would be the right fix.  I'm tempted to
> think that the problem is partly to blame on smie-bnf->prec2 which
> generates a prec2 table where "a" is missing (except for the side info
> of :smie-open/close-alist).

Thank you for your investigation and thank you for SMIE; I am sure it
will help me a lot improving my major mode indentation!

-- 
Raphaël Cauderlier





reply via email to

[Prev in Thread] Current Thread [Next in Thread]