Commits

Paul Miller committed 129ffd9

Add support for word arrays and !-> funcs in livescript.

Comments (0)

Files changed (2)

pygments/lexers/web.py

             # this next expr leads to infinite loops root -> slashstartsregex
             #(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
             include('commentsandwhitespace'),
+            (r'(?:\([^()]+\))?[ ]*!?[~-]{1,2}>|'
+             r'(?:\(?[^()\n]+\)?)?[ ]*<[~-]{1,2}!?', Name.Function),
             (r'\+\+|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|=|'
              r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|'
-             r'~(?!\~?[>])|-(?!\-?[>])|[<>+*`%&\|\^/])=?',
+             r'~(?!\~?>)|-(?!\-?>)|<(?!\[)|(?<!\])>|'
+             r'[+*`%&\|\^/])=?',
              Operator, 'slashstartsregex'),
-            (r'(?:\([^()]+\))?\s*[~-]{1,2}>', Name.Function),
-            (r'(?:\(?[^()\n]+\)?)?[ ]*<[~-]{1,2}', Name.Function),
             (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
             (r'[})\].]', Punctuation),
             (r'(for|own|in|of|while|until|loop|break|return|continue|'
             ('"', String, 'dqs'),
             ("'", String, 'sqs'),
             (r'\\[\w$-]+', String),
+            (r'<\[.*\]>', String),
         ],
         'strings': [
             (r'[^#\\\'"]+', String),

tests/examplefiles/livescript-demo.ls

-a = -> 1
-const b = --> 2
-var c = ~> 3
-d = ~~> 10_000_000km * 500ms
-e = (a) -> (b) ~> (c) --> (d, e) ~~> 5
+a = -> [1 to 50]
+const b = --> [2 til 5]
+var c = ~~> 10_000_000km * 500ms
+e = (a) -> (b) ~> (c) --> (d, e) ~~> <[list of words]>
 dashes-identifiers = ->
-  a - a
-  b -- c
-  1-1 1- -1
-  a- a
-  a -a
+  a - a b -- c 1-1 1- -1 a- a a -a
 underscores_i$d = ->
-/regexp1/ and //regexp2//g
-'strings' and "strings" and \strings
-([2 til 10] or [1 to 50])
+  /regexp1/
+  //regexp2//g
+  'strings' and "strings" and \strings
+
+[2 til 10]
   |> map (* 2)
   |> filter (> 5)
   |> fold (+)
 
 class Class extends Anc-est-or
   (args) ->
+    -> ~> !-> !~> !--> !~~>
+    <-! # Comment
+    <~! /* Comment */
 
 copy = (from, to, callback) -->
   error, data <- read file
   error <~ write file, data
   return callback error if error?
   callback()
-
-->
-~>
-~~>
--->
-# Comment
-/* Comment */