diff python/c3/lexer.py @ 204:de3a68f677a5

Added long comment to c3 parser
author Windel Bouwman
date Fri, 21 Jun 2013 15:01:08 +0200
parents b01429a5d695
children d77cb5962cc5
line wrap: on
line diff
--- a/python/c3/lexer.py	Sat Jun 15 19:13:05 2013 +0200
+++ b/python/c3/lexer.py	Fri Jun 21 15:01:08 2013 +0200
@@ -26,6 +26,8 @@
        ('NEWLINE', r'\n'),
        ('SKIP', r'[ \t]'),
        ('COMMENTS', r'//.*'),
+       ('LONGCOMMENTBEGIN', r'\/\*'),
+       ('LONGCOMMENTEND', r'\*\/'),
        ('LEESTEKEN', r'==|[\.,=:;\-+*\[\]/\(\)]|>=|<=|<>|>|<|{|}'),
        ('STRING', r"'.*?'")
      ]
@@ -34,16 +36,23 @@
      line = 1
      pos = line_start = 0
      mo = gettok(s)
+     incomment = False
      while mo is not None:
        typ = mo.lastgroup
        val = mo.group(typ)
        if typ == 'NEWLINE':
          line_start = pos
          line += 1
-       elif typ == 'COMMENTS':
+       elif typ == 'COMMENT':
          pass
+       elif typ == 'LONGCOMMENTBEGIN':
+          incomment = True
+       elif typ == 'LONGCOMMENTEND':
+          incomment = False
        elif typ == 'SKIP':
          pass
+       elif incomment:
+         pass # Wait until we are not in a comment section
        else:
          if typ == 'ID':
            if val in keywords: