Skip to content

Commit dfb5174

Browse files
committed
🐛 Add missing lookahead_case_insensitive_string!
This adds `lookahead_{token}!` to `def_token_matchers`, as a lookahead version of match, returning the value without consuming the token. `lookahead_case_insensitive_string!` is a fallback for the regexp in `body_type_1part`. This fallback should be invoked nnly very rarely. Its definition was lost when rebasing.
1 parent bcdf31f commit dfb5174

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/net/imap/response_parser/parser_utils.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ def def_token_matchers(name, *token_symbols, coerce: nil, send: nil)
8181
class_eval <<~RUBY, __FILE__, __LINE__ + 1
8282
# frozen_string_literal: true
8383
84+
# lookahead version of match, returning the value
85+
def lookahead_#{name}!
86+
token = #{LOOKAHEAD}
87+
if #{matcher}
88+
#{value}
89+
else
90+
#{raise_parse_error}
91+
end
92+
end
93+
8494
def #{name}?
8595
token = #{LOOKAHEAD}
8696
if #{matcher}
@@ -99,6 +109,7 @@ def #{match_name}
99109
end
100110
end
101111
RUBY
112+
102113
end
103114

104115
end

0 commit comments

Comments
 (0)