本文整理汇总了Python中Interpreter.Interpreter.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python Interpreter.evaluate方法的具体用法?Python Interpreter.evaluate怎么用?Python Interpreter.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interpreter.Interpreter
的用法示例。
在下文中一共展示了Interpreter.evaluate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Lex
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
# don't care about encoding right now
if ( dostdin ):
## interactive interpreter
lexer = Lex( )
parse_eval = Interpreter( lexer, debug, safe_mode,update,stacksize )
REPL( lang, lexer, parse_eval, debug )
else:
## evaluate a files sequentially
exitcode = 0
for files in fname:
## evaluate a file
lexer = Lex(files)
if ( debug ): lexer.dump_tokens()
parse_eval = Interpreter( lexer, debug, safe_mode, update, stacksize )
try:
parse_eval.parse()
except Exception as e:
print(u"parsing the code '%s' failed with exception:\n\t %s"%(files,str(e)))
if ( debug ): print("*"*60); print(str(parse_eval))
exitcode = 255
try:
env = parse_eval.evaluate()
except Exception as e:
print(u"evaluating the code '%s' failed with exception:\n\t %s"%(files,str(e)))
if debug: print("*"*60); print(str(e))
exitcode = 255
sys.exit(exitcode)
pass
示例2: test_AddOnly1
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_AddOnly1(self):
interpreter = Interpreter("1+2+3+4")
result = interpreter.evaluate()
self.assertEqual(10, result)
示例3: test_EdgeCase2
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_EdgeCase2(self):
interpreter = Interpreter(" 100 ")
result = interpreter.evaluate()
self.assertEqual(100, result)
示例4: test_SubtractOnly2
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_SubtractOnly2(self):
interpreter = Interpreter("100 - 80 + 5")
result = interpreter.evaluate()
self.assertEqual(25, result)
示例5: test_SubtractOnly3
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_SubtractOnly3(self):
interpreter = Interpreter(" 100 + 5 -3 +1 - 3")
result = interpreter.evaluate()
self.assertEqual(100, result)
示例6: test_SubtractOnly1
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_SubtractOnly1(self):
interpreter = Interpreter("1+2-3+4")
result = interpreter.evaluate()
self.assertEqual(4, result)
示例7: test_SubtractOnly4
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_SubtractOnly4(self):
interpreter = Interpreter(" 9999 - 10 ")
result = interpreter.evaluate()
self.assertEqual(9989, result)
示例8: test_AddOnly4
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_AddOnly4(self):
interpreter = Interpreter("11+22")
result = interpreter.evaluate()
self.assertEqual(33, result)
示例9: test_AddOnly3
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_AddOnly3(self):
interpreter = Interpreter(" 100 + 5 +3 ")
result = interpreter.evaluate()
self.assertEqual(108, result)
示例10: test_AddOnly2
# 需要导入模块: from Interpreter import Interpreter [as 别名]
# 或者: from Interpreter.Interpreter import evaluate [as 别名]
def test_AddOnly2(self):
interpreter = Interpreter("21 + 543 + 33")
result = interpreter.evaluate()
self.assertEqual(597, result)