lib/net/imap/response_parser/parser_utils.rb in net-imap-0.4.2 vs lib/net/imap/response_parser/parser_utils.rb in net-imap-0.4.3
- old
+ new
@@ -168,9 +168,19 @@
def lookahead
@token ||= next_token
end
+ # like match, without consuming the token
+ def lookahead!(*args)
+ if args.include?((@token ||= next_token)&.symbol)
+ @token
+ else
+ parse_error('unexpected token %s (expected %s)',
+ @token&.symbol, args.join(" or "))
+ end
+ end
+
def peek_str?(str)
assert_no_lookahead if Net::IMAP.debug
@str[@pos, str.length] == str
end