Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lib/jmespath/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ def nud_lbrace(stream)
pairs = []
begin
pairs << parse_key_value_pair(stream)
stream.next(match: valid_keys) if stream.token.type == :comma
if stream.token.type == :comma
stream.next(match: valid_keys)
elsif stream.token.type != :rbrace
raise Errors::SyntaxError, 'expected a comma or closing rbrace'
end
end while stream.token.type != :rbrace
stream.next
Nodes::MultiSelectHash.new(pairs)
Expand Down Expand Up @@ -215,7 +219,14 @@ def led_lparen(stream, left)
stream.next
while stream.token.type != :rparen
args << expr(stream, 0)
stream.next if stream.token.type == :comma
if stream.token.type == :comma
stream.next
if stream.token.type == :rparen
raise Errors::SyntaxError, 'expression expected, found rparen'
end
elsif stream.token.type != :rparen
raise Errors::SyntaxError, 'expected a comma or closing rparen'
end
end
stream.next
Nodes::Function.create(name, args, disable_visit_errors: @disable_visit_errors)
Expand Down Expand Up @@ -294,8 +305,10 @@ def parse_multi_select_list(stream)
if stream.token.type == :comma
stream.next
if stream.token.type == :rbracket
raise Errors::SyntaxError, 'expression epxected, found rbracket'
raise Errors::SyntaxError, 'expression expected, found rbracket'
end
elsif stream.token.type != :rbracket
raise Errors::SyntaxError, 'expected a comma or closing rbracket'
end
end while stream.token.type != :rbracket
stream.next
Expand Down