Commit 0182d8ce authored by eckhart's avatar eckhart
Browse files

test_ebnf.py: new test case for skipping

parent 9990b363
......@@ -48,7 +48,7 @@
syntax = ~ { definition | directive } EOF
definition = symbol §:DEF~ [ :OR~ ] expression :ENDL~ & FOLLOW_UP # [:OR~] to support v. Rossum's syntax
directive = "@" §symbol "=" ( component { "," component } | expression ) & FOLLOW_UP
directive = "@" §symbol "=" component { "," component } & FOLLOW_UP
component = (regexp | literals | procedure | symbol !DEF)
literals = { literal }+ # string chaining, only allowed in directives!
procedure = SYM_REGEX "()" # procedure name, only allowed in directives!
......
......@@ -38,7 +38,7 @@
syntax = ~ { definition | directive } EOF
definition = symbol §DEF~ [ OR~ ] expression ENDL~ & FOLLOW_UP # [OR~] to support v. Rossum's syntax
directive = "@" §symbol "=" ( component { "," component } | expression ) & FOLLOW_UP
directive = "@" §symbol "=" component { "," component } & FOLLOW_UP
component = (regexp | literals | procedure | symbol !DEF)
literals = { literal }+ # string chaining, only allowed in directives!
procedure = SYM_REGEX "()" # procedure name, only allowed in directives!
......
......@@ -688,6 +688,27 @@ class TestErrorRecovery:
assert len(st.errors) == 2 and any(err.code == RESUME_NOTICE for err in st.errors)
assert 'Skipping' in str(st.errors_sorted[1])
def test_series_skip2(self):
grammar = """
@whitespace = vertical
@literalws = right
document = { sentence }+ EOF
@sentence_skip = /\s|(?=\.|$)/
sentence = { word §&continuation }+ "."
continuation = (word | `.` | EOF)
word = /[A-Za-z]+/~
EOF = !/./
"""
data = "Time is out of joint. Oh cursed spite that I was ever born to set it right."
parser = grammar_provider(grammar)()
st = parser(data)
assert not st.errors, str(st.errors)
data2 = data.replace('cursed', 'cur?ed')
st = parser(data2)
assert len(st.errors) == 1
zombie = st.pick('ZOMBIE__')
assert zombie.content == '?ed ', zombie.content
def test_irrelevance_of_error_definition_order(self):
lang = """
document = series | /.*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment