当前位置: 首页>>代码示例>>Python>>正文


Python Interpreter.Interpreter类代码示例

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


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

示例1: install_builtins

 def install_builtins(self):
     """ populate with the builtin functions, while adding our own flavors"""
     Interpreter.install_builtins(self)
     
     #input statements, length constructs
     tamil_equiv = {"சரம்_இடமாற்று":"replace", "சரம்_கண்டுபிடி":"find","நீளம்":"len",
                    "சரம்_உள்ளீடு":"raw_input", "உள்ளீடு" : "input" }
     #list operators        
     tamil_equiv.update( {"பட்டியல்":"list","பின்இணை":"append","தலைகீழ்":"reverse",
                          "வரிசைப்படுத்து":"sort","நீட்டிக்க":"extend","நுழைக்க":"insert","குறியீட்டெண்":"index",
                          "வெளியேஎடு":"pop","பொருந்தியஎண்":"count", "எடு":"__getitem__"} )
     
     #file operators
     tamil_equiv.update({"கோப்பை_திற":"file_open", "கோப்பை_மூடு":"file_close","கோப்பை_படி":"file_read",
                         "கோப்பை_எழுது":"file_write","கோப்பை_எழுது_வரிகள்":"file_writelines","கோப்பை_படி_வரிகள்":"file_readlines"})
     
     for k,v in list(tamil_equiv.items()):
         self.builtin_map[k]=self.builtin_map[v];
     
     # translations for turtle module
     turtle_map = { "முன்னாடி":"forward", "பின்னாடி" :"backward",
                    "வலது":"lt", "இடது":"rt",
                    "எழுதுகோல்மேலே":"penup",  "எழுதுகோல்கிழே":"pendown"}
     for k,v in list(turtle_map.items()):
         vv = "turtle_"+v;
         self.builtin_map[k] = self.builtin_map[vv]
     
     return
开发者ID:nchokkan,项目名称:Ezhil-Lang,代码行数:28,代码来源:ezhil.py

示例2: parse

 def parse(self):
     instructions = self._program()
     # do not print any output if error occurs
     if self.total_error_flag == 0:
         if self.print_symbol_table == 0:
             self.observer.print_output()
         elif self.print_symbol_table == 1:
             self.visitor.visitScope(self.program_scope)
             self.visitor.end()
         elif self.print_symbol_table == 2:
             currinstruction = instructions
             self.visitor.start()
             # while(currinstruction is not None):
             currinstruction.visit(self.visitor)
             # currinstruction = currinstruction._next
         elif self.print_symbol_table == 3:
             environment = self.program_scope.make_environment()
             stack = []
             currinstruction = instructions
             # while curr is not None:
             #    self.interpret(curr, environment, stack)
             #    curr = curr._next
             # v = InterpreterVisitor(environment)
             # v.start()
             # currinstruction.int_visit(v)
             v = Interpreter(currinstruction, environment)
             v.start()
开发者ID:dalapat,项目名称:assignments,代码行数:27,代码来源:Parser.py

示例3: test_should_ignore_invalid_ram_value

    def test_should_ignore_invalid_ram_value(self):
        interpreter = Interpreter(['', None, 'Some non Int', '1000'])

        self.assertEqual('000', interpreter.get_ram_value(0))
        self.assertEqual('000', interpreter.get_ram_value(1))
        self.assertEqual('000', interpreter.get_ram_value(2))
        self.assertEqual('000', interpreter.get_ram_value(3))
开发者ID:linus123,项目名称:PythonPractice,代码行数:7,代码来源:InterpreterTests.py

示例4: test_0ds_should_not_go_to_location_d_when_s_is_zero

    def test_0ds_should_not_go_to_location_d_when_s_is_zero(self):
        interpreter = Interpreter(['200', '214', '010', '201', '100'])

        instruction_count = interpreter.execute()

        self.assertEqual('001', interpreter.get_register_value(0))
        self.assertEqual(5, instruction_count)
开发者ID:linus123,项目名称:PythonPractice,代码行数:7,代码来源:InterpreterTests.py

示例5: test_should_set_ram_given_value

    def test_should_set_ram_given_value(self):
        interpreter = Interpreter(['100'])

        self.assertEqual('100', interpreter.get_ram_value(0))

        for index in range(1, 1000) :
            self.assertEqual('000', interpreter.get_ram_value(index))
开发者ID:linus123,项目名称:PythonPractice,代码行数:7,代码来源:InterpreterTests.py

示例6: __init__

 def __init__(self, **kwargs ):
     """ create a Ezhil Interpeter and initialize runtime builtins etc.. in a RAII fashion,
         and associates a Ezhil parser object with this class
     """
     Interpreter.__init__(self,**kwargs)
     Interpreter.change_parser(self,EzhilParser.factory)
     return
开发者ID:digital-carver,项目名称:Ezhil-Lang,代码行数:7,代码来源:ezhil.py

