Пример #1
0
	def __call__(self):
		try:
			return self._result
		except AttributeError:
			self._result = evaluate(self.expr, self.env)
			del self.expr
			del self.env
			return self._result
Пример #2
0
	def feed(self, instr, verbose=True):
		try:
			if isinstance(instr, assignment):
				self.env[instr.name] = closure(instr.value, self.env)
			else:
				result = evaluate(instr, self.env)
				if verbose: print result
				else: return result
		except (TypeError, RuntimeError, ArithmeticError) as e:
			raise ForvelkiError(e.args[0])