emacs-devel
[Top][All Lists]
Advanced

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

Re: Emacs-devel Digest, Vol 148, Issue 12


From: address@hidden
Subject: Re: Emacs-devel Digest, Vol 148, Issue 12
Date: Tue, 7 Jun 2016 15:01:47 -0400

Thank you for the answers.  You are right about the interaction with sml-mode.  I just tried reloading the file and then restarting the derived minor mode manually (M-x my-sml-mode), and the problem is gone.

On Tue, Jun 7, 2016 at 2:59 PM, Stefan Monnier <address@hidden> wrote:
> (require 'smie)
> (defconst sml-smie-grammar
>   (smie-prec2->grammar
>    (smie-bnf->prec2
>     '((exp
>        (var)
>        ("local" exp "in" exp "end"))
>       (var))
>    )))
> (defun sml-smie-rules (kind token)
>   (pcase (cons kind token)
>     (`(:elem . basic) 4)
>     (`(:elem . args) 2)
>     ))
> (define-derived-mode my-sml-mode sml-mode "My SML"
>   (smie-setup
>    sml-smie-grammar
>    #'sml-smie-rules))
>
> indented test.sml:
>
> local
>   local
>   a
> in
>     a
> end
> in
>     a
> end

Hmm... this seems to be clearly an interaction with sml-mode.

I just tried it with my local copy of sml-mode (straight from elpa.git)
and don't see the above indentation behavior.  I also tried it after
replacing `sml-mode' with `prog-mode' as the parent, and that doesn't
show the problematic behavior either.

> Does the equivalent S-_expression_ representing the parse tree have terminals
> in order, or are they moved to the front - i.e. does 1 + 2 for grammar
> (number "+" number) become (1 + 2) or (+ 1 2)?

The tree is never created, so the question doesn't really have an answer.
The grammar is only used for navigation (e.g. to jump over the "+ 2 * z"
in "x + 2 * z + y" when moving forward).

> What does smie-rule-parent-p use to determine the parent of a token?  Is it
> the first token above the S-_expression_ the current token is contained in,
> e.g. in ("a" "b" ("c" "d" "e") "f"), the parent of "d" is "b"?

I think it would be "c".


        Stefan


reply via email to

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