ast

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ast defines the cirql abstract syntax tree: the typed pipeline, stages, and expressions a parsed query produces. Nodes are pure data; the closed Stage and Expr sets are enforced by unexported tag methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinOp

type BinOp string

BinOp names a binary operator.

const (
	// OpOr is logical ||.
	OpOr BinOp = "||"
	// OpAnd is logical &&.
	OpAnd BinOp = "&&"
	// OpEq is ==.
	OpEq BinOp = "=="
	// OpNe is !=.
	OpNe BinOp = "!="
	// OpGt is >.
	OpGt BinOp = ">"
	// OpLt is <.
	OpLt BinOp = "<"
	// OpGe is >=.
	OpGe BinOp = ">="
	// OpLe is <=.
	OpLe BinOp = "<="
	// OpAdd is +.
	OpAdd BinOp = "+"
	// OpSub is -.
	OpSub BinOp = "-"
	// OpMul is *.
	OpMul BinOp = "*"
	// OpDiv is /.
	OpDiv BinOp = "/"
	// OpMod is %.
	OpMod BinOp = "%"
)

type BinaryExpr

type BinaryExpr struct {
	L  Expr
	R  Expr
	Op BinOp
}

BinaryExpr is L Op R.

type Expr

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

Expr is an expression evaluated against the current object. Closed via isExpr.

type FieldAccess

type FieldAccess struct{ Path []PathSegment }

FieldAccess is .a.b[] etc.; an empty Path is the identity ".".

type FileStage

type FileStage struct{ Path string }

FileStage reads JSON from a local file.

type FilterStage

type FilterStage struct{ Cond Expr }

FilterStage keeps objects for which Cond is truthy.

type FlatMapStage

type FlatMapStage struct{ Mappings []Mapping }

FlatMapStage transforms and flattens: list-valued mappings expand into multiple output objects.

type FuncCall

type FuncCall struct {
	Name string
	Args []Expr
}

FuncCall is name(args...).

type HTTPStage

type HTTPStage struct{ URL Expr }

HTTPStage fetches JSON over HTTP.

type LimitStage

type LimitStage struct{ N int }

LimitStage truncates the result set to at most N objects.

type Literal

type Literal struct{ V value.Value }

Literal is a constant value.

type MapStage

type MapStage struct{ Mappings []Mapping }

MapStage transforms each object 1:1 into a new object.

type Mapping

type Mapping struct {
	Expr Expr
	Key  string
}

Mapping is a key/expression pair in a map or flatMap stage.

type PathSegment

type PathSegment struct {
	Name   string
	IsIter bool
}

PathSegment is one step of a field access: a named field, or [] iteration.

type Pipeline

type Pipeline struct {
	Stages []Stage
}

Pipeline is a parsed cirql query: an ordered list of stages.

type QueryStage

type QueryStage struct{ Body string }

QueryStage executes a GraphQL query.

type ReduceOp

type ReduceOp string

ReduceOp names an aggregation in a reduce stage.

const (
	// OpCount counts the result set.
	OpCount ReduceOp = "count"
	// OpSum sums the argument expression over the result set.
	OpSum ReduceOp = "sum"
	// OpMin takes the minimum of the argument expression.
	OpMin ReduceOp = "min"
	// OpMax takes the maximum of the argument expression.
	OpMax ReduceOp = "max"
	// OpAvg averages the argument expression.
	OpAvg ReduceOp = "avg"
	// OpFirst returns the first object.
	OpFirst ReduceOp = "first"
	// OpLast returns the last object.
	OpLast ReduceOp = "last"
	// OpGroupBy groups objects by the argument expression.
	OpGroupBy ReduceOp = "group_by"
	// OpCollect collects the argument expression from each object into a list.
	OpCollect ReduceOp = "collect"
)

type ReduceStage

type ReduceStage struct {
	Arg Expr
	Op  ReduceOp
}

ReduceStage aggregates the result set into a single object.

type SortStage

type SortStage struct {
	Key    Expr
	IsDesc bool
}

SortStage reorders the result set by Key.

type Stage

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

Stage is one step in a pipeline. The set is closed via isStage.

type StdinStage

type StdinStage struct{}

StdinStage reads the pipeline input as the result set.

type UnOp

type UnOp string

UnOp names a unary operator.

const (
	// OpNot is logical negation.
	OpNot UnOp = "!"
	// OpNeg is arithmetic negation (unary minus).
	OpNeg UnOp = "-"
)

type UnaryExpr

type UnaryExpr struct {
	X  Expr
	Op UnOp
}

UnaryExpr is Op X.

type UniqStage

type UniqStage struct{ Key Expr }

UniqStage deduplicates the result set, by Key when non-nil else whole-object.

type VarRef

type VarRef struct{ Name string }

VarRef is a $name reference.

Jump to

Keyboard shortcuts

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