syntax

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package syntax implements the immutable JSONata syntax tree and parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lex

func Lex(source string) ([]Token, *ParseError)

func Parse

func Parse(source string) (Node, *ParseError)

Types

type Apply

type Apply struct {
	Left, Right Node
	Pos         Position
}

type Array

type Array struct {
	Items         []Node
	Pos           Position
	FlattenInPath bool
}

type Binary

type Binary struct {
	Op          string
	Left, Right Node
	Pos         Position
}

type Bind

type Bind struct {
	Variable Variable
	Value    Node
	Pos      Position
}

type Block

type Block struct {
	Expressions []Node
	Pos         Position
}

type Call

type Call struct {
	Function         Node
	Args             []Node
	Partial          bool
	ProcedureGrouped bool
	Pos              Position
}

type Lambda

type Lambda struct {
	Params    []Variable
	Signature string
	Body      Node
	Pos       Position
}

type Lexer

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

type Literal

type Literal struct {
	Kind         TokenKind
	Value        any
	Pos          Position
	NumberValue  float64
	NumberParsed bool
	RegexValue   jsonregex.Pattern
	RegexParsed  bool
}

type Name

type Name struct {
	Value string
	Pos   Position
}

type Node

type Node interface {
	// contains filtered or unexported methods
}

type Object

type Object struct {
	Pairs []Pair
	Pos   Position
}

type Pair

type Pair struct {
	Key     string
	KeyExpr Node
	Value   Node
	Pos     Position
}

type Parent

type Parent struct{ Pos Position }

type ParseError

type ParseError struct {
	Code, Token, Value, Message string
	Position                    int
}

func (*ParseError) Error

func (e *ParseError) Error() string

type Parser

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

type Path

type Path struct {
	Base   Node
	Fields []Name
	Pos    Position
}

type Placeholder

type Placeholder struct{ Pos Position }

type Position

type Position struct{ Offset, Byte, Line, Column int }

type Selector

type Selector struct {
	Base, Index Node
	Pos         Position
}

type Token

type Token struct {
	Kind    TokenKind
	Text    string
	Pos     Position
	Literal any
	// The number value is stored inline because boxing a float64 in Literal
	// adds an allocation to every numeric token. Regex products use Literal
	// below because their representation is substantially larger.
	NumberValue  float64
	NumberParsed bool
}

type TokenKind

type TokenKind uint8
const (
	EOF TokenKind = iota
	Identifier
	String
	Number
	Regex
	True
	False
	Null
	Operator
	LBracket
	RBracket
	LBrace
	RBrace
	LParen
	RParen
	Comma
	Colon
	Semicolon
	Dollar
	Invalid
)

type Transform

type Transform struct {
	Path, Update, Delete Node
	Pos                  Position
}

type UTF16String

type UTF16String struct {
	Units []uint16
}

UTF16String retains a JSONata string literal containing an unpaired UTF-16 surrogate. Go strings cannot represent that value without information loss. The evaluator must reject it before the public value boundary.

type Unary

type Unary struct {
	Op   string
	Expr Node
	Pos  Position
}

type Variable

type Variable struct {
	Name string
	Kind VariableKind
	Pos  Position
}

type VariableKind

type VariableKind uint8
const (
	VariableNamed VariableKind = iota
	VariableFocus
	VariableRoot
)

type Wildcard

type Wildcard struct {
	Recursive bool
	Pos       Position
}

Jump to

Keyboard shortcuts

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