Пример #1
0
 def test_raise_unknown_token(self):
     tokens = analyse('ONE *unknown', asm_test_tokens)
     self.assertIsInstance(tokens, GeneratorType)
     self.assertEquals('T_FAKE_INSTRUCTION', next(tokens)['type'])
     self.assertEquals('T_SOME_SYMBOL', next(tokens)['type'])
     with self.assertRaises(UnknownToken):
         next(tokens)  # unknown
Пример #2
0
 def test_raise_unknown_token(self):
     tokens = analyse('ONE *unknown', asm_test_tokens)
     self.assertIsInstance(tokens, GeneratorType)
     self.assertEquals('T_FAKE_INSTRUCTION', next(tokens)['type'])
     self.assertEquals('T_SOME_SYMBOL', next(tokens)['type'])
     with self.assertRaises(UnknownToken):
         next(tokens) # unknown
Пример #3
0
 def test_unknown_token_message(self):
     tokens = analyse(';test\n  @--Case \n;TUTEM acronym test',
                      asm_test_tokens)
     self.assertIsInstance(tokens, GeneratorType)
     try:
         list(tokens)
     except UnknownToken as ut:
         self.assertEquals(2, ut.line)
         self.assertEquals(3, ut.column)
         self.assertEquals('  @--Case \n', ut.line_code) # W/ trail wspaces
         self.assertEquals('Unknown token @(2,3):   @--Case', ut.message)
     else:
         self.fail("UnkownToken not raised")
Пример #4
0
 def test_unknown_token_message(self):
     tokens = analyse(';test\n  @--Case \n;TUTEM acronym test',
                      asm_test_tokens)
     self.assertIsInstance(tokens, GeneratorType)
     try:
         list(tokens)
     except UnknownToken as ut:
         self.assertEquals(2, ut.line)
         self.assertEquals(3, ut.column)
         self.assertEquals('  @--Case \n', ut.line_code)  # W/ trail wspaces
         self.assertEquals('Unknown token @(2,3):   @--Case', ut.message)
     else:
         self.fail("UnkownToken not raised")
Пример #5
0
 def test_empty_inputs(self):
     tokens = analyse('', [])
     with self.assertRaises(StopIteration):
         next(tokens) # unknown
Пример #6
0
 def test_empty_token_types_list(self):
     tokens = analyse('something', [])
     with self.assertRaises(UnknownToken):
         next(tokens) # unknown
Пример #7
0
def lexical(code):
    return analyse(code, asm65_tokens)  # A generator
Пример #8
0
 def test_empty_inputs(self):
     tokens = analyse('', [])
     with self.assertRaises(StopIteration):
         next(tokens)  # unknown
Пример #9
0
 def test_empty_token_types_list(self):
     tokens = analyse('something', [])
     with self.assertRaises(UnknownToken):
         next(tokens)  # unknown
Пример #10
0
def lexical(code):
    return analyse(code, asm65_tokens)