mirror of
https://github.com/apple/swift-nio-imap
synced 2026-11-28 05:14:27 +00:00
The grammar now runs on the ~Escapable ParseInput cursor; ParserLibrary and its ParseBuffer are deleted. The stream parsers are generic over ConsumableParserInputBuffer and gather once per call: CommandParser frames synchronizing literals and parses through the same cursor, narrowing its limit instead of slicing. The NIO handlers still feed ByteBuffers, through its ParserInputBuffer conformance. Review focus: CommandParser.parseCommandStream and ResponseParser.parseResponseStream (what is consumed on each exit path). Behavior changes: - Stray spaces before a line ending: up to ParseInput.maximumStraySpaces (1024) are accepted; more throw ParserError. On main, PL.parseNewline recursed through composite once per space, so ~100 threw TooMuchRecursion from the shared 100-frame tracker. Both a looser limit and a different error type. - Trailing spaces with no line ending yet report IncompleteMessage while under the cap, where they used to throw ParserError. Fixes the client side (ResponseParser), which has no framing layer, for a read split as "* 1 EXISTS " | "\r\n". - From an IMAPInputBuffer, payload pieces of at least 1 KiB taken from a retained read (>= 1 KiB, fixed address) refer to it; a large Data is retained as the buffer's one copy. Smaller pieces and tail bytes are copied. From a bare ByteBuffer, payloads are copied. Grammar edits beyond the cursor: the QUOTA resource loop binds parseOptional's result to an explicit `Void?`, and parseLookupKeyword loses a comment about the tracker it no longer takes. ParserError.hint gains a note to keep hot-path hints literal: ParserLibrary's interpolated ones, deleted here, allocated on every mismatch. Public API break: parseCommandStream(buffer:) and parseResponseStream(buffer:) are generic. ByteBuffer conforms in NIOIMAP, so a caller importing only NIOIMAPCore must import NIOIMAP to pass one. Temporary: `typealias ParseBuffer = ParseInput` keeps the grammar's spelling until "Rename ParseBuffer to ParseInput (scripted)". Removes LegacySubParser, the ParseBuffer cursor-method shim and the framing bridge from "Move SynchronizingLiteralParser onto ParserInputBuffer".