本文整理汇总了Python中pynes.compiler.semantic函数的典型用法代码示例。如果您正苦于以下问题:Python semantic函数的具体用法?Python semantic怎么用?Python semantic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了semantic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rts_sngl
def test_rts_sngl(self):
tokens = lexical("RTS")
self.assertEquals(1, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_IMPLIED", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0x60])
示例2: test_sei_sngl
def test_sei_sngl(self):
tokens = list(lexical("SEI"))
self.assertEquals(1, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_IMPLIED", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0x78])
示例3: test_bank_0
def test_bank_0(self):
tokens = lexical('.bank 0')
self.assertEquals(2 , len(tokens))
self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
self.assertEquals('T_DECIMAL_ARGUMENT', tokens[1]['type'])
ast = syntax(tokens)
self.assertEquals(1 , len(ast))
self.assertEquals('S_DIRECTIVE', ast[0]['type'])
code = semantic(ast)
示例4: test_sed_sngl
def test_sed_sngl(self):
tokens = list(lexical('SED'))
self.assertEquals(1, len(tokens))
self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals('S_IMPLIED', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0xf8])
示例5: test_org_fffa
def test_org_fffa(self):
tokens = lexical('.org $FFFA')
self.assertEquals(2 , len(tokens))
self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
self.assertEquals('T_ADDRESS', tokens[1]['type'])
ast = syntax(tokens)
self.assertEquals(1 , len(ast))
self.assertEquals('S_DIRECTIVE', ast[0]['type'])
code = semantic(ast)
示例6: test_asm_compiler_scrolling_5
def test_asm_compiler_scrolling_5(self):
cart = Cartridge()
cart.path = "fixtures/nesasm/scrolling/"
f = open("fixtures/nesasm/scrolling/scrolling5.asm")
code = f.read()
f.close()
tokens = lexical(code)
ast = syntax(tokens)
opcodes = semantic(ast, cart=cart)
示例7: test_bne_rel
def test_bne_rel(self):
tokens = lexical("BNE $10")
self.assertEquals(2, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
self.assertEquals("T_ADDRESS", tokens[1]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_RELATIVE", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0xD0, 0x0E])
示例8: test_lsr_imm_with_binary
def test_lsr_imm_with_binary(self):
tokens = lexical("LSR #%00000100")
self.assertEquals(2, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
self.assertEquals("T_BINARY_NUMBER", tokens[1]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_IMMEDIATE", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0x4A, 0x04])
示例9: test_lsr_imm_with_decimal
def test_lsr_imm_with_decimal(self):
tokens = lexical("LSR #10")
self.assertEquals(2, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
self.assertEquals("T_DECIMAL_NUMBER", tokens[1]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_IMMEDIATE", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0x4A, 0x0A])
示例10: test_lsr_acc
def test_lsr_acc(self):
tokens = lexical("LSR A")
self.assertEquals(2, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
self.assertEquals("T_ACCUMULATOR", tokens[1]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_ACCUMULATOR", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0x4A])
示例11: test_lsr_acc
def test_lsr_acc(self):
tokens = list(lexical('LSR A'))
self.assertEquals(2, len(tokens))
self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
self.assertEquals('T_ACCUMULATOR', tokens[1]['type'])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals('S_ACCUMULATOR', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0x4a])
示例12: test_bpl_rel
def test_bpl_rel(self):
tokens = lexical('BPL $10')
self.assertEquals(2 , len(tokens))
self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
self.assertEquals('T_ADDRESS', tokens[1]['type'])
ast = syntax(tokens)
self.assertEquals(1 , len(ast))
self.assertEquals('S_RELATIVE', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0x10, 0x0e])
示例13: test_ldy_imm_with_decimal
def test_ldy_imm_with_decimal(self):
tokens = list(lexical('LDY #10'))
self.assertEquals(2 , len(tokens))
self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
self.assertEquals('T_DECIMAL_NUMBER', tokens[1]['type'])
ast = syntax(tokens)
self.assertEquals(1 , len(ast))
self.assertEquals('S_IMMEDIATE', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0xa0, 0x0a])
示例14: test_sbc_imm
def test_sbc_imm(self):
tokens = lexical("SBC #$10")
self.assertEquals(2, len(tokens))
self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
self.assertEquals("T_HEX_NUMBER", tokens[1]["type"])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals("S_IMMEDIATE", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0xE9, 0x10])
示例15: test_cmp_imm
def test_cmp_imm(self):
tokens = list(lexical('CMP #$10'))
self.assertEquals(2, len(tokens))
self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
self.assertEquals('T_HEX_NUMBER', tokens[1]['type'])
ast = syntax(tokens)
self.assertEquals(1, len(ast))
self.assertEquals('S_IMMEDIATE', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0xc9, 0x10])