本文整理汇总了Python中interpreter.Interpreter.run方法的典型用法代码示例。如果您正苦于以下问题:Python Interpreter.run方法的具体用法?Python Interpreter.run怎么用?Python Interpreter.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interpreter.Interpreter
的用法示例。
在下文中一共展示了Interpreter.run方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_task
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import run [as 别名]
def create_task(self):
interpreter = Interpreter(self.get_content()['data'])
interpreter.run()
task = Task(based_on_exercise=self.eid,
part_of_match=None,
part_of_sheet=None)
task.set_content(interpreter.globs)
db.session.add(task)
db.session.commit()
return task
示例2: main
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import run [as 别名]
def main():
while True:
try:
text = raw_input('bf> ')
except EOFError:
break
if not text:
continue
if text == "exit":
print("Exiting...")
sys.exit(0);
interpreter = Interpreter(text)
result = interpreter.run()
print(result)
示例3: print
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import run [as 别名]
mem = interp.memory
# allocate ndarray structure
# offset 0: dummy
# offset 16: data pointer
# offset 24: shape pointer
# size 32 bytes
ary_struct_ptr = mem.allocate(32)
print(hex(ary_struct_ptr))
ary_struct_i64 = mem.get_buffer(ary_struct_ptr, astype=np.uint64)
arysize = 10
ary_struct_i64[2] = dataptr = mem.allocate(
arysize * np.dtype('int32').itemsize)
ary_struct_i64[3] = arysize
data = mem.get_buffer(dataptr, astype=np.uint32)
data[:] = np.arange(arysize) + 1
frozen_data = data.copy()
print('data', data)
# run foo
result = interp.run("$foo", args=[np.int64(ary_struct_ptr)])
expect = frozen_data.sum()
print('result', result)
assert expect == result
assert np.all(frozen_data == data)
示例4: len
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import run [as 别名]
if sys.version_info[0] >= 3:
raw_input = input
if len(sys.argv) == 2:
data = open(sys.argv[1]).read()
try:
prog = parser.parse(data)
except SyntaxError as se:
print 'Parse Error: {0}'.format(se)
if not prog:
raise SystemExit
inter = Interpreter(parser.current_scope)
try:
inter.run(prog)
raise SystemExit
except RuntimeError as re:
print 'Error: {0}'.format(re)
raise SystemExit
else:
inter = Interpreter(parser.current_scope)
def execute_command(name):
if name == 'load':
print 'To be implemented'
elif name == 'resources':
inter.show_resources()
elif name == 'quit' or name == 'exit' or name == 'q':
raise SystemExit