]> git.cworth.org Git - apitrace/commitdiff
Parse C comments around prototypes in gltxt.py
authorArnaud Vrac <rawoul@gmail.com>
Mon, 19 Dec 2011 01:37:45 +0000 (02:37 +0100)
committerArnaud Vrac <rawoul@gmail.com>
Mon, 19 Dec 2011 12:57:03 +0000 (13:57 +0100)
specs/scripts/gltxt.py

index c1a0aeaf1039baccc456b0436e46ea4ac35ef631..b30b87c4f04549d2ee901ac09733db7d2413f480 100755 (executable)
@@ -97,6 +97,9 @@ class TxtParser(LineParser):
     property_re = re.compile(r'^\w+:')
     prototype_re = re.compile(r'^(\w+)\((.*)\)$')
 
+    comment_start_re = re.compile(r'^/\*')
+    comment_end_re = re.compile(r'.*\*/$')
+
     def __init__(self, stream, prefix=''):
         LineParser.__init__(self, stream)
         self.prefix = prefix
@@ -133,9 +136,23 @@ class TxtParser(LineParser):
             name = line.strip()
             print '    # %s' % name
 
+    def skip_c_comments(self):
+        while not self.eof():
+            line = self.lookahead().strip()
+            mo = self.comment_start_re.match(line)
+            if not mo:
+                return
+            while not self.eof():
+                self.consume()
+                mo = self.comment_end_re.match(line)
+                if mo:
+                    return
+                line = self.lookahead().strip()
+
     def parse_procs(self):
         lines = []
         while not self.eof():
+            self.skip_c_comments()
             line = self.lookahead()
             if not line.strip():
                 self.consume()