X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=blobdiff_plain;f=tracematch.py;h=41320c17f27112fa7c6f9d6e091a4c08720cf328;hp=68949b16ce35fad0d6ee37c1ee0ad94125255ede;hb=080f6bcc46197f37856d798cee0ec2b8ed9dcaf4;hpb=d9858b16096ac4ec7c99f1430a6ee934e33db2e0 diff --git a/tracematch.py b/tracematch.py index 68949b1..41320c1 100755 --- a/tracematch.py +++ b/tracematch.py @@ -430,7 +430,7 @@ class Parser: ####################################################################### -ID, NUMBER, HEXNUM, STRING, WILDCARD, PRAGMA, LPAREN, RPAREN, LCURLY, RCURLY, COMMA, AMP, EQUAL, PLUS, VERT, BLOB = xrange(16) +ID, NUMBER, HEXNUM, STRING, WILDCARD, LPAREN, RPAREN, LCURLY, RCURLY, COMMA, AMP, EQUAL, PLUS, VERT, BLOB = xrange(15) class CallScanner(Scanner): @@ -454,9 +454,6 @@ class CallScanner(Scanner): # Wildcard (WILDCARD, r'<[^>]*>', False), - - # Pragma - (PRAGMA, r'#[^\r\n]*', False), ] # symbol table @@ -510,15 +507,8 @@ class TraceParser(Parser): def parse(self): while not self.eof(): - self.parse_element() - return TraceMatcher(self.calls) - - def parse_element(self): - if self.lookahead.type == PRAGMA: - token = self.consume() - self.handlePragma(token.text) - else: self.parse_call() + return TraceMatcher(self.calls) def parse_call(self): if self.lookahead.type == NUMBER: @@ -686,14 +676,11 @@ class TraceParser(Parser): def handleCall(self, callNo, functionName, args, ret): raise NotImplementedError - def handlePragma(self, line): - raise NotImplementedError - class RefTraceParser(TraceParser): - def __init__(self, stream): - TraceParser.__init__(self, stream) + def __init__(self, fileName): + TraceParser.__init__(self, open(fileName, 'rt')) self.calls = [] def parse(self): @@ -730,9 +717,6 @@ class RefTraceParser(TraceParser): def handleCall(self, callNo, functionName, args, ret): call = CallMatcher(callNo, functionName, args, ret) self.calls.append(call) - - def handlePragma(self, line): - pass class SrcTraceParser(TraceParser): @@ -792,8 +776,7 @@ def main(): refFileName, srcFileName = args - refStream = open(refFileName, 'rt') - refParser = RefTraceParser(refStream) + refParser = RefTraceParser(refFileName) refTrace = refParser.parse() if options.verbose: sys.stdout.write('// Reference\n')