Andy Li avatar Andy Li committed 33db55f

A number of fixes.

Comments (0)

Files changed (1)

pygments/lexers/web.py

     typeid = r'_*[A-Z][_a-zA-Z0-9]*' 
     
     # combined ident and dollar and idtype
-    ident = r'(?:_*[a-z][_a-zA-Z0-9]*|_+[0-9][_a-zA-Z0-9]*|' + typeid + '|_+|\$[_a-zA-Z0-9]*)'
+    ident = r'(?:_*[a-z][_a-zA-Z0-9]*|_+[0-9][_a-zA-Z0-9]*|' + typeid + '|_+|\$[_a-zA-Z0-9]+)'
     
     # ident except keywords
     ident_no_keyword = r'(?!' + keyword + ')' + ident
             self.preproc_stack.append(ctx.stack[:])
         elif proc in ['else', 'elseif']:
             # restore the stack back to right before #if
-            if len(self.preproc_stack): ctx.stack = self.preproc_stack[-1]
+            if self.preproc_stack: ctx.stack = self.preproc_stack[-1][:]
         elif proc == 'end':
             # remove the saved stack of previous #if
-            if len(self.preproc_stack): self.preproc_stack.pop()
+            if self.preproc_stack: self.preproc_stack.pop()
         
         # #if and #elseif should follow by an expr
         if proc in ['if', 'elseif']:
         'using': [
             include('spaces'),
             (ident, Name.Namespace),
-            (r'\.', Punctuation, 'ident'),
+            (r'\.', Punctuation, 'import-ident'),
             (r'', Text, '#pop'),
         ],
          
         
         'abstract' : [
             include('spaces'),
-            (r'', Text, ('#pop', 'abstract-body', 'abstract-relation', 'type-param-constraint', 'type-name')),
+            (r'', Text, ('#pop', 'abstract-body', 'abstract-relation', 'abstract-opaque', 'type-param-constraint', 'type-name')),
         ],
         
         'abstract-body' : [
             (r'\{', Punctuation, ('#pop', 'class-body')),
         ],
         
+        'abstract-opaque' : [
+            include('spaces'),
+            (r'\(', Punctuation, ('#pop', 'parenthesis-close', 'type')),
+            (r'', Text, '#pop'),
+        ],
+        
         'abstract-relation': [
             include('spaces'),
-            (r'(?:=>|<=)', Keyword.Declaration, 'type'),
+            (r'(?:to|from)', Keyword.Declaration, 'type'),
             (r',', Punctuation),
             (r'', Text, '#pop'),
         ],
         'extends': [
             include('spaces'),
             (r'(?:extends|implements)\b', Keyword.Declaration, 'type'),
-            (r',', Punctuation),
+            (r',', Punctuation), #the comma is made optional here, since haxe2 requires the comma but haxe3 does not allow it.
             (r'', Text, '#pop'),
         ],
         
             (r'\{', Punctuation, '#pop'),
         ],
         
+        'bracket-close': [
+            include('spaces'),
+            (r'\}', Punctuation, '#pop'),
+        ],
+        
         'class-body': [
             include('spaces'),
             include('meta'),
             (r'\}', Punctuation, '#pop'),
-            (r'(?:static|public|private|override|dynamic|inline)\b', Keyword.Declaration),
+            (r'(?:static|public|private|override|dynamic|inline|macro)\b', Keyword.Declaration),
             (r'', Text, 'class-member'),
         ],
         
         'class-member': [
             include('spaces'),
             (r'(var)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'prop')),
-            (r'(function)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'function')),
+            (r'(function)\b', Keyword.Declaration, ('#pop', 'optional-semicolon', 'class-method')),
         ],
         
         # local function, anonymous or not
             (r'', Text, '#pop'),
         ],
         
-        'function': [
+        'class-method': [
             include('spaces'),
             (ident, Name.Function, ('#pop', 'optional-expr', 'flag', 'function-param', 'parenthesis-open', 'type-param-constraint')),
         ],
         ],
         
         'expr-statement': [
+            include('spaces'),
             # makes semicolon optional here, just to avoid checking the last one is bracket or not.
             (r'', Text, ('#pop', 'optional-semicolon', 'expr')),
         ],
             (r'(?:return)\b', Keyword, ('#pop', 'optional-expr')),
             (r'(?:macro)\b', Keyword, ('#pop', 'macro')),
             (r'(?:continue|break)\b', Keyword, '#pop'),
+            (r'(?:\$\s*[a-z]\b|\$(?!'+ident+'))', Name, ('#pop', 'dollar')),
             (ident_no_keyword, Name, ('#pop', 'expr-chain')),
             
             # Float
         'expr-chain': [
             include('spaces'),
             (r'(?:\+\+|\-\-)', Operator),
-            (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>>=|>>>=|==|!=|<=|>=|&&|\|\||<<|>>>|>>|\.\.\.|<|>|%|&|\||\^|\+|\*|/|\-|=)', Operator, ('#pop', 'expr')),
+            (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>>=|>>>=|==|!=|<=|>=|&&|\|\||<<|>>>|>>|\.\.\.|<|>|%|&|\||\^|\+|\*|/|\-|=>|=)', Operator, ('#pop', 'expr')),
             (r'(?:in)\b', Keyword, ('#pop', 'expr')),
             (r'\?', Operator, ('#pop', 'expr', 'ternary', 'expr')),
             (r'(\.)(' + ident_no_keyword + ')', bygroups(Punctuation, Name)),
             include('spaces'),
             (ident, Name, '#pop'),
         ],
+              
+        'dollar': [
+            include('spaces'),
+            (r'\{', Keyword, ('#pop', 'bracket-close', 'expr')),
+            (r'', Text, ('#pop', 'expr-chain')),
+        ],
         
         'type-name': [
             include('spaces'),
             include('spaces'),
             (r'\}', Punctuation, '#pop'),
             (r'\?', Punctuation),
+            (r'>', Punctuation, ('comma', 'type')),
             (ident_no_keyword, Name, ('#pop', 'type-struct-sep', 'type', 'colon')),
             include('class-body'),
         ],
         # bracket can be block or object
         'bracket': [
             include('spaces'),
-            (ident_no_keyword, Name, ('#pop', 'bracket-check')),
+            (r'(?!(?:\$\s*[a-z]\b|\$(?!'+ident+')))' + ident_no_keyword, Name, ('#pop', 'bracket-check')),
             (string1, String.Single, ('#pop', 'bracket-check')),
             (string2, String.Double, ('#pop', 'bracket-check')),
             (r'', Text, ('#pop', 'block')),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.