parse

package
v0.0.0-...-348c89d Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanSqlChars

func ScanSqlChars(data []byte, atEOF bool) (advance int, token []byte, err error)

Types

type CreateIndexData

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

CreateIndexData is the parser for the "create index" statement.

func NewCreateIndexData

func NewCreateIndexData(idxname, tblname, fldname string) *CreateIndexData

NewCreateIndexData saves the table and field names of the specified index.

func (*CreateIndexData) FieldName

func (c *CreateIndexData) FieldName() string

FieldName returns the name of the indexed field.

func (*CreateIndexData) IndexName

func (c *CreateIndexData) IndexName() string

IndexName returns the name of the index.

func (*CreateIndexData) TableName

func (c *CreateIndexData) TableName() string

TableName returns the name of the indexed table.

type CreateTableData

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

CreateTableData is the data for the SQL "create table" statement.

func NewCreateTableData

func NewCreateTableData(tblname string, sch *record.Schema) *CreateTableData

NewCreateTableData saves the table name and schema.

func (*CreateTableData) NewSchema

func (c *CreateTableData) NewSchema() *record.Schema

NewSchema returns the schema of the new table.

func (*CreateTableData) TableName

func (c *CreateTableData) TableName() string

TableName returns the name of the new table.

type CreateViewData

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

CreateViewData is the data for the SQL "create view" statement.

func NewCreateViewData

func NewCreateViewData(viewname string, qrydata *QueryData) *CreateViewData

NewCreateViewData saves the view name and its definition.

func (*CreateViewData) ViewDef

func (c *CreateViewData) ViewDef() string

ViewDef returns the definition of the new view.

func (*CreateViewData) ViewName

func (c *CreateViewData) ViewName() string

ViewName returns the name of the new view.

type DeleteData

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

DeleteData is the data for the SQL "delete" statement.

func NewDeleteData

func NewDeleteData(tblname string, pred *query.Predicate) *DeleteData

NewDeleteData saves the table name and predicate.

func (*DeleteData) Pred

func (d *DeleteData) Pred() *query.Predicate

Pred returns the predicate that describes which records should be deleted.

func (*DeleteData) TableName

func (d *DeleteData) TableName() string

TableName returns the name of the affected table.

type InsertData

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

InsertData is the data for the SQL "insert" statement.

func NewInsertData

func NewInsertData(tblname string, flds []string, vals []*record.Constant) *InsertData

NewInsertData saves the table name and the field and value lists.

func (*InsertData) Fields

func (i *InsertData) Fields() []string

Fields returns a list of fields for which values will be specified in the new record.

func (*InsertData) TableName

func (i *InsertData) TableName() string

TableName returns the name of the affected table.

func (*InsertData) Vals

func (i *InsertData) Vals() []*record.Constant

Vals returns a list of values for the specified fields. There is a one-one correspondence between this list of values and the list of fields.

type Lexer

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

Lexer is the lexical analyzer.

func NewLexer

func NewLexer(s string) *Lexer

NewLexer creates a new lexical analyzer for SQL statement s.

func (*Lexer) EatDelim

func (l *Lexer) EatDelim(d rune)

eatDelim throws an exception if the current token is not the specified delimiter. Otherwise, moves to the next token.

func (*Lexer) EatId

func (l *Lexer) EatId() string

eatId throws an exception if the current token is not an identifier. Otherwise, returns the identifier string and moves to the next token.

func (*Lexer) EatIntConstant

func (l *Lexer) EatIntConstant() int

eatIntConstant throws an exception if the current token is not an integer. Otherwise, returns that integer and moves to the next token.

func (*Lexer) EatKeyword

func (l *Lexer) EatKeyword(w string)

eatKeyword throws an exception if the current token is not the specified keyword. Otherwise, moves to the next token.

func (*Lexer) EatStringConstant

func (l *Lexer) EatStringConstant() string

eatStringConstant throws an exception if the current token is not a string. Otherwise, returns that string and moves to the next token.

func (*Lexer) MatchDelim

func (l *Lexer) MatchDelim(d rune) bool

matchDelim returns true if the current token is the specified delimiter character.

