Add SQL lexer with token scanning and position tracking#23
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a position-tracked SQL lexer: token types, keyword map and lookup, scanners for identifiers/numbers/strings, whitespace/comment skipping, lexer error types, NextToken returning (Token, error), and a generic LookaheadIterator for parser peek semantics. ChangesSQL Lexer Infrastructure
Assessment against linked issues
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/sql/lexer/lookahead.go (1)
16-17: ⚡ Quick winConsider validating
nextFnparameter.If
nextFnis nil, the iterator will panic later during the firstPeek()orNext()call with a nil pointer dereference. Adding an early check would provide a clearer error message at construction time.🛡️ Suggested validation
func NewLookaheadIterator[T any](nextFn func() T) *LookaheadIterator[T] { + if nextFn == nil { + panic("lookahead: nextFn cannot be nil") + } return &LookaheadIterator[T]{nextFn: nextFn} }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bc4ffb44-7265-4271-9e98-3f6725f40711
📒 Files selected for processing (6)
internal/sql/lexer/errors.gointernal/sql/lexer/keywords.gointernal/sql/lexer/lexer.gointernal/sql/lexer/lookahead.gointernal/sql/lexer/position.gointernal/sql/lexer/tokens.go
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/sql/lexer/lexer.go (1)
22-22:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winTypo in doc comment: "fro" → "for".
-// NewLexer creates a Lexer fro the given SQL source string +// NewLexer creates a Lexer for the given SQL source string
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1099c6c0-fd02-47c0-b261-90848c729c04
📒 Files selected for processing (3)
internal/sql/lexer/.gitkeepinternal/sql/lexer/errors.gointernal/sql/lexer/lexer.go
Issue Reference
Summary by CodeRabbit
New Features
Bug Fixes / Reliability