Once a quoted field closes, the only things allowed next are a delimiter, a newline, or the end of input. Anything else is malformed, and today you report it at the position of the offending character, completing the quoting state machine.
Report an error when characters other than a delimiter or newline follow a closing quote.
A quoted field makes a tidy promise: after its closing quote, the field is over, so
the very next thing must be a separator. Concretely, once you read the closing quote
you enter a brief after-quote state where only three things are legal, a
delimiter to start the next field, a record terminator to end the row, or the end of
the input. A " followed by a" followed by b violates this, because b is
neither, and the honest response is to reject it at the position of that b rather
than silently gluing it onto the field.
This includes whitespace: a space after a closing quote, as in "a" b, is stray
text too, because leading and trailing spaces are significant in this parser and a
quoted field’s boundary is exact. Reporting these at the offending column, using the
positioned error from the previous lesson, closes out the quoting state machine.
With it, your parser now has a complete model of quotes: it opens them only at a
field’s start, reads any content including delimiters, newlines, and escaped quotes,
requires a matching close, and forbids anything unexpected around the boundary. Every
later chapter builds on this core without changing it.
// after the CLOSING quote you are in an "after-quote" state; the next rune must be// a delimiter -> start the next field// a newline / carriage return / end of input -> end the record// anything else (including a space) -> ParseError at the current column