Commits

Gaurav Jain committed d8cf245

Added support for iVar block parsing

Ass seen with Issue #933, the lexer fails to identify methods as after parsing the @implementation keyword as it is still in the 'statement' state and methods are only parsed in the 'root' state. The block after the class name needs to have a seperate state similar to the 'function' state so that we return to the 'root' state after exiting the block.

  • Participants
  • Parent commits 4ddfcf3

Comments (0)

Files changed (1)

File pygments/lexers/compiled.py

             ],
             'oc_classname' : [
                 # interface definition that inherits
+                ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?(\s*)({)',
+                 bygroups(Name.Class, Text, Name.Class, Text, Punctuation), ('#pop', 'oc_ivars')),
                 ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?',
                  bygroups(Name.Class, Text, Name.Class), '#pop'),
                 # interface definition for a category
+                ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))(\s*)({)',
+                 bygroups(Name.Class, Text, Name.Label, Text, Punctuation), ('#pop', 'oc_ivars')),
                 ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\([a-zA-Z$_][a-zA-Z0-9$_]*\))',
                  bygroups(Name.Class, Text, Name.Label), '#pop'),
                 # simple interface / implementation
+                ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)({)',
+                 bygroups(Name.Class, Text, Punctuation), ('#pop', 'oc_ivars')),
                 ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop')
             ],
             'oc_forward_classname' : [
               ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*;?)',
                bygroups(Name.Class, Text), '#pop')
             ],
+            'oc_ivars' : [
+              include('whitespace'),
+              include('statements'),
+              (';', Punctuation),
+              ('{', Punctuation, '#push'),
+              ('}', Punctuation, '#pop'),
+            ],
             'root': [
               # methods
               (r'^([-+])(\s*)'                         # method marker