Fix Ruby's operator precedence

* lisp/progmodes/ruby-mode.el (ruby-smie-grammar):
Rearrange the smie-precs->prec2 form.
This commit is contained in:
Dmitry Gutov 2016-03-16 04:32:59 +02:00
parent 1d686c2afb
commit 2036be4666
2 changed files with 28 additions and 6 deletions

View file

@ -406,16 +406,17 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
'((right "=") '((right "=")
(right "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" (right "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^="
"<<=" ">>=" "&&=" "||=") "<<=" ">>=" "&&=" "||=")
(left ".." "...") (nonassoc ".." "...")
(left "+" "-")
(left "*" "/" "%" "**")
(left "&&" "||") (left "&&" "||")
(left "^" "&" "|")
(nonassoc "<=>") (nonassoc "<=>")
(nonassoc ">" ">=" "<" "<=")
(nonassoc "==" "===" "!=") (nonassoc "==" "===" "!=")
(nonassoc "=~" "!~") (nonassoc "=~" "!~")
(nonassoc ">" ">=" "<" "<=")
(left "^" "&" "|")
(left "<<" ">>") (left "<<" ">>")
(left "+" "-")
(left "*" "/" "%")
(left "**")
(assoc ".")))))) (assoc "."))))))
(defun ruby-smie--bosp () (defun ruby-smie--bosp ()

View file

@ -295,10 +295,31 @@ def begin
tee < qux tee < qux
zux do zux do
foo == bar and foo == bar &&
tee == qux tee == qux
a = 3 and
b = 4
end end
foo + bar ==
tee + qux
1 .. 2 &&
3
3 < 4 +
5
10 << 4 ^
20
100 + 2 >>
3
2 ** 10 /
2
foo ^ foo ^
bar bar