X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=blobdiff_plain;f=checker.py;h=be1331db8fc50c460529e6f0a6ea35b05d0c6628;hp=a235592dac8c1430e951f196f4aef111392d6e57;hb=77cd7db1b4deb6f373d708054fced68a9709e9a6;hpb=788d6307640d3b5ab65cda3dc7f7f73f16ad0132 diff --git a/checker.py b/checker.py index a235592..be1331d 100644 --- a/checker.py +++ b/checker.py @@ -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)