Implemented FunctionParser
This commit is contained in:
@@ -40,6 +40,7 @@ class Expando:
|
||||
def __repr__(self):
|
||||
return f"{dir(self)}"
|
||||
|
||||
|
||||
@dataclass
|
||||
class PythonEvalError:
|
||||
error: Exception
|
||||
@@ -59,13 +60,19 @@ class PythonEvaluator(OneReturnValueEvaluator):
|
||||
self.globals = {}
|
||||
|
||||
def matches(self, context, return_value):
|
||||
return return_value.status and \
|
||||
isinstance(return_value.value, ParserResultConcept) and \
|
||||
isinstance(return_value.value.value, PythonNode)
|
||||
if not return_value.status or not isinstance(return_value.value, ParserResultConcept):
|
||||
return False
|
||||
body = return_value.value.value
|
||||
return isinstance(body, PythonNode) or (
|
||||
hasattr(body, "python_node") and isinstance(body.python_node, PythonNode))
|
||||
# return return_value.status and \
|
||||
# isinstance(return_value.value, ParserResultConcept) and \
|
||||
# isinstance(return_value.value.value, PythonNode)
|
||||
|
||||
def eval(self, context, return_value):
|
||||
sheerka = context.sheerka
|
||||
node = return_value.value.value
|
||||
node = return_value.value.value if isinstance(return_value.value.value, PythonNode) else \
|
||||
return_value.value.value.python_node
|
||||
|
||||
context.log(f"Evaluating python node {node}.", self.name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user