diff --git a/lark/parsers/xearley.py b/lark/parsers/xearley.py index 762c2a8..a2aaf24 100644 --- a/lark/parsers/xearley.py +++ b/lark/parsers/xearley.py @@ -52,7 +52,6 @@ class Parser: # Define parser functions start_symbol = start_symbol or self.start_symbol delayed_matches = defaultdict(list) - match_after_ignore = set() text_line = 1 text_column = 0 @@ -89,8 +88,7 @@ class Parser: m = x.match(stream, i) if m: delayed_matches[m.end()] += set(to_scan) - if m.end() == len(stream): - match_after_ignore.update(set(column.to_reduce)) + delayed_matches[m.end()] += set(column.to_reduce) # TODO add partial matches for ignore too? # s = m.group(0) @@ -142,10 +140,6 @@ class Parser: solutions = [n.tree for n in column.to_reduce if n.rule.origin==start_symbol and n.start is column0] - if not solutions: - solutions = [n.tree for n in match_after_ignore - if n.rule.origin==start_symbol and n.start is column0] - if not solutions: raise ParseError('Incomplete parse: Could not find a solution to input') elif len(solutions) == 1: diff --git a/tests/test_parser.py b/tests/test_parser.py index ffed772..0b3a9f1 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -962,6 +962,13 @@ def _make_parser_test(LEXER, PARSER): tree = parser.parse("int 1 ! This is a comment") # A trailing ignore token can be tricky! self.assertEqual(tree.children, ['1']) + parser = _Lark(r""" + start : "a"* + %ignore "b" + """) + tree = parser.parse("bb") + self.assertEqual(tree.children, []) + @unittest.skipIf(LEXER==None, "Scanless doesn't support regular expressions") def test_regex_escaping(self):