示例#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
文件: compiler.py 项目: yxda/pyNES
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)