From c953dd9505dbba1bd8fbded0077a040a1ce0e5b5 Mon Sep 17 00:00:00 2001 From: Erez Sh Date: Mon, 5 Jul 2021 13:15:29 +0300 Subject: [PATCH] Tests: Added a test case demonstrating the need for calculating containers --- tests/test_parser.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_parser.py b/tests/test_parser.py index ff4e064..40ed131 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -94,6 +94,26 @@ class TestParsers(unittest.TestCase): r = g.parse('a') self.assertEqual( r.children[0].meta.line, 1 ) + def test_propagate_positions2(self): + g = Lark("""start: a + a: b + ?b: "(" t ")" + !t: "t" + """, propagate_positions=True) + + start = g.parse("(t)") + a ,= start.children + t ,= a.children + assert t.children[0] == "t" + + assert t.meta.column == 2 + assert t.meta.end_column == 3 + + assert start.column == a.column == 1 + assert start.end_column == a.end_column == 4 + + + def test_expand1(self): g = Lark("""start: a