Skip to content

Commit

Permalink
Fix recognizing arguments shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
lkinasiewicz committed May 31, 2020
1 parent 0886e9e commit dc426fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/rouge/lexers/livescript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ def self.loop_control_keywords
push :id
end

# operators
rule %r(
[+][+]|--|&&|\b(and|x?or|is(nt)?|not)\b(?!-[a-zA-Z]|_)|[|][|]|
[.]([|&^]|<<|>>>?)[.]|\\(?=\n)|[.:]=|<<<<?|<[|]|[|]>|
(<<|>>|==?|!=?|[-<>+*%^/~?])=?
)x, Operator, :slash_starts_regex

# instance attributes
rule %r/(@)(#{id})/ do
groups Name::Variable::Instance, Name::Attribute
Expand All @@ -90,13 +97,6 @@ def self.loop_control_keywords
groups Name::Builtin, Name::Attribute
end

# operators
rule %r(
[+][+]|--|&&|\b(and|x?or|is(nt)?|not)\b(?!-[a-zA-Z]|_)|[|][|]|
[.]([|&^]|<<|>>>?)[.]|\\(?=\n)|[.:]=|<<<<?|<[|]|[|]>|
(<<|>>|==?|!=?|[-<>+*%^/~?])=?
)x, Operator, :slash_starts_regex

# switch case
rule %r/[|]|\bcase(?=\s)/, Keyword, :switch_underscore

Expand Down
3 changes: 3 additions & 0 deletions spec/visual/samples/livescript
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ c = ^^...[copy, these, {}]
delete ...list[1, 2, 3]
do ...[a, b, c]

# arguments shorthand &
-> &1 + &2 || &a + &b || &

# Imports
obj = {one: 1, two: 2}
obj <<< three: 3
Expand Down

0 comments on commit dc426fd

Please sign in to comment.