parser

package
v0.0.0-...-e31ada9 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate struct {
	Func   string
	Column string
}

type Condition

type Condition struct {
	Field string
	Op    string
	Value string
}

type Join

type Join struct {
	Table    string
	OnField1 string
	OnField2 string
}

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer represents a lexer for SQL.

func NewLexer

func NewLexer(input string) *Lexer

NewLexer initializes a new Lexer.

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Node

type Node interface{}

AST Nodes

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser represents a parser for SQL.

func NewParser

func NewParser(l *Lexer) *Parser

NewParser initializes a new Parser.

func (*Parser) Parse

func (p *Parser) Parse() Node

type SelectStatement

type SelectStatement struct {
	Columns    []string
	TableName  string
	Conditions []Condition
	Joins      []Join
	Aggregates []Aggregate
}

type Token

type Token struct {
	Type    TokenType
	Literal string
}

Token represents a lexical token.

type TokenType

type TokenType int
const (
	ILLEGAL TokenType = iota
	EOF
	WS
	IDENT
	NUMBER
	COMMA
	SELECT
	FROM
	WHERE
	EQ
	GT  // Greater Than
	LT  // Less Than
	GTE // Greater Than or Equal To
	LTE // Less Than or Equal To
	NEQ // Not Equal To
	AND
	INSERT
	INTO
	VALUES
	UPDATE
	SET
	DELETE
	LPAREN
	RPAREN
	JOIN
	ON
	SUM
	ASTERISK
)

Jump to

Keyboard shortcuts

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