all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: ruby-mide, SMIE and token priority
Date: Wed, 06 Nov 2013 23:30:53 -0500	[thread overview]
Message-ID: <jwvzjpg975h.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <527B069B.6020400@yandex.ru> (Dmitry Gutov's message of "Thu, 07 Nov 2013 05:18:51 +0200")

> bar.foo(tee) do
>   bar
> end

What is the AST corresponding to this code?
I mean, is it a method call on "bar" with method "foo" and 2 arguments
(tee and do...end)?  I.e. (. bar foo tee (do-end bar))?

> The problem seems to be that "." is considered the parent token of
> "do".  Probably because the left priority of "do" is not a number.

SMIE parses it as (. bar (call foo tee (do-end bar))).

> It would be more natural if the parent of "do" was ";" on the preceding
> line, instead.

You mean parse it as (call (. bar foo tee) (do-end bar))?

> Is it at all possible to change the grammar this way?

You'd probably have to use a trick similar to the " @ " used on the
space between the method name and the multiple-args.

> Or should we just handle this as a special case in the `ruby-smie-rules',
> and in case of "do", instead of delegating to the parent, skip the parents
> until we find ";"?

Depends: the rule of thumb is that if you have to choose between "make
the grammar match the AST" or "make the grammar match the indentation",
then better choose "match the AST" and then adjust the indentation via
the smie-rules.

So if the indentation you want is indeed not faithful to the AST, then
indeed it's better to fix it in smie-rules.  But otherwise, if you can
fix it in the grammar, then it's preferable.


        Stefan



  reply	other threads:[~2013-11-07  4:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-07  3:18 ruby-mide, SMIE and token priority Dmitry Gutov
2013-11-07  4:30 ` Stefan Monnier [this message]
2013-11-07 13:10   ` Dmitry Gutov
2013-11-07 16:02     ` Stefan Monnier
2013-11-11  9:14       ` Bozhidar Batsov
2013-11-11 12:56         ` Dmitry Gutov
2013-11-11 15:13           ` Bozhidar Batsov
2013-11-11 17:19             ` Dmitry Gutov

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

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

  git send-email \
    --in-reply-to=jwvzjpg975h.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.