Fixed #125: SheerkaErrorManager

Fixed #135: Change services service priorities
Fixed #136: ErrorManager: Implement recognize_error
Fixed #137: BNFNodeParser : Error when parsing regex with sub parsers
Fixed #138: get_last_errors(): real errors sources are lost
Fixed #139: OneError return value removes the origin of the error
Fixed #140: Concept variables are not correctly handled when parsing sub expression
Fixed #143: Implement has_unknown_concepts()
This commit is contained in:
2021-10-28 14:04:41 +02:00
parent 48ab72fd9c
commit 87cab44fb8
56 changed files with 1391 additions and 1286 deletions
@@ -87,7 +87,7 @@ class TestExprToConditionsVisitor(TestUsingMemoryBasedSheerka):
@staticmethod
def get_conditions_from_expression(context, expression, parser=None):
parser = parser or ExpressionParser(old_style=False)
parser = parser or ExpressionParser()
error_sink = ErrorSink()
parser_input = ParserInput(expression)
parser.reset_parser_input(parser_input, error_sink)
@@ -293,6 +293,21 @@ class TestExprToConditionsVisitor(TestUsingMemoryBasedSheerka):
resolved_expected_objects = {k: cmap[v].id for k, v in {"__o_00__": "two"}.items()}
assert resolved_objects == resolved_expected_objects
def test_i_can_manage_possible_variable_indication(self):
my_map = {
"isa": Concept("x is an int").def_var("x") # no pre condition
}
sheerka, context = self.initialize_test(my_map)
parser = ExpressionParser(known_variables={"x"})
conditions = self.get_conditions_from_expression(context, "x is an int", parser)
python_source = conditions[0].return_value.body.body.source
assert python_source == "call_concept(__o_00__, x=x)"
resolved_objects = {k: v.id for k, v in conditions[0].objects.items()}
resolved_expected_objects = {k: my_map[v].id for k, v in {"__o_00__": "isa"}.items()}
assert resolved_objects == resolved_expected_objects
def test_i_can_parse_when_variables_are_missing(self):
sheerka, context = self.initialize_test()
expression = "x equals 1"
@@ -17,7 +17,7 @@ class TestPythonExprVisitor(TestUsingMemoryBasedSheerka):
@staticmethod
def get_expr_node(context, expression, parser=None):
parser = parser or ExpressionParser(old_style=False)
parser = parser or ExpressionParser()
error_sink = ErrorSink()
parser_input = ParserInput(expression)
parser.reset_parser_input(parser_input, error_sink)