Fixed initialisation issue for concepts with BNF definition
This commit is contained in:
@@ -485,6 +485,27 @@ def test_i_can_detect_duplicates_when_reference():
|
||||
assert res[1].value.body == [(foo, 0, 0, "twenty")]
|
||||
|
||||
|
||||
def test_i_can_parse_concept_reference_that_is_not_in_grammar():
|
||||
context = get_context()
|
||||
one = Concept(name="one")
|
||||
two = Concept(name="two")
|
||||
foo = Concept(name="foo")
|
||||
context.sheerka.add_in_cache(one)
|
||||
context.sheerka.add_in_cache(two)
|
||||
|
||||
concepts = {foo: Sequence("twenty", OrderedChoice(one, two))}
|
||||
parser = ConceptLexerParser()
|
||||
parser.initialize(context, concepts)
|
||||
|
||||
res = parser.parse(context, "twenty two")
|
||||
assert res.status
|
||||
assert res.value.body == [(foo, 0, 2, "twenty two")]
|
||||
|
||||
res = parser.parse(context, "twenty one")
|
||||
assert res.status
|
||||
assert res.value.body == [(foo, 0, 2, "twenty one")]
|
||||
|
||||
|
||||
def test_i_can_parse_zero_or_more():
|
||||
context = get_context()
|
||||
foo = Concept(name="foo")
|
||||
@@ -741,6 +762,7 @@ def test_infinite_recursion_does_not_fail_if_a_concept_is_missing():
|
||||
|
||||
assert foo in parser.concepts_grammars
|
||||
|
||||
|
||||
def test_i_can_detect_indirect_infinite_recursion_with_optional():
|
||||
# TODO infinite recursion with optional
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user