示例7: test_9sa_set_the_value_in_ram

    def test_9sa_set_the_value_in_ram(self):
        interpreter = Interpreter(['209', '215', '901', '100'])

        instruction_count = interpreter.execute()

        self.assertEqual('009', interpreter.get_ram_value(5))
        self.assertEqual(4, instruction_count)
开发者ID:linus123,项目名称:PythonPractice,代码行数:7,代码来源:InterpreterTests.py

示例8: assign

    def assign(self, interpreter_flag=False):
        Interpreter.interpreter_flag = interpreter_flag

        sc = self.scanner
        lexeme_identifier = sc.next_lexeme()

        if Interpreter.interpreter_flag:
            # semantic
            if not self.semantic_tree.is_describe_var_early(sc.get_pointer_line(), sc.get_pointer_position(), sc.lexeme):
                raise SemanticExceptionUndescribeVar(sc.get_pointer_line(), sc.get_pointer_position(), sc.lexeme)
            # semantic

        if Interpreter.interpreter_flag:
            # Interpreter
            node = self.semantic_tree.get_variable_node(sc.lexeme)
            # Interpreter

        sc.next_lexeme()  # =

        value_obj = ValueObj()
        self.expression(value_obj, interpreter_flag=Interpreter.interpreter_flag)

        if Interpreter.interpreter_flag:
            # Interpreter
            Interpreter.to_type(value_obj, node.type_data)
            node.value = value_obj.value
开发者ID:nikialeksey,项目名称:SyntaxAnalis,代码行数:26,代码来源:DescendingAnalyse.py

示例9: testInterpreter3

def testInterpreter3():

 te.checkComplainAndAdjustExpected( 0)

 i= Interpreter()
 i.evalToken( s( '(')) # baustelle: testbarkeit der repl
 
 te.checkComplainAndAdjustExpected( 0)
开发者ID:schwidom,项目名称:pl-lisp,代码行数:8,代码来源:testInterpreter.py

示例10: test_5ds_should_set_register_d_to_the_value_of_register_s

    def test_5ds_should_set_register_d_to_the_value_of_register_s(self):
        interpreter = Interpreter(['209', '510', '100'])

        instruction_count = interpreter.execute()

        self.assertEqual('009', interpreter.get_register_value(0))
        self.assertEqual('009', interpreter.get_register_value(1))
        self.assertEqual(3, instruction_count)
开发者ID:linus123,项目名称:PythonPractice,代码行数:8,代码来源:InterpreterTests.py

示例11: test_8da_should_set_register_d_to_the_value_in_ram_whose_address_is_in_register_a

    def test_8da_should_set_register_d_to_the_value_in_ram_whose_address_is_in_register_a(self):
        interpreter = Interpreter(['203', '810', '100', '999'])

        instruction_count = interpreter.execute()

        self.assertEqual('003', interpreter.get_register_value(0))
        self.assertEqual('999', interpreter.get_register_value(1))
        self.assertEqual(3, instruction_count)
开发者ID:linus123,项目名称:PythonPractice,代码行数:8,代码来源:InterpreterTests.py

示例12: test_7ds_should_multiply_register_d_to_the_value_of_register_s

    def test_7ds_should_multiply_register_d_to_the_value_of_register_s(self):
        interpreter = Interpreter(['209', '212', '710', '100'])

        instruction_count = interpreter.execute()

        self.assertEqual('009', interpreter.get_register_value(0))
        self.assertEqual('018', interpreter.get_register_value(1))
        self.assertEqual(4, instruction_count)
开发者ID:linus123,项目名称:PythonPractice,代码行数:8,代码来源:InterpreterTests.py

示例13: main

def main(args):
	input = FileStream(args[1])
	lexer = MiniPLexer(input)
	stream = CommonTokenStream(lexer)
	parser = MiniPParser(stream)
	tree = parser.program()

	interpreter = Interpreter()
	interpreter.visit(tree)
开发者ID:MaltesIndividualUsername,项目名称:VirtualMachine,代码行数:9,代码来源:Tool.py

示例14: makeOverridenInterpreter

def makeOverridenInterpreter():

 ios= InterpreterOverridings()
 i= Interpreter()

 i.readTokenRawInput= ios.readTokenRawInput
 i.essentials_macro_function.ess_print= ios.ess_ess_print # 8c231655685648cc99e5b0bf3b0b8687
 i.s_print= ios.s_print

 return ( ios, i)
开发者ID:schwidom,项目名称:pl-lisp,代码行数:10,代码来源:testRepl.py

示例15: __init__

class InterpreterVisitor:

    def __init__(self, environment):
        self.environment = environment
        self.interpreter = Interpreter()

    def visitNode(self, ast):
        self.interpreter.interpret(ast, self.environment)
        if ast._next is not None:
            ast._next.int_visit(self)
开发者ID:dalapat,项目名称:assignments,代码行数:10,代码来源:InterpreterVisitor.py


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