
Python3.test.ctest.py Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of antlr4-runtime-testsuite Show documentation
Show all versions of antlr4-runtime-testsuite Show documentation
A collection of tests for ANTLR 4 Runtime libraries.
import sys
sys.setrecursionlimit(4000)
import antlr4
from parser.cparser import CParser
from parser.clexer import CLexer
from datetime import datetime
import cProfile
class ErrorListener(antlr4.error.ErrorListener.ErrorListener):
def __init__(self):
super(ErrorListener, self).__init__()
self.errored_out = False
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
self.errored_out = True
def sub():
# Parse the input file
input_stream = antlr4.FileStream("c.c")
lexer = CLexer(input_stream)
token_stream = antlr4.CommonTokenStream(lexer)
parser = CParser(token_stream)
errors = ErrorListener()
parser.addErrorListener(errors)
tree = parser.compilationUnit()
def main():
before = datetime.now()
sub()
after = datetime.now()
print(str(after-before))
# before = after
# sub()
# after = datetime.now()
# print(str(after-before))
if __name__ == '__main__':
cProfile.run("main()", sort='tottime')
© 2015 - 2025 Weber Informatics LLC | Privacy Policy