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


Python Interpreter.run方法代码示例

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


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

示例1: test_one

# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
 def test_one(self,benchmark):
     
     n=1
     while(n<100):
         i = Interpreter()
         f = open('input.bas', 'r')
         for line in f:   
             line = line.strip()
             split_line = line.split(" ")
             line_number = int(split_line[0])
             i.add_line(line_number, split_line[1:])
         i.run()
         f.close()
         n=n+1
     benchmark(time.sleep, 0.000001)
开发者ID:pranay-91,项目名称:kivyApp,代码行数:17,代码来源:TestClass.py

示例2: entry_point

# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
def entry_point(argv):
	filename = argv[1]
	args = []
	args.append( filename )
	for i in xrange(len(argv)):
		if i > 1:
			args.append( argv[i] )

	interp = Interpreter( filename=filename, argv=args )
	rv = interp.run()

	return rv
开发者ID:terrence2,项目名称:befunge2010,代码行数:14,代码来源:targetbefunge.py

示例3: run_app

# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
    def run_app(self, instance):
        i = Interpreter()
        line_number = 1
        for cmd in self.command_stack:
            line = cmd.get_command()
            i.add_line(line_number, line)
            line_number = line_number + 1

        i.run()
        output = i.get_output()
        variables = i.get_variables()

        self.comment.text = ""
        self.comment.insert_text('\n Output : \n')
        for value in output:
            self.comment.insert_text(' ' + str(value)+ '\n')

        self.comment.insert_text('\n Memory: \n')
        self.comment.insert_text(' Variable \t Value \n')
        for var in variables.keys():
            value = ' \t' + var + ' \t\t\t ' + str(variables[var]) + '\n'
            self.comment.insert_text(' ' + str(value))
开发者ID:pranay-91,项目名称:kivyApp,代码行数:24,代码来源:KivyApp.py

示例4: runtest

# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
def runtest( filename ):
	print "File: %s -> " % os.path.basename(filename),

	# get program contents
	f = open_file_as_stream(filename)
	program = f.readall()
	f.close()
	
	# expect?
	expect_rv = 0
	expect_stack = []
	expect_space = []
	expect_stdout = ''
	
	# look for special tags in out
	for ln in program.split('\n'):
		if ln.startswith( 'Return:' ):
			expect_rv = int(ln.split(' ')[-1])
		elif ln.startswith( 'Stack:' ):
			expect_stack = [Cell(int(v)) for v in ln.split(' ')[1:]]
		elif ln.startswith( 'Space:' ):
			parts = ln.split(' ')[1:]
			expect_space.append( (int(parts[0]),int(parts[1]),Cell(int(parts[2]))) )
		elif ln.startswith( 'Stdout:' ):
			expect_stdout = ln[7:].strip()

	# run the interpreter on the file
	cap = py.io.StdCaptureFD()
	i = Interpreter( filename=filename, argv=['testrunner'] )
	rv = i.run()
	fds = cap.done()
	actual_stdout = fds[0].read().strip()
	
	# check results
	#print "E: %s" % str(expect_stack)
	#print "A: %s" % str(i.stacks.head().inner)
	try:
		assert rv == expect_rv
		for v in expect_stack:
			assert 0 == v.cmp_( i.stacks.pop() )
		for x,y,val in expect_space:
			assert 0 == val.cmp_( i.space.get( x, y ) )
		assert expect_stdout == actual_stdout
	except:
		print ""
		print "RV: %s" % rv
		print str(i.stacks)
		raise
开发者ID:terrence2,项目名称:befunge2010,代码行数:50,代码来源:test_python_runner.py

示例5: Interpreter

# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
from Interpreter.Interpreter import *

if __name__ == '__main__':
    interpret = Interpreter()
    interpret.run()
开发者ID:Ashrak22,项目名称:lang_interpreter,代码行数:7,代码来源:main.py

示例6: open_file_as_stream

# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
#!/usr/bin/python
# encoding: utf-8
#import autopath
import sys
import getopt

from pypy.rlib.streamio import open_file_as_stream

from Interpreter import Interpreter

f = open_file_as_stream(sys.argv[1])
program = f.readall()
f.close()

interp = Interpreter( program=program, argv=sys.argv[1:] )
rv = interp.run()

print interp.stacks

sys.exit( rv )
开发者ID:terrence2,项目名称:befunge2010,代码行数:22,代码来源:befunge.py


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