Implement ParseFile on the dolphin parser: marino now records the
comments its lexer scans, so statements and comments come from one
parser pass, with statement extents computed by sequential search so
repeated statements resolve to their own occurrences. Parse becomes a
filter over ParseFile, dropping the TODO statements the compiler skips
while the formatter still sees them.
Register MySQL in newQueryFormatter and teach the fmt comment helpers
MySQL's # line-comment syntax. Carry marino's newly stamped positions
through the converter (FROM tables, INSERT columns, binary and IS NULL
expressions) so comments anchor to the right clause and the author's
line breaks survive, matching the SQLite and PostgreSQL behavior.
The fmt/mysql endtoend case now expects formatted output instead of
the unsupported-engine notice.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C48orUYrL7xE989UGLTVqi
sqlc fmt now formats MySQL query files. Built on marino v0.3.1 (sqlc-dev/marino#46), whose lexer records the comments it scans and stamps positions on table references and INSERT column lists.
dolphin: ParseFile
The dolphin parser gains ParseFile, following meyer's and oliphant's shape: statements and the file's comments from one parser pass. Parse becomes a filter over it — statements sqlc has no node for stay in ParseFile's list (the formatter needs their extents to keep them as written) and are dropped for the compiler.
Statement extents are now found by searching from the previous statement's end instead of strings.Index over the whole file, so two statements with identical text no longer resolve to the same location.
fmt
MySQL joins newQueryFormatter, and the comment-line helpers learn #, MySQL's line-comment syntax — safe globally, since text reaching those helpers sits outside statements the engine already parsed. The docs page now names the supported engines.
Converter positions
The converted nodes carry the positions marino now stamps — FROM-clause tables, INSERT columns, binary and IS NULL expressions. The printer's comment anchoring and break preservation are position-driven (Pos() == 0 nodes are invisible to them), and these fixed two fidelity issues:
Both now match the SQLite and PostgreSQL behavior: comments stay anchored to their clause, and the author's line breaks survive.
All of fmt's safety nets apply unchanged: a statement is only reformatted when the output reparses to one statement with the same comments and prints as a fixed point, and no file result may change comment content or statement count.
Testing
The fmt/mysql endtoend case now expects real formatted output — -- name: headers, # hash comments, inline /* */ comments, trailing same-line comments, @user_name session variables, and CAST(... AS UNSIGNED) all preserved. The full --tags=examples suite passes against live PostgreSQL and MySQL.
🤖 Generated with Claude Code
https://claude.ai/code/session_01C48orUYrL7xE989UGLTVqi
Generated by Claude Code