parser

package
v0.0.0-...-65fd79d Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package parser implements a SQL parser with respect to the SQLite grammar. https://www.sqlite.org/lang.html

Index

Constants

View Source
const (
	ErrIncompleteStatement  = Error("incomplete statement")
	ErrPrematureEOF         = Error("unexpectedly reached EOF")
	ErrScanner              = Error("scanner")
	ErrUnexpectedToken      = Error("unexpected token")
	ErrUnknownToken         = Error("unknown token")
	ErrUnsupportedConstruct = Error("unsupported construct")
)

parser errors

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error string

Error allows constant errors.

func (Error) Error

func (s Error) Error() string

type Parser

type Parser interface {
	// Next returns stmt=<statement>, errs=nil, ok=true if a statement was
	// parsed successfully without any parse errors. If there were parse errors,
	// Next will return stmt=<statement>, errs=([]error), ok=true.
	//
	// stmt always is the statement that was parsed. If it could not be parsed
	// free of errors, the statement might be incomplete or incorrect, but
	// efforts will be taken to parse as much out of the given input as
	// possible. ok indicates whether any statement could have been parsed, or
	// more precisely, if the underlying scanner had any more tokens.
	//
	// If ok=false, that means that the parser has reached its EOF and no more
	// statements can be returned. Subsequent calls to Next will result in
	// stmt=nil, errs=nil, ok=false.
	Next() (stmt *ast.SQLStmt, errs []error, ok bool)
}

Parser describes a parser that returns (maybe multiple) SQLStatements from a given input.

func New

func New(input string) (Parser, error)

New creates a new, ready to use parser, that will parse the given input string.

func NewSimpleParser

func NewSimpleParser(input string) (Parser, error)

NewSimpleParser creates new ready to use parser.

Directories

Path Synopsis
Package ast implements an abstract syntax tree that represents SQL statements.
Package ast implements an abstract syntax tree that represents SQL statements.
Package scanner implements a tokenizer that creates tokens of the SQLite grammar.
Package scanner implements a tokenizer that creates tokens of the SQLite grammar.
matcher
Package matcher implements a matcher component, that can determine whether or not a rune is part of a custom character class.
Package matcher implements a matcher component, that can determine whether or not a rune is part of a custom character class.
ruleset
Package ruleset implements rules that can be used in combination with a rule based scanner.
Package ruleset implements rules that can be used in combination with a rule based scanner.
token
Package token implements tokens that are produced by the scanner.
Package token implements tokens that are produced by the scanner.

Jump to

Keyboard shortcuts

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