fix: add SQL comment support to the scanner (-- and /* */) - #277
Open
0x5t4l1n wants to merge 1 commit into
Open
Conversation
Resolves tomarrell#200. The parser had no token types or scanner rules for SQL comments as specified in https://www.sqlite.org/lang_comment.html. Both single-line (--) and multi-line (/* */) comment forms are now recognised by the rule-based scanner and emitted as distinct token kinds. The parser skips these tokens so comments are transparent to grammar rules, matching SQLite behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n\nFixes #200 — SQL comments as specified in https://www.sqlite.org/lang_comment.html were not recognised by the scanner, causing parse errors when SQL input contained comments.\n\nNew files in
internal/parser/scanner/:\n-token/kind.go— addsSingleLineCommentandMultiLineCommenttoken kinds\n-comment_scanner.go—TryScanComment(src, pos)handles--and/* */forms\n-comment_scanner_test.go— full test coverage including unterminated comments and edge cases\n\nThe parser layer skips both comment token kinds so they are transparent to grammar rules.\n\n## Test plan\n- [ ]go test ./internal/parser/scanner/...\n- [ ] ParseSELECT 1 -- comment→ succeeds\n- [ ] ParseSELECT /* multi\\nline */ 1→ succeeds\n\n🤖 Generated with Claude Code