token

package
v0.0.0-...-d0f7b5f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind of a token.

const (
	//Illegal token.
	Illegal Kind = iota
	//Literal token.
	Literal
	//String (single, double, bracket, back tick, or blob) token.
	String
	//Argument is @NNN or @ENV_VAR token.
	Argument
	//Placeholder is a pseudo-token for lifting non-standard subqueries
	//out of regular sql.
	Placeholder
	//LParen is a ( token.
	LParen
	//RParen is a ) token.
	RParen
	//Semicolon is a ; token.
	Semicolon
)

func (Kind) Empty

func (k Kind) Empty() bool

Empty is true if the kind of token has no value.

func (Kind) String

func (k Kind) String() string

type Poser

type Poser interface {
	Pos() Position
}

Posers can report their Position.

type Position

type Position struct {
	Name       string
	Line, Rune int
}

Position of a token in input.

func (Position) Pos

func (p Position) Pos() Position

func (Position) String

func (p Position) String() string

type Value

type Value struct {
	Position
	Kind
	//Value is only valid if !Kind.Empty()
	Value string
	//Canon is only valid if Kind == Literal and is strings.ToUpper(Value)
	Canon string
	//StringKind is only valid if Kind == String.
	//If valid it will be one of ' " ` [  or x (for blob literals).
	StringKind rune
	//Err is only non-nil if Kind == Illegal.
	Err error
}

Value of token in input.

func NewLiteral

func NewLiteral(s string) Value

func NewString

func NewString(s string) Value

func (Value) AnyLiteral

func (v Value) AnyLiteral(ss ...string) bool

AnyLiteral sees if v is any of the ss.

func (Value) Equal

func (v Value) Equal(s Value) bool

Equal if the same kind and value. Illegal, String, and Placeholder tokens are never equal.

func (Value) Head

func (v Value) Head(subquery bool) bool

Head is true if v is a literal whose canonical value is one of the list of valid literals for beginning a statement, as recognized by this SQLite superset.

func (Value) Literal

func (v Value) Literal(s string) bool

Literal if v.Kind == Literal and v.Canon == s.

func (Value) Op

func (v Value) Op() bool

Op is true if v is literal and first rune is one of "!@%&|-+=/<>"".

func (Value) String

func (v Value) String() string

func (Value) Unescape

func (v Value) Unescape() (string, bool)

Unescape a string (false if not string or literal).

func (Value) Valid

func (v Value) Valid() bool

Valid token.

Jump to

Keyboard shortcuts

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