Browse Source

Corrected & Simplified test

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.8.6
MegaIng1 4 years ago
parent
commit
ed17512c3a
1 changed files with 5 additions and 6 deletions
  1. +5
    -6
      tests/test_parser.py

+ 5
- 6
tests/test_parser.py View File

@@ -813,16 +813,15 @@ def _make_parser_test(LEXER, PARSER):

def test_templates(self):
g = _Lark(r"""
start: number_list "\n" number_dict
start: "[" sep{NUMBER, ","} "]"
sep{item, delim}: item (delim item)*
number_list: "[" sep{NUMBER, ","} "]"
number_dict: "{" sep{(NUMBER ":" NUMBER), ";"} "}" // Just to test this
NUMBER: /\d+/
%ignore " "
""")
x = g.parse("[1, 2, 3, 4] {1:2, 3:4, 5:6}")
print(x)
x = g.parse("[1] {1:2}")
x = g.parse("[1, 2, 3, 4]")
self.assertSequenceEqual(x.children,['1', '2', '3', '4'])
x = g.parse("[1]")
self.assertSequenceEqual(x.children,['1'])
print(x)

def test_token_collision_WS(self):


Loading…
Cancel
Save