Skip to content

Commit

Permalink
Handle useless semicolon statement endings.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanAlbert committed May 11, 2023
1 parent 24ba89c commit a545fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dcs/lua/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def parse(self):
return self.number()
elif c == '_':
return self.str_function()
elif c == ';':
self.advance()
return self.parse()
else: # varname
self.eat_ws()

Expand Down
12 changes: 12 additions & 0 deletions dcs/lua/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,18 @@ def test_mixed_quote_strings(self) -> None:
r = loads("name = \"foo 'bar' baz\"")
self.assertEqual(r["name"], "foo 'bar' baz")

def test_useless_semicolon(self) -> None:
r = loads(
textwrap.dedent(
"""\
name = "foo";
other_name = "bar";
"""
)
)
self.assertEqual(r["name"], "foo")
self.assertEqual(r["other_name"], "bar")


if __name__ == '__main__':
unittest.main()

0 comments on commit a545fc4

Please sign in to comment.