token

package
v0.2.48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 7 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePos

func ComparePos(x, y Pos) int

Types

type Kind

type Kind int
const (
	// A keyword (like SELECT)
	SQLKeyword Kind = iota
	// Numeric literal
	Number
	// A character that cloud not be tokenized
	Char
	// Single quoted string i.e: 'string'
	SingleQuotedString
	// National string i.e: N'string'
	NationalStringLiteral
	// Comma
	Comma
	// Whitespace
	Whitespace
	// comment node
	Comment
	// multiline comment node
	MultilineComment
	// = operator
	Eq
	// != or <> operator
	Neq
	// <  operator
	Lt
	// > operator
	Gt
	// <= operator
	LtEq
	// >= operator
	GtEq
	// + operator
	Plus
	// - operator
	Minus
	// * operator
	Mult
	// / operator
	Div
	// % operator
	Caret
	// ^ operator
	Mod
	// Left parenthesis `(`
	LParen
	// Right parenthesis `)`
	RParen
	// Period
	Period
	// Colon
	Colon
	// DoubleColon
	DoubleColon
	// Semicolon
	Semicolon
	// Backslash
	Backslash
	// Left bracket `]`
	LBracket
	// Right bracket `[`
	RBracket
	// &
	Ampersand
	// Left brace `{`
	LBrace
	// Right brace `}`
	RBrace
	// ILLEGAL sqltoken
	ILLEGAL
)

func (Kind) String

func (i Kind) String() string

type Pos

type Pos struct {
	Line int
	Col  int
}

func NewPos

func NewPos(line, col int) Pos

func (*Pos) String

func (p *Pos) String() string

type SQLWord

type SQLWord struct {
	Value      string
	QuoteStyle rune
	Keyword    string
	Kind       dialect.KeywordKind
}

func MakeKeyword

func MakeKeyword(word string, quoteStyle rune) *SQLWord

func (*SQLWord) NoQuoteString added in v0.2.27

func (s *SQLWord) NoQuoteString() string

func (*SQLWord) String

func (s *SQLWord) String() string

type Token

type Token struct {
	Kind  Kind
	Value interface{}
	From  Pos
	To    Pos
}

type Tokenizer

type Tokenizer struct {
	Dialect dialect.Dialect
	Scanner *scanner.Scanner
	Line    int
	Col     int
}

func NewTokenizer

func NewTokenizer(src io.Reader, dialect dialect.Dialect) *Tokenizer

func (*Tokenizer) NextToken

func (t *Tokenizer) NextToken() (*Token, error)

func (*Tokenizer) Pos

func (t *Tokenizer) Pos() Pos

func (*Tokenizer) Tokenize

func (t *Tokenizer) Tokenize() ([]*Token, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL