Beispiel #1
0
 def test_parse_method(self):
     tokens = lex("print 1 + 1;")
     parser = Parser(tokens)
     ast = parser.parse()
     expected_ast = AST(
         [PrintStatement(BinOpexpr("+", Integer(1), Integer(1)))])
     self.assertEqual(ast, expected_ast)
Beispiel #2
0
 def test_parse_method(self):
     tokens = lex("print 1 + 1;")
     parser = Parser(tokens)
     ast = parser.parse()
     expected_ast = AST([PrintStatement(
                         BinOpexpr("+",
                                   Integer(1),
                                   Integer(1)
                                   )
                         )
                         ])
     self.assertEqual(ast, expected_ast)
Beispiel #3
0
 def test_parse_statements_method(self):
     tokens = lex("print 1;")
     parser = Parser(tokens)
     parser.parse()
     expected_ast = AST([PrintStatement(Integer(1))])
     self.assertEqual(parser.ast, expected_ast)
Beispiel #4
0
 def test_parse_statements_method(self):
     tokens = lex("print 1;")
     parser = Parser(tokens)
     parser.parse()
     expected_ast = AST([PrintStatement(Integer(1))])
     self.assertEqual(parser.ast, expected_ast)