Skip to content

Commit c52853e

Browse files
committed
🚧 Parse RFC4466 tagged-ext-val
Although this is currently unused, we need `tagged-ext-val` for the RFC4466 extension grammar for `STATUS`, `ESEARCH`, `LIST`, etc.
1 parent aacc2ac commit c52853e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

lib/net/imap/response_parser.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,50 @@ def case_insensitive__nstring
556556
NIL? ? nil : case_insensitive__string
557557
end
558558

559+
# tagged-ext-comp = astring /
560+
# tagged-ext-comp *(SP tagged-ext-comp) /
561+
# "(" tagged-ext-comp ")"
562+
# ; Extensions that follow this general
563+
# ; syntax should use nstring instead of
564+
# ; astring when appropriate in the context
565+
# ; of the extension.
566+
# ; Note that a message set or a "number"
567+
# ; can always be represented as an "atom".
568+
# ; A URL should be represented as
569+
# ; a "quoted" string.
570+
def tagged_ext_comp
571+
vals = []
572+
while true
573+
vals << case lookahead!(*ASTRING_TOKENS, T_LPAR).symbol
574+
when T_LPAR then lpar; ary = tagged_ext_comp; rpar; ary
575+
when T_NUMBER then number
576+
else astring
577+
end
578+
SP? or break
579+
end
580+
vals
581+
end
582+
583+
# tagged-ext-simple is a subset of atom
584+
# TODO: recognize sequence-set in the lexer
585+
#
586+
# tagged-ext-simple = sequence-set / number / number64
587+
def tagged_ext_simple
588+
number? || sequence_set
589+
end
590+
591+
# tagged-ext-val = tagged-ext-simple /
592+
# "(" [tagged-ext-comp] ")"
593+
def tagged_ext_val
594+
if lpar?
595+
_ = peek_rpar? ? [] : tagged_ext_comp
596+
rpar
597+
_
598+
else
599+
tagged_ext_simple
600+
end
601+
end
602+
559603
# valid number ranges are not enforced by parser
560604
# number64 = 1*DIGIT
561605
# ; Unsigned 63-bit integer

0 commit comments

Comments
 (0)