The MySQL lexing rules (backslash escapes in strings, backtick identifiers, # comments, the ---needs-whitespace rule, live /*! bodies) are implemented twice: rewriteMySQLSQL in internal/transform/mysql_sql.go rewrites ? to pyformat at generation time, and placeholderSequence in internal/driver/common.go scans the rewritten text to order binding slots for reused sqlc.slice markers.
The two are kept in sync by tests that pin each rule on both sides, but a divergence silently misorders reused-slice arguments - review on #248 caught two such cases (odd-length dash runs, the \r line-end rule) before merge. A single shared scanner would remove the failure class entirely; the open question is where it lives, since transform and driver do not import each other today. An alternative is computing the placeholder sequence during the rewrite and carrying it on the IR, dropping the second lexer.
The MySQL lexing rules (backslash escapes in strings, backtick identifiers,
#comments, the---needs-whitespace rule, live/*!bodies) are implemented twice:rewriteMySQLSQLininternal/transform/mysql_sql.gorewrites?to pyformat at generation time, andplaceholderSequenceininternal/driver/common.goscans the rewritten text to order binding slots for reusedsqlc.slicemarkers.The two are kept in sync by tests that pin each rule on both sides, but a divergence silently misorders reused-slice arguments - review on #248 caught two such cases (odd-length dash runs, the
\rline-end rule) before merge. A single shared scanner would remove the failure class entirely; the open question is where it lives, sincetransformanddriverdo not import each other today. An alternative is computing the placeholder sequence during the rewrite and carrying it on the IR, dropping the second lexer.