Fixed first token recognition when creating bnf concepts

This commit is contained in:
2020-05-29 08:52:06 +02:00
parent 479461c0a4
commit c498b394e3
11 changed files with 125 additions and 24 deletions
+4 -1
View File
@@ -84,6 +84,8 @@ class TestBnfParser(TestUsingMemoryBasedSheerka):
("('a'*=x 'b'+=y)=z", Sequence(
ZeroOrMore(StrMatch("a"), rule_name="x"),
OneOrMore(StrMatch("b"), rule_name="y"), rule_name="z")),
("'--filter'",
Sequence(StrMatch("-", skip_whitespace=False), StrMatch("-", skip_whitespace=False), StrMatch("filter")))
])
def test_i_can_parse_regex(self, expression, expected):
sheerka, context, parser = self.init_parser()
@@ -141,8 +143,9 @@ class TestBnfParser(TestUsingMemoryBasedSheerka):
sheerka, context, parser = self.init_parser()
res = parser.parse(context, Tokenizer(expression))
ret_value = res.value.value
ret_value = res.body.body
assert parser.has_error
assert sheerka.isinstance(res.body, BuiltinConcepts.ERROR)
assert not res.status
assert ret_value[0] == error