本文整理汇总了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)
示例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
示例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))
示例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
示例5: Interpreter
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import run [as 别名]
from Interpreter.Interpreter import *
if __name__ == '__main__':
interpret = Interpreter()
interpret.run()
示例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 )