Commits

Andy Li committed 0c0e228

Improved cast.

Comments (0)

Files changed (1)

pygments/lexers/web.py

             (r'', Text, ('#pop', 'expr')),
         ],
         
+        # cast can be written as "cast expr" or "cast(expr, type)"
         'cast': [
             include('spaces'),
-            (r'\(', Punctuation, ('#pop', 'parenthesis-close', 'type', 'comma', 'expr')),
+            (r'\(', Punctuation, ('#pop', 'parenthesis-close', 'cast-type', 'expr')),
             (r'', Text, ('#pop', 'expr')),
         ],
         
+        # optionally give a type as the 2nd argument of cast()
+        'cast-type': [
+            include('spaces'),
+            (r',', Punctuation, ('#pop', 'type')),
+            (r'', Text, '#pop'),
+        ],
+        
         'catch': [
             include('spaces'),
             (r'(?:catch)\b', Keyword, ('expr', 'function-param', 'parenthesis-open')),