]> git.cworth.org Git - apitrace-tests/commitdiff
Pragmas.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 18 Mar 2012 00:35:46 +0000 (00:35 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 18 Mar 2012 00:35:46 +0000 (00:35 +0000)
checker.py

index a235592dac8c1430e951f196f4aef111392d6e57..be1331db8fc50c460529e6f0a6ea35b05d0c6628 100644 (file)
@@ -348,20 +348,7 @@ class Parser:
 
 #######################################################################
 
-ID = 0
-NUMBER = 1
-HEXNUM = 2
-STRING = 3
-
-LPAREN = 4
-RPAREN = 5
-LCURLY = 6
-RCURLY = 7
-COMMA = 8
-AMP = 9
-EQUAL = 11
-
-BLOB = 12
+ID, NUMBER, HEXNUM, STRING, PRAGMA, LPAREN, RPAREN, LCURLY, RCURLY, COMMA, AMP, EQUAL, BLOB = xrange(13)
 
 
 class CallScanner(Scanner):
@@ -382,6 +369,9 @@ class CallScanner(Scanner):
 
         # String IDs
         (STRING, r'"[^"\\]*(?:\\.[^"\\]*)*"', False),
+        
+        # Pragma
+        (PRAGMA, r'#[^\r\n]*', False),
     ]
 
     # symbol table
@@ -433,9 +423,22 @@ class CallParser(Parser):
 
     def parse(self):
         while not self.eof():
+            self.parse_element()
+
+    def parse_element(self):
+        if self.lookahead.type == PRAGMA:
+            # TODO
+            token = self.consume()
+            self.handlePragma(token.text)
+        else:
             self.parse_call()
 
     def parse_call(self):
+        while self.lookahead.type == PRAGMA:
+            # TODO
+            token = self.consume()
+            print token.text
+
         if self.lookahead.type == NUMBER:
             token = self.consume()
             callNo = int(token.text)
@@ -533,7 +536,7 @@ class CallParser(Parser):
         self.consume(rtype)
 
         return elements
-
+    
     def handleID(self, value):
         return LiteralValueMatcher(value)
 
@@ -564,6 +567,10 @@ class CallParser(Parser):
         sys.stdout.write(str(matcher))
         sys.stdout.write('\n')
 
+    def handlePragma(self, line):
+        sys.stdout.write(line)
+        sys.stdout.write('\n')
+
 
 def main():
     parser = CallParser(sys.stdin)