parser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 11 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 ParsePath

func ParsePath(s string) (document.Path, error)

ParsePath parses a path to a value in a document.

func ParseQuery

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

ParseQuery parses a query string and returns its AST representation.

Types

type Options

type Options struct {
	// A map of builtin SQL functions.
	Functions expr.Functions
}

Options of the SQL parser.

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 Genji SQL Parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func NewParserWithOptions

func NewParserWithOptions(r io.Reader, opts *Options) *Parser

NewParserWithOptions returns a new instance of Parser using given Options.

func (*Parser) ParseDocument

func (p *Parser) ParseDocument() (*expr.KVPairs, error)

ParseDocument parses a document

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 Genji SQL string and returns a Query.

func (*Parser) ParseStatement

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

ParseStatement parses a Genji SQL string and returns a Statement AST object.

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