models package
Core data structures shared by every stage: tokens, spans and locations.
Import path: github.com/ajitpratap0/GoSQLX/pkg/models (pkg.go.dev)
Part of the GoSQLX API reference.
Core Types
TokenType (Type)
type TokenType intConstants: TokenTypeSelect, TokenTypeFrom, TokenTypeWhere, TokenTypeIdentifier, etc.
Enhancements:
- 120+ new SQL token types with proper categorization
ModelTypefield for O(1) int-based comparisons- Helper methods:
IsKeyword(),IsOperator(),IsLiteral(),IsDMLKeyword(),IsDDLKeyword(), etc.
TokenWithSpan
type TokenWithSpan struct {
Type TokenType
Value string
Span Span
}Span
type Span struct {
Start Location
End Location
}Location
type Location struct {
Line int // 1-based line number
Column int // 1-based byte column within the line
}Column counts bytes, not runes or UTF-16 units: a multi-byte character counts its bytes, and a tab is one column. A token's Start is the token itself, after any leading whitespace and comments. Convert to UTF-16 before sending positions to an LSP client.
Functions
NewTokenWithSpan(tokenType TokenType, value string, span Span) TokenWithSpan
Create token with span.
(t TokenType) String() string
Get string representation.
Enhancement:
- Complete hash map implementation covering all 90+ token types (optimized for performance)