parser

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustParseExpr

func MustParseExpr(s string) expr.Expr

MustParseExpr calls ParseExpr and panics if it returns an error.

func ParseExpr

func ParseExpr(s string) (expr.Expr, error)

ParseExpr parses an expression.

func ParseQuery

func ParseQuery(s string) (query.Query, error)

ParseQuery parses a query string and returns its AST representation.

Types

type ParseError

type ParseError struct {
	Message  string
	Found    string
	Expected []string
	Pos      scanner.Pos
}

ParseError represents an error that occurred during parsing.

func (*ParseError) Error

func (e *ParseError) Error() string

Error returns the string representation of the error.

type Parser

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

Parser represents an Chai SQL Parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Parse

func (p *Parser) Parse(fn func(statement.Statement) error) error

ParseQuery parses a Chai SQL string and returns a Query.

func (*Parser) ParseExpr

func (p *Parser) ParseExpr() (e expr.Expr, err error)

ParseExpr parses an expression.

func (*Parser) ParseQuery

func (p *Parser) ParseQuery() (query.Query, error)

ParseQuery parses a Chai SQL string and returns a Query.

func (*Parser) ParseStatement

func (p *Parser) ParseStatement() (statement.Statement, error)

ParseStatement parses a Chai SQL string and returns a statement.

func (*Parser) ParseTokens added in v0.17.0

func (p *Parser) ParseTokens(tokens ...scanner.Token) error

ParseTokens parses all the given tokens one after the other. It returns an error if one of the token is missing.

func (*Parser) Scan

func (p *Parser) Scan() (tok scanner.Token, pos scanner.Pos, lit string)

Scan returns the next token from the underlying scanner.

func (*Parser) ScanIgnoreWhitespace

func (p *Parser) ScanIgnoreWhitespace() (tok scanner.Token, pos scanner.Pos, lit string)

ScanIgnoreWhitespace scans the next non-whitespace and non-comment token.

func (*Parser) Unscan

func (p *Parser) Unscan()

Unscan pushes the previously read token back onto the buffer.

Jump to

Keyboard shortcuts

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