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 int
Constants: TokenTypeSelect, TokenTypeFrom, TokenTypeWhere, TokenTypeIdentifier, etc.
v1.6.0 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 column number
Offset int // 0-based byte offset
}
Functions
NewTokenWithSpan(tokenType TokenType, value string, span Span) TokenWithSpan
Create token with span.
(t TokenType) String() string
Get string representation.
v1.6.0 Enhancement:
- Complete hash map implementation covering all 90+ token types (optimized for performance)