Commits

Eric Knibbe committed 4240616

more fixes and colouring improvements

  • Participants
  • Parent commits a083148

Comments (0)

Files changed (1)

File pygments/lexers/web.py

             (r'\?>', Comment.Preproc, '#pop'),
             include('lasso'),
         ],
-        'lasso': [
-            # whitespace/comments
+        'whitespacecomments': [
             (r'\s+', Text),
             (r'//.*?\n', Comment.Single),
             (r'/\*\*!.*?\*/', String.Doc),
             (r'/\*.*?\*/', Comment.Multiline),
+        ],
+        'lasso': [
+            # whitespace/comments
+            include('whitespacecomments'),
 
             # literals
             (r'\d*\.\d+(e[+-]?\d+)?', Number.Float),
             (r'(define)(\s+)([a-z_][\w.]*)',
                 bygroups(Keyword.Declaration, Text, Name.Function),
                 'signature'),
-            (r'(public|protected|private|provide)(\s+)([a-z_][\w.]*=?|'
-             r'[-+*/%<>]|==)(\s*)(\()',
-                bygroups(Keyword, Text, Name.Function, Text, Punctuation),
-                ('signature', 'parameter')),
+            (r'(public|protected|private|provide)(\s+)(([a-z_][\w.]*=?|'
+             r'[-+*/%<>]|==)(?=\s*\())', bygroups(Keyword, Text, Name.Function),
+                'signature'),
             (r'(public|protected|private)(\s+)([a-z_][\w.]*)',
                 bygroups(Keyword, Text, Name.Function)),
 
              r'null)\b', Keyword.Type),
             (r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Text, Keyword)),
             (r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Text, Name)),
+            (r'require\b', Keyword, 'requiresection'),
             (r'(/?)(Namespace_Using)\b',
                 bygroups(Punctuation, Keyword.Namespace)),
             (r'(/?)(Cache|Database_Names|Database_SchemaNames|'
                  bygroups(Punctuation, Keyword)),
 
             # other
+            (r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=\s*\([^)]*\)\s*=>))',
+                Name.Function, 'signature'),
             (r'(and|or|not)\b', Operator.Word),
             (r'([a-z_][\w.]*)(\s*)(::\s*)([a-z_][\w.]*)(\s*)(=)',
                 bygroups(Name, Text, Punctuation, Name.Label, Text, Operator)),
              r'[abefnrtv?\"\'\\]|$)', String.Escape),
         ],
         'signature': [
+            (r'=>', Operator, '#pop'),
+            (r'\)', Punctuation, '#pop'),
             (r'[(,]', Punctuation, 'parameter'),
-            (r'=>', Operator, '#pop'),
             include('lasso'),
         ],
         'parameter': [
+            (r'\)', Punctuation, '#pop'),
+            (r'-?[a-z_][\w.]*', Name.Attribute, '#pop'),
             (r'\.\.\.', Name.Builtin.Pseudo),
-            (r'-?[a-z_][\w.]*', Name.Attribute, '#pop'),
-            (r'\)', Punctuation, '#pop'),
             include('lasso'),
         ],
+        'requiresection': [
+            (r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=\s*\())', Name, 'requiresignature'),
+            (r'(([a-z_][\w.]*=?|[-+*/%<>]|==)(?=(\s*::\s*[\w.]+)?\s*,))', Name),
+            (r'[a-z_][\w.]*=?|[-+*/%<>]|==', Name, '#pop'),
+            (r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
+            (r',', Punctuation),
+            include('whitespacecomments'),
+        ],
+        'requiresignature': [
+            (r'(\)(?=(\s*::\s*[\w.]+)?\s*,))', Punctuation, '#pop'),
+            (r'\)', Punctuation, '#pop:2'),
+            (r'-?[a-z_][\w.]*', Name.Attribute),
+            (r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
+            (r'\.\.\.', Name.Builtin.Pseudo),
+            (r'[(,]', Punctuation),
+            include('whitespacecomments'),
+        ],
     }
 
     def __init__(self, **options):