unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Matt DeBoard <matt.deboard@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: SMIE
Date: Wed, 9 Jul 2014 23:59:46 -0400	[thread overview]
Message-ID: <CAPLdYOjG=GnKXPbBiY84h=Aquv3vtGAgp6=MEE_A+hw_-0D7Ww@mail.gmail.com> (raw)
In-Reply-To: <CAPLdYOjRntb-ivOM1xpR0_JH=-U6-n18nEfZ8KTJM38tKPqmGg@mail.gmail.com>

As regarding inclusion in GNU ELPA, I'm just a caretaker for the
project on behalf of the Elixir-lang people, but as it's already in
MELPA I'm sure it's fine.

On Wed, Jul 9, 2014 at 11:53 PM, Matt DeBoard <matt.deboard@gmail.com> wrote:
> In general I’m having a hard time connecting the dots between the BNF
> grammar table creation, the smie-rules (i.e. :before, :after, etc.),
> tokenization, indentation, and so forth, and how it all comes together
> to make this indentation machine work.
>
> It’s not that the manual is poorly written. In fact between the manual
> and the code comments it’s pretty comprehensive. It’s just a high
> volume of new information. I think it’ll take me awhile to ingest
> everything, but when I do I’d be glad to contribute back.
>
> Regarding the specific issue I mentioned, I closed that out tonight.
> There was some overly “greedy” definitions in the syntax table, so
> there’s that. I’m slowly starting to pare things away. The bit you
> wrote about :list-intro is interesting. When you say that it sees two
> or more concatenated expressions, how does that tie in to the BNF
> grammar definitions?
>
> On Wed, Jul 9, 2014 at 11:02 PM, Stefan Monnier
> <monnier@iro.umontreal.ca> wrote:
>>> Hi there. As the subject line says I’m writing for help with SMIE.
>>
>> Cool!
>>
>>> I am currently working on elixir-mode
>>> <https://github.com/elixir-lang/emacs-elixir>, having (apparently) taking
>>> over the mode as the latest in a line of contributors.
>>
>> I'd love to include this in GNU ELPA.  Interested?
>>
>>> Specifically I’m having trouble understanding the mental model for how
>>> tokenisation & indentation works.  For example, in this
>>> <https://github.com/elixir-lang/emacs-elixir/issues/18> issue, indentation
>>> errors seem to crop up only after separating lines of code with blank
>>> lines.
>>> I have spent, seriously, hundreds of hours trying to sort out what’s
>>> happening here and I am at my wits’ end.
>>
>> IIUC, Elixir syntax does not treat all whitespace as "irrelevant",
>> contrary to the default tokenizer of SMIE.
>>
>>> Does this issue ring any bells with issues you’ve dealt with in
>>> the past?
>>
>> Yes, indeed.  Octave and sh are two other languages that use SMIE and
>> where some whitespace is syntactically significant.
>>
>> What you need to do is to change the tokenizer so that instead of
>> skipping all whitespace, it turns the syntactically-significant
>> whitespace into a token (you can name it any way you like; in the above
>> languages, it turns out to be syntactically equivalent to a semi-colon,
>> so we call it ";").
>>
>> I know absolutely nothing about Elixir or its syntax, so I can't give
>> you specific details, but you can look at octave.el and sh-script.el
>> for examples.  Feel free to email me back with more details if you need
>> further help.
>>
>>> Final question, how is it determined if a token is a :list-intro token?
>>
>> Not sure I understand the question.  The issue is for the indentation
>> rules, when it sees two (or more) concatenated expressions (e.g. "exp1
>> exp2"), should it assume that exp2 is something like an argument to the
>> exp1 function (and hence exp2 (and exp3, ...) should be indented like
>> a function argument) or are all those "expressions" just a list, where
>> the first is not more special than the second?
>> This usually depends on the context.  E.g. in a situation like
>>
>>    fun x1 x2 x3 =>
>>
>> x2 is not an argument passed to the function x1;  Instead x1, x2, and x3
>> are "siblings" and should be indented to the same level.  So to decide
>> how to indent x2 and x3 w.r.t x1, SMIE calls the smie-rule-function with
>> (:list-intro . "fun") so smie-rule-function can tell it that "fun"
>> introduces a *list* of "things" rather than being followed by a "normal
>> expression".
>>
>> Does that make more sense?
>>
>>> I have read the SMIE manual ten times, at least, but I’m really
>>> struggling.  I would truly appreciate your help.
>>
>> I'm not very good at writing manuals, sorry.  But I promise to do my
>> best to help you get SMIE working well.  In return, I would appreciate
>> if you could help me improve the doc by giving, if not actual patches,
>> at least suggestions of how to rewrite the doc, or what to add to it
>> (usually, you can only make such suggestions after you finally
>> understand what's going on, and at the same time it's
>> important/necessary/useful to try and remember what it was that you
>> didn't understand).
>>
>>
>>         Stefan



  reply	other threads:[~2014-07-10  3:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPLdYOhnp353s3LTM9EORWbzmiH2JXVjFNX1sp07tQYe2Q4MPA@mail.gmail.com>
2014-07-10  3:02 ` SMIE Stefan Monnier
2014-07-10  3:53   ` SMIE Matt DeBoard
2014-07-10  3:59     ` Matt DeBoard [this message]
2014-07-10 17:00       ` SMIE chad
2014-08-16  2:34         ` SMIE Matt DeBoard
2014-08-17  7:27           ` SMIE Bozhidar Batsov
2014-08-17 11:55             ` SMIE Stefan Monnier
2014-08-18 12:00               ` SMIE Bozhidar Batsov
2014-08-18 13:33                 ` SMIE Tassilo Horn
2014-08-18 14:07                 ` SMIE Stefan Monnier
2014-08-19 13:08                 ` SMIE Richard Stallman
2014-08-19 14:12                   ` SMIE Bastien
2014-08-20  2:27                     ` SMIE Richard Stallman
2014-08-20  3:19                       ` SMIE Matt DeBoard
2014-08-20  3:57                         ` SMIE Ivan Andrus
2014-08-20 14:25                           ` SMIE Stefan Monnier
2014-08-27 22:44                             ` SMIE Matt DeBoard
2014-08-28  3:11                               ` SMIE Stefan Monnier
2014-08-28  7:40                                 ` SMIE David Kastrup
2014-08-28 22:03                                   ` SMIE Dmitry
2014-08-17  8:55         ` SMIE Andreas Röhler
2014-07-10 13:32     ` SMIE Stefan Monnier
2014-07-12 14:38     ` SMIE Stephen Leake
2014-07-10  4:22   ` SMIE Matt DeBoard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPLdYOjG=GnKXPbBiY84h=Aquv3vtGAgp6=MEE_A+hw_-0D7Ww@mail.gmail.com' \
    --to=matt.deboard@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).