all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: ruby-mide, SMIE and token priority
Date: Thu, 07 Nov 2013 15:10:59 +0200	[thread overview]
Message-ID: <527B9163.3020102@yandex.ru> (raw)
In-Reply-To: <jwvzjpg975h.fsf-monnier+emacs@gnu.org>

On 07.11.2013 06:30, Stefan Monnier wrote:
>> 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))?

More or less, yes. "bar" could also be a method, but the structure would 
be the same.

>> 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))?

Guess so. The argument in favor of doing it this way is the grammar is 
already a bit skewed toward indentation (for example, " @ " has higher 
priority than "."), but that's likely something to be fixed, too.

>> 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.

Ah, okay. Sounds not very efficient, performance-wise.

>> 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.

Let's try this way, then.



  reply	other threads:[~2013-11-07 13:10 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
2013-11-07 13:10   ` Dmitry Gutov [this message]
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=527B9163.3020102@yandex.ru \
    --to=dgutov@yandex.ru \
    --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 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.