Tags: sqlc-dev/marino
Tags
parser: record scanned comments and stamp table/column positions (#46) Record the comments the lexer skips — '-- ' and '#' line comments and '/* */' block comments — as byte-offset spans on the Scanner, exposed through Scanner.Comments and Parser.Comments. Executable comments and optimizer hints are lexed as SQL, so they are not recorded, and recording is gated on strictly increasing positions because the scanner's lookaheads re-read source text. Stamp OriginTextPosition on FROM-clause table factors, INSERT/REPLACE table references and INSERT column lists, which goyacc left unstamped (it stamped only <expr> symbols). Consumers placing comments or errors need these positions; only Accept-reachable nodes are stamped so the restore round-trip tests can keep resetting them. This gives sqlc's MySQL engine what its ParseFile needs to power sqlc fmt: statements and comments from one lexer pass, with enough positions to anchor comments and the author's line breaks. Claude-Session: https://claude.ai/code/session_01C48orUYrL7xE989UGLTVqi Co-authored-by: Claude <noreply@anthropic.com>