[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ruby-mide, SMIE and token priority
From: |
Stefan Monnier |
Subject: |
Re: ruby-mide, SMIE and token priority |
Date: |
Wed, 06 Nov 2013 23:30:53 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> 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
- ruby-mide, SMIE and token priority, Dmitry Gutov, 2013/11/06
- Re: ruby-mide, SMIE and token priority,
Stefan Monnier <=
- Re: ruby-mide, SMIE and token priority, Dmitry Gutov, 2013/11/07
- Re: ruby-mide, SMIE and token priority, Stefan Monnier, 2013/11/07
- Re: ruby-mide, SMIE and token priority, Bozhidar Batsov, 2013/11/11
- Re: ruby-mide, SMIE and token priority, Dmitry Gutov, 2013/11/11
- Re: ruby-mide, SMIE and token priority, Bozhidar Batsov, 2013/11/11
- Re: ruby-mide, SMIE and token priority, Dmitry Gutov, 2013/11/11