• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python addressing.AddressParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中py65.utils.addressing.AddressParser的典型用法代码示例。如果您正苦于以下问题:Python AddressParser类的具体用法?Python AddressParser怎么用?Python AddressParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AddressParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_number_bad_label_with_offset

 def test_number_bad_label_with_offset(self):
   parser = AddressParser()
   try:
     parser.number('bad_label+3')
     self.fail()
   except KeyError as why:
     self.assertEqual("'Label not found: bad_label'", str(why))    
开发者ID:dabeaz,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例2: test_number_bad_label_with_offset

 def test_number_bad_label_with_offset(self):
     parser = AddressParser()
     try:
         parser.number("bad_label+3")
         self.fail()
     except KeyError, why:
         self.assertEqual("Label not found: bad_label", why[0])
开发者ID:BigEd,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例3: test_number_bad_label

 def test_number_bad_label(self):
     parser = AddressParser()
     try:
         parser.number('bad_label')
         self.fail()
     except KeyError, why:
         self.assertEqual('Label not found: bad_label', why[0])
开发者ID:andybest,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例4: test_number_bad_label_with_offset

 def test_number_bad_label_with_offset(self):
     parser = AddressParser()
     try:
         parser.number('bad_label+3')
         self.fail()
     except KeyError as exc:
         self.assertEqual('Label not found: bad_label', exc.args[0])
开发者ID:B-Rich,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例5: test_number_label_dec_offset

 def test_number_label_dec_offset(self):
   parser = AddressParser()
   parser.labels = {'foo': 0xC000}
   self.assertEquals(0xC003, parser.number('foo++3'))
   self.assertEquals(0xBFFD, parser.number('foo-+3'))
   self.assertEquals(0xC003, parser.number('foo + +3'))
   self.assertEquals(0xBFFD, parser.number('foo - +3'))
开发者ID:ddribin,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例6: test_number_label_bin_offset

 def test_number_label_bin_offset(self):
   parser = AddressParser()
   parser.labels = {'foo': 0xC000}
   self.assertEqual(0xC003, parser.number('foo+%00000011'))
   self.assertEqual(0xBFFD, parser.number('foo-%00000011'))
   self.assertEqual(0xC003, parser.number('foo + %00000011'))
   self.assertEqual(0xBFFD, parser.number('foo - %00000011'))
开发者ID:dabeaz,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例7: test_number_label_dec_offset

 def test_number_label_dec_offset(self):
     parser = AddressParser()
     parser.labels = {"foo": 0xC000}
     self.assertEqual(0xC003, parser.number("foo++3"))
     self.assertEqual(0xBFFD, parser.number("foo-+3"))
     self.assertEqual(0xC003, parser.number("foo + +3"))
     self.assertEqual(0xBFFD, parser.number("foo - +3"))
开发者ID:BigEd,项目名称:py65,代码行数:7,代码来源:test_addressing.py


示例8: test_number_bad_label_syntax

 def test_number_bad_label_syntax(self):
     parser = AddressParser()
     parser.labels = {'foo': 0xFFFF}
     try:
         parser.number('#$foo')
         self.fail()
     except KeyError as exc:
         self.assertEqual('Label not found: #$foo', exc.args[0])
开发者ID:B-Rich,项目名称:py65,代码行数:8,代码来源:test_addressing.py


示例9: test_number_label_offset_default_radix

 def test_number_label_offset_default_radix(self):
   parser = AddressParser()
   parser.labels = {'foo': 0xC000}
   parser.radix = 16
   self.assertEqual(0xC010, parser.number('foo+10'))
   self.assertEqual(0xBFF0, parser.number('foo-10'))
   self.assertEqual(0xC010, parser.number('foo + 10'))
   self.assertEqual(0xBFF0, parser.number('foo - 10'))    
   parser.radix = 10
   self.assertEqual(0xC00A, parser.number('foo+10'))
   self.assertEqual(0xBFF6, parser.number('foo-10'))
   self.assertEqual(0xC00A, parser.number('foo + 10'))
   self.assertEqual(0xBFF6, parser.number('foo - 10'))    
开发者ID:dabeaz,项目名称:py65,代码行数:13,代码来源:test_addressing.py


示例10: test_number_bin_literal

 def test_number_bin_literal(self):
   parser = AddressParser()
   self.assertEqual(129, parser.number('%10000001'))
开发者ID:dabeaz,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例11: test_number_dec_literal

 def test_number_dec_literal(self):
   parser = AddressParser()
   self.assertEqual(49152, parser.number('+49152'))
开发者ID:dabeaz,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例12: test_number_hex_literal

 def test_number_hex_literal(self):
   parser = AddressParser()
   self.assertEqual(49152, parser.number('$c000'))
开发者ID:dabeaz,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例13: test_maxwidth_setter

 def test_maxwidth_setter(self):
   parser = AddressParser()
   parser.maxwidth = 24
   self.assertEqual(24, parser.maxwidth)
   self.assertEqual(0xFFFFFF, parser._maxaddr)       
