Commits

Patrick Dubroy  committed ff91276

Change multiline comments in C, Cpp, & ObjC to support incremental lexing.

  • Participants
  • Parent commits f04a348

Comments (0)

Files changed (1)

File pygments/lexers/compiled.py

             (r'\s+', Text),
             (r'\\\n', Text), # line continuation
             (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
-            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+            (r'/(\\\n)?[*]', Comment.Multiline, 'comment'),
         ],
         'statements': [
             (r'L?"', String, 'string'),
             (r'\\\n', String), # line continuation
             (r'\\', String), # stray backslash
         ],
+        'comment': [
+            (r'.*?[*](\\\n)?/', Comment.Multiline, '#pop'),
+            (r'.*\n', Comment.Multiline)
+        ],
         'macro': [
             (r'[^/\n]+', Comment.Preproc),
-            (r'/[*](.|\n)*?[*]/', Comment.Multiline),
+            (r'/(\\\n)?[*]', Comment.Multiline, 'comment'),
             (r'//.*?\n', Comment.Single, '#pop'),
             (r'/', Comment.Preproc),
             (r'(?<=\\)\n', Comment.Preproc),
             (r'\s+', Text),
             (r'\\\n', Text), # line continuation
             (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
-            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+            (r'/(\\\n)?[*]', Comment.Multiline, 'comment'),
             (r'[{}]', Punctuation),
             (r'L?"', String, 'string'),
             (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
             (r'\\\n', String), # line continuation
             (r'\\', String), # stray backslash
         ],
+        'comment': [
+            (r'.*?[*](\\\n)?/', Comment.Multiline, '#pop'),
+            (r'.*\n', Comment.Multiline)
+        ],
         'macro': [
             (r'[^/\n]+', Comment.Preproc),
-            (r'/[*](.|\n)*?[*]/', Comment.Multiline),
+            (r'/(\\\n)?[*]', Comment.Multiline, 'comment'),
             (r'//.*?\n', Comment.Single, '#pop'),
             (r'/', Comment.Preproc),
             (r'(?<=\\)\n', Comment.Preproc),
             (r'\s+', Text),
             (r'\\\n', Text), # line continuation
             (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
-            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+            (r'/(\\\n)?[*]', Comment.Multiline, 'comment'),
         ],
         'statements': [
             (r'(L|@)?"', String, 'string'),
             (r'\\\n', String), # line continuation
             (r'\\', String), # stray backslash
         ],
+        'comment': [
+            (r'.*?[*](\\\n)?/', Comment.Multiline, '#pop'),
+            (r'.*\n', Comment.Multiline)
+        ],
         'macro': [
             (r'[^/\n]+', Comment.Preproc),
-            (r'/[*](.|\n)*?[*]/', Comment.Multiline),
+            (r'/(\\\n)?[*]', Comment.Multiline, 'comment'),
             (r'//.*?\n', Comment.Single, '#pop'),
             (r'/', Comment.Preproc),
             (r'(?<=\\)\n', Comment.Preproc),