parser

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parser provides a Parser struct that parses lexer tokens from the tq query into an AST.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueryElement indicates an unprocessable query filter element.
	ErrQueryElement = errors.New("failed to parse query filter element")

	// ErrSelectorUnterminated indicates an unterminated selector element.
	ErrSelectorUnterminated = errors.New("expected ']' to terminate selector")

	// ErrParserBufferOutOfRange indicates the end of the parser buffer has
	// been reached.
	ErrParserBufferOutOfRange = errors.New("reached the end of the buffer")
)

Functions

This section is empty.

Types

type Error

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

Error wraps a concrete parser error to represent its context. It reports the token where the error has occurred.

func (*Error) Error

func (e *Error) Error() string

Error reports the parser error wrapped inside of the custom context.

func (*Error) Is

func (e *Error) Is(target error) bool

Is allows to check if Error.err matches the target error.

type Parser

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

Parser encapsulates the logic of parsing tq queries into valid expressions.

func New

func New(l *lexer.Lexer) (*Parser, error)

New returns a new Parser with the buffer populated with lexer tokens read from the Lexer l.

func (*Parser) Parse

func (p *Parser) Parse() (*ast.Root, error)

Parse the abstract syntax tree given the buffer of tq lexer tokens.

Jump to

Keyboard shortcuts

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