parsing

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ASTEmpty astNodeType = iota
	ASTArithmeticExpression
	ASTArithmeticUnaryExpression
	ASTComparator
	ASTCurrentNode
	ASTRootNode
	ASTExpRef
	ASTFunctionExpression
	ASTField
	ASTFilterProjection
	ASTFlatten
	ASTIdentity
	ASTIndex
	ASTIndexExpression
	ASTKeyValPair
	ASTLiteral
	ASTMultiSelectHash
	ASTMultiSelectList
	ASTOrExpression
	ASTAndExpression
	ASTNotExpression
	ASTPipe
	ASTProjection
	ASTSubexpression
	ASTSlice
	ASTValueProjection
	ASTLetExpression
	ASTVariable
	ASTBindings
	ASTBinding
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTNode

type ASTNode struct {
	NodeType astNodeType
	Value    interface{}
	Children []ASTNode
}

ASTNode represents the abstract syntax tree of a JMESPath expression.

func (ASTNode) PrettyPrint

func (node ASTNode) PrettyPrint(indent int) string

PrettyPrint will pretty print the parsed AST. The AST is an implementation detail and this pretty print function is provided as a convenience method to help with debugging. You should not rely on its output as the internal structure of the AST may change at any time.

func (ASTNode) String

func (node ASTNode) String() string

type Lexer

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

Lexer contains information about the expression being tokenized.

func NewLexer

func NewLexer() *Lexer

NewLexer creates a new JMESPath lexer.

func (*Lexer) Tokenize

func (lexer *Lexer) Tokenize(expression string) ([]token, error)

tokenize takes an expression and returns corresponding tokens.

type Parser

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

Parser holds state about the current expression being parsed.

func NewParser

func NewParser() *Parser

NewParser creates a new JMESPath parser.

func (*Parser) Parse

func (p *Parser) Parse(expression string) (ASTNode, error)

Parse will compile a JMESPath expression.

type SyntaxError

type SyntaxError struct {
	Expression string // Expression that generated a SyntaxError
	Offset     int    // The location in the string where the error occurred
	// contains filtered or unexported fields
}

SyntaxError is the main error used whenever a lexing or parsing error occurs.

func (SyntaxError) Error

func (e SyntaxError) Error() string

func (SyntaxError) HighlightLocation

func (e SyntaxError) HighlightLocation() string

HighlightLocation will show where the syntax error occurred. It will place a "^" character on a line below the expression at the point where the syntax error occurred.

type TokType

type TokType int
const (
	TOKUnknown TokType = iota
	TOKStar
	TOKDot
	TOKFilter
	TOKFlatten
	TOKLparen
	TOKRparen
	TOKLbracket
	TOKRbracket
	TOKLbrace
	TOKRbrace
	TOKOr
	TOKPipe
	TOKNumber
	TOKUnquotedIdentifier
	TOKQuotedIdentifier
	TOKComma
	TOKColon
	TOKPlus
	TOKMinus
	TOKMultiply
	TOKDivide
	TOKModulo
	TOKDiv
	TOKLT
	TOKLTE
	TOKGT
	TOKGTE
	TOKEQ
	TOKNE
	TOKJSONLiteral
	TOKStringLiteral
	TOKCurrent
	TOKRoot
	TOKExpref
	TOKAnd
	TOKNot
	TOKVarref
	TOKAssign
	TOKEOF
)

func (TokType) String

func (i TokType) String() string

Jump to

Keyboard shortcuts

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