示例#1
0
 def testPrintVisitor(self):
     src = Source('./tests/test.minipl')
     scanner = Scanner(src)
     parser = Parser(scanner)
     ast = parser.program()
     pv = PrintVisitor()
     ast.accept(pv)
示例#2
0
 def testTypeCheckVisitor(self):
     return
     src = Source('./tests/test.minipl')
     scanner = Scanner(src)
     parser = Parser(scanner)
     ast = parser.program()
     tc = TypeCheck()
     ast.accept(tc)
示例#3
0
 def __createAstAndVisitor__(self, lines):
     src = MockSource(lines)
     scanner = Scanner(src)
     parser = Parser(scanner)
     ast = parser.program()
     tc = TypeCheck()
     ast.accept(tc)
     iv = InterpretingVisitor(tc.symbolTable)
     return ast, iv
示例#4
0
 def testInterpretingVisitorWithAFile(self, output, input):
     src = Source('./tests/test.minipl')
     scanner = Scanner(src)
     parser = Parser(scanner)
     ast = parser.program()
     tc = TypeCheck()
     ast.accept(tc)
     iv = InterpretingVisitor(tc.symbolTable)
     ast.accept(iv)
     output.assert_called_with('120')
示例#5
0
def setup(filename):
    src = Source(filename)
    scanner = Scanner(src)
    parser = Parser(scanner)
    ast = parser.program()
    return ast, parser.errors
示例#6
0
 def testParser(self):
     src = Source('./tests/test.minipl')
     scanner = Scanner(src)
     parser = Parser(scanner)
     parser.program()
示例#7
0
 def __createAST__(self, lines):
     src = MockSource(lines)
     scanner = Scanner(src)
     parser = Parser(scanner)
     return parser.program(), parser