package ast

Import Path
	github.com/pancsta/gochickpeas/gql/internal/ast (on go.dev)

Dependency Relation
	imports 3 packages, and imported by 2 packages

Involved Source Files Package ast is the language-neutral query AST: produced by the GQL parser (gql/internal/parser), consumed by desugar/bind/plan. Port of the Rust cypher crate's ast.rs -- the shapes below the parser deliberately keep the Rust engine's segment model (a query is reading clauses plus projection boundaries ending in a final projection), so GQL's RETURN...NEXT / LET / FILTER forms all normalize into the same With clause the Rust binder and planner consume. Expression AST nodes: the Expr interface, its node structs, operators, and parsed literals. Split from ast.go to keep files under the repo size norm. Fingerprint renders a query AST to a canonical string: two ASTs render identically iff they are structurally identical (every node emits a type tag with delimited fields, strings are quoted), so the rendering is safe as a plan-cache template key -- the Go analogue of the Rust engine keying its L2 on the template AST's debug rendering. The shared expression walker: desugar, the binder, and autoparam all traverse expressions with it (including the pattern-carrying subquery nodes' inner WHERE/projection expressions).
Package-Level Type Names (total 63)
/* sort by: | */
Binary is an infix operator application. LHS Expr Op BinOp RHS Expr *Binary : Expr
BinOp is an infix operator. const OpAdd const OpAnd const OpConcat const OpContains const OpDiv const OpEndsWith const OpEq const OpGt const OpGte const OpLt const OpLte const OpMul const OpNeq const OpOr const OpStartsWith const OpSub const OpXor const github.com/pancsta/gochickpeas/gql/gqlparser.OpAdd const github.com/pancsta/gochickpeas/gql/gqlparser.OpAnd const github.com/pancsta/gochickpeas/gql/gqlparser.OpConcat const github.com/pancsta/gochickpeas/gql/gqlparser.OpContains const github.com/pancsta/gochickpeas/gql/gqlparser.OpDiv const github.com/pancsta/gochickpeas/gql/gqlparser.OpEndsWith const github.com/pancsta/gochickpeas/gql/gqlparser.OpEq const github.com/pancsta/gochickpeas/gql/gqlparser.OpGt const github.com/pancsta/gochickpeas/gql/gqlparser.OpGte const github.com/pancsta/gochickpeas/gql/gqlparser.OpLt const github.com/pancsta/gochickpeas/gql/gqlparser.OpLte const github.com/pancsta/gochickpeas/gql/gqlparser.OpMul const github.com/pancsta/gochickpeas/gql/gqlparser.OpNeq const github.com/pancsta/gochickpeas/gql/gqlparser.OpOr const github.com/pancsta/gochickpeas/gql/gqlparser.OpStartsWith const github.com/pancsta/gochickpeas/gql/gqlparser.OpSub const github.com/pancsta/gochickpeas/gql/gqlparser.OpXor
CallProc is CALL proc(args...) YIELD field [AS alias], ... -- runs an analytic procedure and produces one row per result with the yielded columns bound. Args are general expressions: constant ones resolve at plan time, others evaluate per input row (a correlated call). Args []Expr Proc string Yields []YieldItem *CallProc : Clause
CallSubquery is CALL [(vars...)] { subquery }: a clause-level correlated subquery (lateral join). Imports is the variable-scope list -- the outer variables visible inside; empty means uncorrelated (runs once, cross-joins every outer row). The body query keeps a leading importing With as its first clause (the shape the binder expects). Imports []string Query Query *CallSubquery : Clause
Case is CASE [operand] WHEN...THEN... [ELSE default] END. A non-nil Operand is the simple form (each cond compares to the operand); otherwise the searched form (each cond is a boolean). // nil when absent // nil for the searched form Whens []CaseWhen *Case : Expr
CaseWhen is one WHEN cond THEN result arm. Cond Expr Result Expr
Clause is a clause appearing before a part's final projection. *CallProc *CallSubquery *Match *PathBind *ShortestPath *Unwind *With
Cost is the weighted shortest-path cost between two bound endpoints (engine node; no GQL surface syntax -- reachable via CALL procedures). Dir Dir From string To string Types []string Weight CostSpec *Cost : Expr
CostKind discriminates a CostSpec. const CostConstant const CostExpr const CostProperty const github.com/pancsta/gochickpeas/gql/gqlparser.CostConstant const github.com/pancsta/gochickpeas/gql/gqlparser.CostExpr const github.com/pancsta/gochickpeas/gql/gqlparser.CostProperty
CostSpec is a weighted-path weight specification. Const float64 Expr Expr Kind CostKind Prop string
CountSub is COUNT { MATCH pattern [WHERE expr] }: how many times the correlated inner pattern matches the current row. Pattern *Pattern // nil when absent *CountSub : Expr
Dir is a relationship direction as written in the pattern. Flipped is the direction seen when traversing the other way. func Dir.Flipped() Dir const DirBoth const DirIn const DirOut const github.com/pancsta/gochickpeas/gql/gqlparser.DirBoth const github.com/pancsta/gochickpeas/gql/gqlparser.DirIn const github.com/pancsta/gochickpeas/gql/gqlparser.DirOut
Exists is EXISTS { MATCH pattern [WHERE expr] }: true if the (possibly correlated) inner pattern matches at least once for the current row. Pattern *Pattern // nil when absent *Exists : Expr
Expr is one expression node. *Binary *Case *Cost *CountSub *Exists *Func *HasLabelExpr *In *Index *IsNull *IsTruth *IsTyped *ListComp *ListExpr *ListPred *Lit *MapLit *MapProj *PatternComp *Prop *PropOf *Reduce *Slice *Unary *Var func Walk(e Expr, f func(Expr) bool)
Func is a function call; Star is count(*), Distinct is count(DISTINCT x). Args []Expr Distinct bool Name string Star bool *Func : Expr
HasLabelExpr tests a LabelExpr against the node bound to Var -- built from the surface label predicate (n:Label) and by the planner lowering a node pattern's general label expression. Expr *LabelExpr Var string *HasLabelExpr : Expr
In is `expr IN list`. Expr Expr List Expr *In : Expr
Index is base[index] (0-based; negative counts from the end; out of range yields null). Base Expr Idx Expr *Index : Expr
IsNull is the postfix null test; Negated is the IS NOT NULL form. Expr Expr Negated bool *IsNull : Expr
IsTruth is the postfix truth-value test `x IS [NOT] TRUE|FALSE`: IS TRUE is true iff x is the boolean true (null and non-booleans read false); IS FALSE iff x is the boolean false. NOT negates the whole test. (IS UNKNOWN parses to IsNull -- unknown IS the null truth value.) Expr Expr Negated bool Want bool *IsTruth : Expr
IsTyped is `x IS [NOT] TYPED <type>`: a runtime value-kind test. Expr Expr // normalized lowercase: integer, float, string, boolean, list, node, relationship Negated bool *IsTyped : Expr
LabelExpr is a boolean label expression tree: label tests combined with & (and), | (or), ! (not), and parentheses. Kind LabelKind L *LabelExpr // LabelName only R *LabelExpr
LabelKind discriminates a LabelExpr node. const LabelAnd const LabelName const LabelNot const LabelOr const LabelWild const github.com/pancsta/gochickpeas/gql/gqlparser.LabelAnd const github.com/pancsta/gochickpeas/gql/gqlparser.LabelName const github.com/pancsta/gochickpeas/gql/gqlparser.LabelNot const github.com/pancsta/gochickpeas/gql/gqlparser.LabelOr const github.com/pancsta/gochickpeas/gql/gqlparser.LabelWild
ListComp is [x IN list WHERE filter | map] (engine node; no GQL surface syntax yet). // nil when absent List Expr // nil when absent Var string *ListComp : Expr
ListExpr is a list literal. Elems []Expr *ListExpr : Expr
ListPred is a list-predicate quantifier: all(x IN list WHERE pred) and the any/none/single forms. List Expr Pred Expr Quant Quant Var string *ListPred : Expr
Lit is a literal constant. Value Literal *Lit : Expr
Literal is a parsed constant (distinct from a runtime value). B bool F float64 I int64 Kind LitKind // LitParam slot // LitStr text or LitNamedParam name func BoolLit(b bool) Literal func FloatLit(v float64) Literal func IntLit(v int64) Literal func NamedParamLit(name string) Literal func NullLit() Literal func ParamLit(slot uint32) Literal func StrLit(s string) Literal
LitKind discriminates a Literal. const LitBool const LitFloat const LitInt const LitNamedParam const LitNull const LitParam const LitStr const github.com/pancsta/gochickpeas/gql/gqlparser.LitBool const github.com/pancsta/gochickpeas/gql/gqlparser.LitFloat const github.com/pancsta/gochickpeas/gql/gqlparser.LitInt const github.com/pancsta/gochickpeas/gql/gqlparser.LitNamedParam const github.com/pancsta/gochickpeas/gql/gqlparser.LitNull const github.com/pancsta/gochickpeas/gql/gqlparser.LitParam const github.com/pancsta/gochickpeas/gql/gqlparser.LitStr
MapField is one key/value of a MapLit, in written order. Key string Val Expr
MapLit is a map literal {key: expr, ...} in expression position; values are arbitrary expressions (unlike a pattern's inline property map). Fields []MapField *MapLit : Expr
MapProj is a map projection var{.key, alias: expr, .*} (engine node; no GQL surface syntax yet). Entries []MapProjEntry Var string *MapProj : Expr
MapProjEntry is one entry of a MapProj. // MapProjField only Key string Kind MapProjEntryKind
MapProjEntryKind discriminates a map-projection entry. const MapProjAll const MapProjField const MapProjProp const github.com/pancsta/gochickpeas/gql/gqlparser.MapProjAll const github.com/pancsta/gochickpeas/gql/gqlparser.MapProjField const github.com/pancsta/gochickpeas/gql/gqlparser.MapProjProp
Match is [OPTIONAL] MATCH pattern[, pattern...] [WHERE expr]. Comma-separated patterns bind sequentially (sharing variables). When Optional, a row with no match survives with the new variables null. Acyclic is the ACYCLIC path-mode prefix: no repeated node within each quantified segment. TRAIL needs no flag -- it is the engine's native traversal semantics. Optional bool Patterns []Pattern Repeatable is the REPEATABLE ELEMENTS match mode: relationship uniqueness is NOT enforced within the clause (walk semantics). DIFFERENT EDGES needs no flag -- it is the engine default. // nil when absent *Match : Clause
NodePat is one node pattern. LabelExpr is a general boolean label expression -- non-nil only when not a plain conjunction (then Labels is empty). The planner lowers it to a per-node HasLabelExpr WHERE conjunct. Labels is the conjunctive (AND) label list -- the common case. When the label expression is a plain conjunction it is flattened here and LabelExpr stays nil, keeping the planner/kernel fast paths. PropExprs are non-literal inline property values ({name: tagVar}). The desugar pass lowers each to a WHERE equality before planning. Props are literal/param inline property values ({id: 669}, {name: $p}) -- the fast seek/filter path. // "" when anonymous Where is the element pattern's inline predicate ((v:L WHERE expr)); the desugar pass conjoins it onto the clause WHERE. func (*Pattern).EndNode() *NodePat
PathBind is [OPTIONAL] MATCH p = (a)-[...]->(b): bind the named path over a general pattern (distinct from the path-search form). Acyclic is the ACYCLIC path-mode prefix (see Match.Acyclic). Optional bool PathVar string Pattern Pattern // nil when absent *PathBind : Clause
Pattern is a linear path pattern: a start node followed by zero or more (rel, node) hops. Hops []PatternHop Start NodePat EndNode is the node at the far end of the path (the start if no hops). Reversed is the same path written end-to-start: the last node becomes the start and every relationship direction flips. Used by the planner to anchor traversal on the bound (selective) endpoint. func (*Pattern).Reversed() Pattern
PatternComp is [ (pattern) [WHERE filter] | proj ] (engine node; no GQL surface syntax yet). Pattern *Pattern Proj Expr // nil when absent *PatternComp : Expr
PatternHop is one relationship step and the node it reaches. Node NodePat Rel RelPat
Projection is a projection body (With / final RETURN): items, DISTINCT, and the ordering / pagination applied to the projected rows. Distinct bool Items []ReturnItem // nil when absent OrderBy []SortItem // OFFSET/SKIP; nil when absent Star means `*` was written: all in-scope variables project ahead of any explicit Items, expanded by the binder in introduction order.
Prop is a property access on a variable, e.g. f.name. Key string Var string *Prop : Expr
PropEntry is one literal inline property. Key string Val Literal
PropExprEntry is one expression-valued inline property. Key string Val Expr
PropOf is property access on an arbitrary expression (rels(e)[i].ts); the common ident.key parses as Prop. Base Expr Key string *PropOf : Expr
Quant is the list-predicate quantifier of a ListPred. const QuantAll const QuantAny const QuantNone const QuantSingle const github.com/pancsta/gochickpeas/gql/gqlparser.QuantAll const github.com/pancsta/gochickpeas/gql/gqlparser.QuantAny const github.com/pancsta/gochickpeas/gql/gqlparser.QuantNone const github.com/pancsta/gochickpeas/gql/gqlparser.QuantSingle
Query is a whole read-only query: one or more QueryPart branches combined by UNION / UNION ALL. len(Union) == len(Parts)-1. Mode QueryMode Parts []QueryPart Union []UnionKind func github.com/pancsta/gochickpeas/gql/internal/parser.Parse(src string) (*Query, error) func Fingerprint(q *Query) string
QueryMode says how a query runs: normally, or as EXPLAIN (plan only) / PROFILE (plan annotated with actual per-operator row counts). const Explain const Profile const Run const github.com/pancsta/gochickpeas/gql/gqlparser.Explain const github.com/pancsta/gochickpeas/gql/gqlparser.Profile const github.com/pancsta/gochickpeas/gql/gqlparser.Run
QueryPart is one UNION branch: zero or more reading / projection-boundary clauses, then the final projection. Clauses []Clause Ret Projection
Reduce is reduce(acc = init, x IN list | body): left-fold a list (engine node; no GQL surface syntax yet). Acc string Body Expr Init Expr List Expr Var string *Reduce : Expr
RelPat is one relationship pattern. Dir Dir Length is non-nil for a quantified relationship (-[:T]->{1,3}, *, +); nil is a single fixed hop. PropExprs []PropExprEntry Props []PropEntry Types []string // "" when anonymous Where is the element pattern's inline predicate ([r:T WHERE expr]); the desugar pass conjoins it onto the clause WHERE.
ReturnItem is one projected expression with an optional alias. // "" when absent Expr Expr
ShortestPath is a path-search binding: GQL `MATCH p = ANY SHORTEST pat` (All false) / `ALL SHORTEST pat` (All true), optionally weighted via the COST clause. Binds PathVar between already-bound endpoints. All bool Optional bool PathVar string Pattern Pattern // nil for hop-minimal // nil when absent *ShortestPath : Clause
Slice is base[from..to]; either bound may be nil; negative bounds count from the end. Base Expr // nil when omitted // nil when omitted *Slice : Expr
SortItem is one ORDER BY key. Desc bool Expr Expr
Unary is a prefix operator application. Expr Expr Op UnOp *Unary : Expr
UnionKind says how two adjacent QueryParts combine. const UnionAll const UnionDistinct const UnionExcept const UnionIntersect const github.com/pancsta/gochickpeas/gql/gqlparser.UnionAll const github.com/pancsta/gochickpeas/gql/gqlparser.UnionDistinct const github.com/pancsta/gochickpeas/gql/gqlparser.UnionExcept const github.com/pancsta/gochickpeas/gql/gqlparser.UnionIntersect
UnOp is a prefix operator. const Neg const Not const github.com/pancsta/gochickpeas/gql/gqlparser.Neg const github.com/pancsta/gochickpeas/gql/gqlparser.Not
Unwind is GQL `FOR var IN expr`: expand a list to rows -- for each input row, emit one output row per element with var bound to it. An empty list or null emits no rows for that input row. Expr Expr Var string *Unwind : Clause
Var is a bare variable reference. Name string *Var : Expr
VarLength is a quantifier's bound spec. Nil bounds mean unspecified (`*` => both nil; `{2,}` => Max nil; `{,3}` => Min nil; `{2}` => Min == Max). Max *uint64 Min *uint64
With is the projection boundary: project columns forward, then optionally filter the projected rows. GQL surface forms that lower here: RETURN...NEXT (the projection), LET (star + extra items), FILTER (star + where). Proj Projection // nil when absent *With : Clause
YieldItem is one YIELD field with an optional alias. // "" when absent Field string
Package-Level Functions (total 9)
BoolLit is a boolean literal.
Fingerprint is the canonical rendering of q.
FloatLit is a float literal.
IntLit is an integer literal.
NamedParamLit is a $name parameter.
NullLit is the null literal.
ParamLit is an auto-lifted parameter slot.
StrLit is a string literal.
Walk visits e and every sub-expression in pre-order. Returning false from f skips the node's children (the node itself was already visited). Pattern-carrying nodes (Exists/CountSub/PatternComp) descend into their inner WHERE / projection expressions and the patterns' inline property expressions, so a pass that rewrites literals or checks references sees every expression a query evaluates.
Package-Level Constants (total 51)
CostConstant gives every traversed relationship a fixed weight.
CostExpr evaluates a per-edge weight formula referencing only the path's relationship variable.
CostProperty reads the named relationship property as the edge weight.
DirBoth is -[...]-.
DirIn is <-[...]-.
DirOut is -[...]->.
Explain renders the plan without executing.
LabelAnd is `a & b`.
LabelName is a single label test.
LabelNot is `!a` (operand in L).
LabelOr is `a | b`.
LabelWild is `%`: the node carries at least one label.
LitBool is a boolean literal.
LitFloat is a float literal.
LitInt is an integer literal.
LitNamedParam is an explicit $name parameter.
LitNull is null.
LitParam is an auto-lifted parameter slot -- never produced by the parser; the autoparam pass replaces constants so queries differing only in a constant share one cached plan.
LitStr is a string literal.
MapProjAll is .* (all properties).
MapProjField is name: expr.
MapProjProp is .key.
Neg is arithmetic negation.
Not is boolean negation.
OpAdd is +.
OpAnd is AND.
OpConcat is || -- string/list concatenation only (null otherwise; unlike +, it never adds numbers).
OpContains is CONTAINS.
OpDiv is /.
OpEndsWith is ENDS WITH.
OpEq is =.
OpGt is >.
OpGte is >=.
OpLt is <.
OpLte is <=.
OpMul is *.
OpNeq is <>.
OpOr is OR.
OpStartsWith is STARTS WITH (comparison precedence).
OpSub is -.
OpXor is XOR (three-valued: null when either side is null).
Profile executes and annotates the plan with row counts.
QuantAll is all(...).
QuantAny is any(...).
QuantNone is none(...).
QuantSingle is single(...).
Run executes normally.
UnionAll is UNION ALL: combine branches keeping every row.
UnionDistinct is UNION: combine branches, removing duplicate rows.
UnionExcept is EXCEPT: rows of the left side (deduplicated) not present in the right side.
UnionIntersect is INTERSECT: rows (deduplicated) present on both sides.