예제 #1
0
 def test_attribute_reference(self):
     code = ".speed \0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(
         True,
         self.parser.try_parse_attribute_reference(env.Identifier("a"),
                                                   False))
예제 #2
0
 def try_parse_identifier(self):
     if self.current_token.token_type == tokens.TokenType.t_identifier:
         self.class_stack.append(env.Identifier(self.current_token.value))
         self.consume_token()
         return True
     return False
예제 #3
0
 def test_method_call(self):
     code = ".run(a, b, c, d)\0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(
         True, self.parser.try_parse_method_call(env.Identifier("a")))
예제 #4
0
 def test_function_call(self):
     code = "(a, b, c, d);\0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(
         True, self.parser.try_parse_function_call(env.Identifier("a")))
예제 #5
0
 def test_attribute(self):
     code = "{get; set} = \'abcde\'; \0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(True,
                      self.parser.try_parse_attribute(env.Identifier("a")))
예제 #6
0
 def test_object(self):
     code = " extends Vehicle { a= None; b = 10; } \0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(True,
                      self.parser.try_parse_object(env.Identifier("a")))
예제 #7
0
 def test_assignment(self):
     code = "= 5 + 3 * 2 + ( 7 * 9 ) \0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(True,
                      self.parser.try_parse_assignment(env.Identifier("a")))
예제 #8
0
 def test_function(self):
     code = "(){ a = 5; out<<a; } \0"
     self.manage_source(code)
     self.parser.consume_token()
     self.assertEqual(
         True, self.parser.try_parse_function(env.Identifier("main")))