func (*Lexer) MatchId

func (l *Lexer) MatchId() bool

matchId returns true if the current token is a legal identifier.

func (*Lexer) MatchKeyword

func (l *Lexer) MatchKeyword(w string) bool

matchKeyword returns true if the current token is the specified keyword.

func (*Lexer) MatchStringConstant

func (l *Lexer) MatchStringConstant() bool

matchStringConstant returns true if the current token is a string.

type ModifyData

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

ModifyData is the data for the SQL "update" statement.

func NewModifyData

func NewModifyData(tblname, fldname string, newval *query.Expression, pred *query.Predicate) *ModifyData

NewModifyData saves the table name, the modified field and its new value, and the predicate.

func (*ModifyData) NewValue

func (m *ModifyData) NewValue() *query.Expression

NewValue returns an expression. Evaluating this expression for a record produces the value that will be stored in the record's target field.

func (*ModifyData) Pred

func (m *ModifyData) Pred() *query.Predicate

Pred returns the predicate that describes which records should be modified.

func (*ModifyData) TableName

func (m *ModifyData) TableName() string

TableName returns the name of the affected table.

func (*ModifyData) TargetField

func (m *ModifyData) TargetField() string

TargetField returns the field whose values will be modified.

type Parser

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

Parser is the SimpleDB parser.

func NewParser

func NewParser(s string) *Parser

NewParser creates a new parser for SQL statement s.

func (*Parser) Constant

func (p *Parser) Constant() *record.Constant

Constant parses and returns a constant.

func (*Parser) CreateIndex

func (p *Parser) CreateIndex() *CreateIndexData

CreateIndex parses and returns a create index data.

func (*Parser) CreateTable

func (p *Parser) CreateTable() *CreateTableData

CreateTable parses and returns a create table data.

func (*Parser) CreateView

func (p *Parser) CreateView() *CreateViewData

CreateView parses and returns a create view data.

func (*Parser) Delete

func (p *Parser) Delete() *DeleteData

Delete parses and returns a delete data.

func (*Parser) Expression

func (p *Parser) Expression() *query.Expression

Expression parses and returns an expression.

func (*Parser) Field

func (p *Parser) Field() string

Field parses and returns a field.

func (*Parser) Insert

func (p *Parser) Insert() *InsertData

Insert parses and returns an insert data.

func (*Parser) Modify

func (p *Parser) Modify() *ModifyData

Modify parses and returns a modify data.

func (*Parser) Predicate

func (p *Parser) Predicate() *query.Predicate

Predicate parses and returns a predicate.

func (*Parser) Query

func (p *Parser) Query() *QueryData

Query parses and returns a query data.

func (*Parser) Term

func (p *Parser) Term() *query.Term

Term parses and returns a term.

func (*Parser) UpdateCmd

func (p *Parser) UpdateCmd() interface{}

UpdateCmd parses and returns an update command.

type PredParser

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

func NewPredParser

func NewPredParser(s string) *PredParser

func (*PredParser) Constant

func (p *PredParser) Constant()

func (*PredParser) Expression

func (p *PredParser) Expression()

func (*PredParser) Field

func (p *PredParser) Field() string

func (*PredParser) Predicate

func (p *PredParser) Predicate()

func (*PredParser) Term

func (p *PredParser) Term()

type QueryData

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

QueryData holds data for the SQL select statement.

func NewQueryData

func NewQueryData(fields []string, tables []string, pred *query.Predicate) *QueryData

NewQueryData creates a new QueryData instance.

func (*QueryData) Fields

func (q *QueryData) Fields() []string

Fields returns the fields mentioned in the select clause.

func (*QueryData) Pred

func (q *QueryData) Pred() *query.Predicate

Pred returns the predicate that describes which records should be in the output table.

func (*QueryData) String

func (q *QueryData) String() string

String returns the string representation of the QueryData.

func (*QueryData) Tables

func (q *QueryData) Tables() []string

Tables returns the tables mentioned in the from clause.

type TokenType

type TokenType int
const (
	EOF TokenType = iota
	Word
	Number
	Other
)

Jump to

Keyboard shortcuts

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