开发者ID:dabeaz,项目名称:py65,代码行数:5,代码来源:test_addressing.py


示例14: test_label_for_returns_alternate_default

 def test_label_for_returns_alternate_default(self):
   parser = AddressParser(labels={})
   self.assertEqual('foo', parser.label_for(0xFFD2, 'foo'))
开发者ID:dabeaz,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例15: test_number_constrains_address_at_maxwidth_24

 def test_number_constrains_address_at_maxwidth_24(self):
     parser = AddressParser()
     parser.maxwidth = 24
     parser.labels = {'foo': 0xFFFFFF}
     self.assertRaises(OverflowError, parser.number, 'foo+5')
开发者ID:B-Rich,项目名称:py65,代码行数:5,代码来源:test_addressing.py


示例16: test_adderss_for_returns_alternate_default

 def test_adderss_for_returns_alternate_default(self):
     parser = AddressParser(labels={})
     self.assertEqual('foo', parser.address_for('chrout', 'foo'))
开发者ID:McNeight,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例17: Monitor

class Monitor(cmd.Cmd):

    def __init__(self, mpu_type=NMOS6502, completekey='tab', stdin=None, stdout=None):
        self._reset(mpu_type)
        self._width = 78
        self._update_prompt()
        self._add_shortcuts()
        cmd.Cmd.__init__(self, completekey, stdin, stdout)

    def onecmd(self, line):
        line = self._preprocess_line(line)
        
        result = None
        try:
            result = cmd.Cmd.onecmd(self, line)
        except KeyboardInterrupt:
            self._output("Interrupt")
        except Exception as e:
            (file, fun, line), t, v, tbinfo = compact_traceback()
            error = 'Error: %s, %s: file: %s line: %s' % (t, v, file, line)
            self._output(error)

        self._update_prompt()
        return result

    def _reset(self, mpu_type):
        self._mpu = mpu_type()
        self._install_mpu_observers()
        self._address_parser = AddressParser()
        self._disassembler = Disassembler(self._mpu, self._address_parser)
        self._assembler = Assembler(self._mpu, self._address_parser)

    def _add_shortcuts(self):
        self._shortcuts = {'~':   'tilde',
                           '?':   'help',
                           'a':   'assemble',
                           'al':  'add_label',
                           'd':   'disassemble',
                           'dl':  'delete_label',
                           'f':   'fill',
                           '>':   'fill',
                           'g':   'goto',
                           'l':   'load',
                           'm':   'mem',
                           'r':   'registers',
                           'ret': 'return',
                           'rad': 'radix',
                           's':   'save',
                           'shl': 'show_labels',
                           'x':   'quit',
                           'z':   'step'}

    def _preprocess_line(self, line):
        # line comments
        quoted = False
        for pos, char in enumerate(line):
            if char in ('"', "'"):
                quoted = not quoted
            if (not quoted) and (char == ';'):
                line = line[:pos]
                break

        # whitespace & leading dots
        line = line.strip(' \t').lstrip('.')

        # special case for vice compatibility
        if line.startswith('~'):
          line = self._shortcuts['~'] + ' ' + line[1:]
      
        # command shortcuts
        for shortcut, command in self._shortcuts.items():
            if line == shortcut:
                line = command
                break

            pattern = '^%s\s+' % re.escape(shortcut)
            matches = re.match(pattern, line)
            if matches:
                start, end = matches.span()
                line = "%s %s" % (command, line[end:])
                break

        return line

    def _install_mpu_observers(self):
        def putc(address, value):
            self.stdout.write(chr(value))
            self.stdout.flush()

        def getc(address):
            char = console.getch_noblock(self.stdin)
            if char:
                byte = ord(char)
            else:
                byte = 0
            return byte

        m = ObservableMemory()
        #m.subscribe_to_write([0xF001], putc)
        #m.subscribe_to_read([0xF004], getc)
#.........这里部分代码省略.........
开发者ID:dabeaz,项目名称:py65,代码行数:101,代码来源:monitor.py


示例18: test_range_two_numbers

 def test_range_two_numbers(self):
     parser = AddressParser(labels={})
     self.assertEqual((0xFFD2, 0xFFD4), parser.range('ffd2:ffd4'))
开发者ID:B-Rich,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例19: test_range_one_label

 def test_range_one_label(self):
     parser = AddressParser(labels={'chrout':0xFFD2})
     self.assertEqual((0xFFD2, 0xFFD2), parser.range('chrout'))
开发者ID:B-Rich,项目名称:py65,代码行数:3,代码来源:test_addressing.py


示例20: test_range_one_number

 def test_range_one_number(self):
     parser = AddressParser(labels={})
     self.assertEqual((0xFFD2, 0xFFD2), parser.range('ffd2'))
开发者ID:B-Rich,项目名称:py65,代码行数:3,代码来源:test_addressing.py



注:本文中的py65.utils.addressing.AddressParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyBigWig.open函数代码示例发布时间:2022-05-27
下一篇:
Python monitor.Monitor类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap