本文整理汇总了Python中pynes.compiler.semantic函数的典型用法代码示例。如果您正苦于以下问题:Python semantic函数的具体用法?Python semantic怎么用?Python semantic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了semantic函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:9,代码来源:rts_test.py
示例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])
开发者ID:BmanisKing,项目名称:Mine,代码行数:9,代码来源:sei_test.py
示例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)
开发者ID:acs022,项目名称:pyNES,代码行数:9,代码来源:directive_test.py
示例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])
开发者ID:BmanisKing,项目名称:Mine,代码行数:9,代码来源:sed_test.py
示例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)
开发者ID:acs022,项目名称:pyNES,代码行数:9,代码来源:directive_test.py
示例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)
开发者ID:gabriel-ozeas,项目名称:pyNES,代码行数:9,代码来源:scrolling_test.py
示例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])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:10,代码来源:bne_test.py
示例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])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:10,代码来源:lsr_test.py
示例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])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:10,代码来源:lsr_test.py
示例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])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:10,代码来源:lsr_test.py
示例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])
开发者ID:BmanisKing,项目名称:Mine,代码行数:10,代码来源:lsr_test.py
示例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])
开发者ID:acs022,项目名称:pyNES,代码行数:10,代码来源:bpl_test.py
示例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])
开发者ID:ebennaga,项目名称:pyNES,代码行数:10,代码来源:ldy_test.py
示例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])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:10,代码来源:sbc_test.py
示例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])
开发者ID:BmanisKing,项目名称:Mine,代码行数:10,代码来源:cmp_test.py
示例16: test_sty_zp
def test_sty_zp(self):
tokens = list(lexical('STY $00'))
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_ZEROPAGE', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0x84, 0x00])
开发者ID:ebennaga,项目名称:pyNES,代码行数:10,代码来源:sty_test.py
示例17: test_ldy_abs
def test_ldy_abs(self):
tokens = list(lexical('LDY $1234'))
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_ABSOLUTE', ast[0]['type'])
code = semantic(ast)
self.assertEquals(code, [0xac, 0x34, 0x12])
开发者ID:ebennaga,项目名称:pyNES,代码行数:10,代码来源:ldy_test.py
示例18: test_ldy_imm_with_binary
def test_ldy_imm_with_binary(self):
tokens = list(lexical('LDY #%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, [0xa0, 0x04])
开发者ID:ebennaga,项目名称:pyNES,代码行数:10,代码来源:ldy_test.py
示例19: test_bit_zp
def test_bit_zp(self):
tokens = lexical("BIT $00")
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_ZEROPAGE", ast[0]["type"])
code = semantic(ast)
self.assertEquals(code, [0x24, 0x00])
开发者ID:ickybodclay,项目名称:pyNES,代码行数:10,代码来源:bit_test.py
示例20: test_inesmir
def test_inesmir(self):
tokens = list(lexical('.inesmir 1'))
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, True)
# self.assertEquals(1, get_var('inesmir'))
self.assertEquals(code[7], 1)
开发者ID:BmanisKing,项目名称:Mine,代码行数:11,代码来源:directive_test.py
注:本文中的pynes.compiler.semantic函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论