EvalEvaluator is called only if in root context. Added action and action_context to ExecutionContext
This commit is contained in:
@@ -798,7 +798,11 @@ class BaseNodeParser(BaseParser):
|
||||
from parsers.BnfParser import BnfParser
|
||||
regex_parser = BnfParser()
|
||||
desc = f"Resolving BNF {concept.metadata.definition}"
|
||||
with context.push(parser_name, obj=concept, desc=desc) as sub_context:
|
||||
with context.push(BuiltinConcepts.INIT_BNF,
|
||||
concept,
|
||||
who=parser_name,
|
||||
obj=concept,
|
||||
desc=desc) as sub_context:
|
||||
sub_context.add_inputs(parser_input=concept.metadata.definition)
|
||||
bnf_parsing_ret_val = regex_parser.parse(sub_context, concept.metadata.definition)
|
||||
sub_context.add_values(return_values=bnf_parsing_ret_val)
|
||||
|
||||
@@ -845,7 +845,7 @@ class BnfNodeParser(BaseNodeParser):
|
||||
|
||||
expression = concept.bnf
|
||||
desc = f"Resolving parsing expression {expression}"
|
||||
with self.context.push(self.name, obj=concept, desc=desc) as sub_context:
|
||||
with self.context.push(BuiltinConcepts.INIT_BNF, concept, who=self.name, obj=concept, desc=desc) as sub_context:
|
||||
sub_context.add_inputs(expression=expression)
|
||||
resolved = self.resolve_parsing_expression(expression, already_seen or set())
|
||||
sub_context.add_values(return_values=resolved)
|
||||
|
||||
@@ -357,7 +357,11 @@ class DefaultParser(BaseParser):
|
||||
|
||||
regex_parser = BnfParser()
|
||||
desc = f"Resolving BNF {current_concept_def.definition}"
|
||||
with self.context.push(self.name, obj=current_concept_def, desc=desc) as sub_context:
|
||||
with self.context.push(BuiltinConcepts.INIT_BNF,
|
||||
current_concept_def,
|
||||
who=self.name,
|
||||
obj=current_concept_def,
|
||||
desc=desc) as sub_context:
|
||||
parsing_result = regex_parser.parse(sub_context, tokens)
|
||||
sub_context.add_values(return_values=parsing_result)
|
||||
|
||||
@@ -402,7 +406,7 @@ class DefaultParser(BaseParser):
|
||||
continue
|
||||
|
||||
# ask the other parsers if they recognize the tokens
|
||||
with self.context.push(self.name, desc=f"Parsing {keyword}") as sub_context:
|
||||
with self.context.push(BuiltinConcepts.PARSING, keyword, who=self.name, desc=f"Parsing {keyword}") as sub_context:
|
||||
parser_input = self.sheerka.services[SheerkaExecute.NAME].get_parser_input(None, tokens)
|
||||
to_parse = self.sheerka.ret(
|
||||
sub_context.who,
|
||||
|
||||
@@ -133,7 +133,9 @@ class LexerNodeParserHelperForPython:
|
||||
source += node.source
|
||||
to_parse += node.source
|
||||
|
||||
with context.push(self, desc="Trying Python for '" + to_parse + "'") as sub_context:
|
||||
with context.push(BuiltinConcepts.PARSE_CODE,
|
||||
{"language": "Python", "source": to_parse},
|
||||
desc="Trying Python for '" + to_parse + "'") as sub_context:
|
||||
sub_context.add_inputs(to_parse=to_parse)
|
||||
python_parser = PythonParser()
|
||||
parser_input = context.sheerka.services[SheerkaExecute.NAME].get_parser_input(to_parse)
|
||||
|
||||
@@ -77,7 +77,9 @@ class PythonWithConceptsParser(BaseParser):
|
||||
source += node.source
|
||||
to_parse += node.source
|
||||
|
||||
with context.push(self, "Trying Python for '" + to_parse + "'") as sub_context:
|
||||
with context.push(BuiltinConcepts.PARSE_CODE,
|
||||
{"language": "Python", "source": to_parse},
|
||||
"Trying Python for '" + to_parse + "'") as sub_context:
|
||||
parser_input = context.sheerka.services[SheerkaExecute.NAME].get_parser_input(to_parse)
|
||||
python_parser = PythonParser()
|
||||
result = python_parser.parse(sub_context, parser_input)
|
||||
|
||||
Reference in New Issue
Block a user