Skip to content

Commit bdda80e

Browse files
committed
Fix multiselect list parsing
Closes #86.
1 parent 9302489 commit bdda80e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

jmespath/parser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,13 @@ def _parse_comparator(self, left, comparator):
338338

339339
def _parse_multi_select_list(self):
340340
expressions = []
341-
while not self._current_token() == 'rbracket':
341+
while True:
342342
expression = self._expression()
343343
expressions.append(expression)
344-
if self._current_token() == 'comma':
344+
if self._current_token() == 'rbracket':
345+
break
346+
else:
345347
self._match('comma')
346-
self._assert_not_token('rbracket')
347348
self._match('rbracket')
348349
return ast.multi_select_list(expressions)
349350

tests/compliance/syntax.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@
201201
"expression": "foo.[0]",
202202
"error": "syntax"
203203
},
204+
{
205+
"expression": "[foo bar]",
206+
"error": "syntax"
207+
},
204208
{
205209
"expression": "foo.[*]",
206210
"result": null

0 commit comments

Comments
 (0)