Skip to content

Commit c5331e7

Browse files
committed
Fix issue #35
Fix an odd degenerate case where empty list literals aren't displayed.
1 parent af75375 commit c5331e7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/celpy/celparser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ def list_lit(self, tree: lark.Tree) -> None:
335335
if self.stack:
336336
left = self.stack.pop()
337337
self.stack.append(f"[{left}]")
338+
else:
339+
self.stack.append("")
338340

339341
def map_lit(self, tree: lark.Tree) -> None:
340342
if self.stack:

tests/test_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,12 @@ def test_dump_ast(parser):
439439
assert DumpAST.display(ast6) == ".min()"
440440

441441

442+
def test_dump_issue_35():
443+
cel = "[]"
444+
tree = CELParser().parse(cel)
445+
assert DumpAST.display(tree) == ""
446+
447+
442448
def test_tree_dump(parser):
443449
ast = parser.parse("-(3*4+5-1/2%3==1)?name[index]:f(1,2)||false&&true")
444450
assert tree_dump(ast) == '- (3 * 4 + 5 - 1 / 2 % 3 == 1) ? name[index] : f(1, 2) || false && true'

0 commit comments

Comments
 (0)