ast

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ast defines the Abstract Syntax Tree (AST) for openCypher 9.

Every production reachable in the read + write + DDL + procedure scope is represented here (FOREACH, CALL{}, and multi-graph syntax are excluded). The AST is the IR-input contract consumed by later compiler stages (semantic analysis, planning, execution).

All types embed a Position struct for source-location tracking; the fields are populated by the parser in a later task.

Concurrency: AST nodes are value types produced once by the parser and then treated as immutable. Concurrent reads are safe without external locking.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(q Query) string

Print returns the canonical Cypher representation of q.

The output is deterministic and differs from q.String() in one critical respect: string literals are emitted with double-quotes ("value") rather than single-quotes ('value'). This is required for the round-trip property (see package-level documentation): the grammar's CHAR_LITERAL rule matches only a single character in single-quotes, so multi-character values enclosed in single-quotes are lexed as identifiers rather than string literals. Double-quoted STRING_LITERAL has no such restriction.

All other formatting rules are inherited from the existing String() methods:

  • Keywords in UPPER CASE
  • Single-space token separators
  • Explicit parentheses around every binary and unary operator

Round-trip guarantee: for any Cypher query Q that github.com/FlavioCFOliveira/GoGraph/cypher/parser.Parse accepts, Parse(Print(Parse(Q))) produces an AST that is structurally equal to Parse(Q) when Position fields are ignored.

Example

ExamplePrint renders a parsed AST back to canonical Cypher source text. Print is the inverse-direction helper used by tooling and debug output.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/GoGraph/cypher/ast"
	"github.com/FlavioCFOliveira/GoGraph/cypher/parser"
)

func main() {
	q, err := parser.Parse("MATCH (n:Person) RETURN n.name")
	if err != nil {
		fmt.Println("error:", err)
		return
	}
	fmt.Println(ast.Print(q))
}
Output:
MATCH (n:Person) RETURN n.name

Types

type BinaryOp

type BinaryOp struct {
	Left     Expression
	Right    Expression
	Operator string // e.g. "+", "-", "=", "<>", "AND", "OR", "IN", "CONTAINS"
	Pos      Position
	EndPos   Position
	// Parenthesized records that this BinaryOp was explicitly parenthesized in
	// the source. The precedence-rebalancing pass in cypher/parser uses this
	// flag to suppress lifting list/string-predicate operators (IN, CONTAINS,
	// STARTS WITH, ENDS WITH) out of arithmetic chains when the user wrote the
	// parentheses explicitly: `[1] + (2 IN [3]) + 4` must remain `[1] +
	// bool + 4`, but `[1] + 2 IN [3] + 4` must rebalance to `([1] + 2) IN
	// ([3] + 4)`. The flag is cleared once the rebalance pass completes;
	// downstream consumers ignore it.
	Parenthesized bool
}

BinaryOp is a binary operator expression: left OP right.

func (*BinaryOp) String

func (b *BinaryOp) String() string

String returns the Cypher infix expression.

type BoolLiteral

type BoolLiteral struct {
	Pos    Position
	EndPos Position
	Value  bool
}

BoolLiteral is the literal true or false.

func (*BoolLiteral) String

func (n *BoolLiteral) String() string

String returns "true" or "false".

type Call

type Call struct {
	Where     *Where // nil when no WHERE predicate on YIELD
	Procedure string
	Namespace []string
	Args      []Expression // nil or empty means no argument list
	Yield     []*YieldItem // nil means no YIELD clause; empty slice means YIELD *
	Pos       Position
	EndPos    Position
}

Call is a CALL procedure clause.

CALL namespace.procedure(args) YIELD items WHERE predicate

func (*Call) String

func (c *Call) String() string

String returns the CALL clause.

type CaseAlternative

type CaseAlternative struct {
	Condition  Expression
	Consequent Expression
	Pos        Position
	EndPos     Position
}

CaseAlternative is a single WHEN … THEN … arm in a CASE expression.

func (*CaseAlternative) String

func (c *CaseAlternative) String() string

String returns the WHEN…THEN arm.

type CaseExpression

type CaseExpression struct {
	Subject      Expression // nil for generic CASE
	ElseExpr     Expression // nil when no ELSE clause
	Alternatives []*CaseAlternative
	Pos          Position
	EndPos       Position
}

CaseExpression is a CASE expression, either generic or value-form.

CASE [subject] WHEN … THEN … [ELSE …] END

func (*CaseExpression) String

func (c *CaseExpression) String() string

String returns the Cypher CASE expression.

type Clause

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

Clause is implemented by every top-level clause node.

type CountSubquery

type CountSubquery struct {
	Pattern *Pattern     // pattern form
	Query   *SingleQuery // full subquery form
	Pos     Position
	EndPos  Position
}

CountSubquery is a COUNT { … } subquery expression.

func (*CountSubquery) String

func (c *CountSubquery) String() string

String returns the Cypher COUNT subquery.

type Create

type Create struct {
	Pattern *Pattern
	Pos     Position
	EndPos  Position
}

Create is a CREATE clause.

func (*Create) String

func (c *Create) String() string

String returns the CREATE clause.

type Delete

type Delete struct {
	Expressions []Expression
	Pos         Position
	EndPos      Position
}

Delete is a DELETE clause.

func (*Delete) String

func (d *Delete) String() string

String returns the DELETE clause.

type DetachDelete

type DetachDelete struct {
	Expressions []Expression
	Pos         Position
	EndPos      Position
}

DetachDelete is a DETACH DELETE clause.

func (*DetachDelete) String

func (d *DetachDelete) String() string

String returns the DETACH DELETE clause.

type ExistsSubquery

type ExistsSubquery struct {
	Pattern *Pattern     // pattern form: EXISTS { (a)-[r]->(b) }
	Where   *Where       // optional inline WHERE clause for the pattern form
	Query   *SingleQuery // full subquery form: EXISTS { MATCH … RETURN … }
	Pos     Position
	EndPos  Position
}

ExistsSubquery is an EXISTS { … } subquery expression.

func (*ExistsSubquery) String

func (e *ExistsSubquery) String() string

String returns the Cypher EXISTS subquery.

type Expression

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

Expression is implemented by every AST node that can appear in an expression context (right-hand sides, WHERE predicates, RETURN items, etc.).

type FloatLiteral

type FloatLiteral struct {
	Pos    Position
	EndPos Position
	Value  float64
}

FloatLiteral is a floating-point literal value.

func (*FloatLiteral) String

func (n *FloatLiteral) String() string

String returns the decimal representation of the float. Always emits a fractional or exponent marker so the literal round-trips back to a float when re-parsed by downstream property-value parsers — strconv.FormatFloat drops the trailing ".0" for whole-number values like 10.0, but the downstream parser uses presence of "." or "eE" to discriminate float from integer literals.

type Foreach added in v0.9.0

type Foreach struct {
	Expr   Expression       // the list the loop iterates over
	Var    string           // the loop variable, scoped to Body
	Body   []UpdatingClause // updating clauses run per element
	Pos    Position
	EndPos Position
}

Foreach is a FOREACH clause: FOREACH (var IN expr | updatingClause+). For each element of the list the expression yields, the loop variable Var is bound to that element and every clause in Body is executed as a side-effect; FOREACH does not change the surrounding query's row cardinality.

func (*Foreach) String added in v0.9.0

func (f *Foreach) String() string

String returns the FOREACH clause.

type FunctionInvocation

type FunctionInvocation struct {
	Name      string
	Namespace []string // e.g. ["apoc", "path"] for apoc.path.expand
	Args      []Expression
	Pos       Position
	EndPos    Position
	Distinct  bool
	// CountStar is true when this is COUNT(*). String() renders it as
	// "count(*)" and downstream aggregation detects it without needing
	// a wildcard argument expression.
	CountStar bool
}

FunctionInvocation is a function call: func(args…) or func(DISTINCT args…).

func (*FunctionInvocation) String

func (f *FunctionInvocation) String() string

String returns the Cypher function call.

type IntLiteral

type IntLiteral struct {
	Pos    Position
	EndPos Position
	Value  int64
}

IntLiteral is an integer literal value.

func (*IntLiteral) String

func (n *IntLiteral) String() string

String returns the decimal representation of the integer.

type LabelPredicate

type LabelPredicate struct {
	Receiver Expression
	Labels   []string
	Pos      Position
	EndPos   Position
}

LabelPredicate is the conjunctive-label test on a node-valued expression: `n:Foo:Bar` evaluates to true when n is a node carrying every named label. The form appears both in WHERE filters and as a stand-alone projection (`RETURN (n:Foo)`). Receiver may be any expression; at evaluation time non-Node values yield NULL.

func (*LabelPredicate) String

func (l *LabelPredicate) String() string

String returns the Cypher predicate `(receiver:Label1:Label2)`. The parentheses match the canonical openCypher column-header form projected by `RETURN (n:Foo)`, so RETURN columns line up with the TCK comparison table.

type ListComprehension

type ListComprehension struct {
	Source     Expression
	Predicate  Expression // nil when no WHERE clause
	Projection Expression // nil when no projection expression
	Variable   string
	Pos        Position
	EndPos     Position
}

ListComprehension is a list comprehension: [var IN list WHERE pred | expr].

func (*ListComprehension) String

func (l *ListComprehension) String() string

String returns the Cypher list comprehension.

type ListLiteral

type ListLiteral struct {
	Elements []Expression
	Pos      Position
	EndPos   Position
}

ListLiteral is a bracketed list of expressions: [e1, e2, …].

func (*ListLiteral) String

func (n *ListLiteral) String() string

String returns the Cypher list literal.

type MapLiteral

type MapLiteral struct {
	Keys   []string
	Values []Expression
	Pos    Position
	EndPos Position
}

MapLiteral is a map expression: {key1: expr1, key2: expr2, …}.

func (*MapLiteral) String

func (n *MapLiteral) String() string

String returns the Cypher map literal.

type MapProjection

type MapProjection struct {
	Subject Expression
	Items   []*MapProjectionItem
	Pos     Position
	EndPos  Position
}

MapProjection is a map projection expression: n {.name, .age, extra: $x}.

The map-projection production lives in the ANTLR grammar (cypher/parser/grammar/CypherParser.g4, the mapProjection / mapProjectionItem rules); the parser visitor (github.com/FlavioCFOliveira/GoGraph/cypher/parser VisitMapProjection) constructs this node, which is then evaluated by (github.com/FlavioCFOliveira/GoGraph/cypher/expr evalMapProjection) and type-checked by the semantic analyser. Map projection is an accepted openCypher extension (CIP2014-12-12); it is NOT part of the openCypher TCK, so it does not affect TCK conformance.

func (*MapProjection) String

func (m *MapProjection) String() string

String returns the Cypher map projection.

type MapProjectionItem

type MapProjectionItem struct {
	Value  Expression // nil for the property-selector shorthand (`.key`)
	Key    string     // explicit key when present; otherwise empty
	Pos    Position
	EndPos Position
	IsAll  bool // true for the .*  selector
}

MapProjectionItem represents one item in a map projection.

func (*MapProjectionItem) String

func (m *MapProjectionItem) String() string

String returns the item representation.

type Match

type Match struct {
	Pattern *Pattern
	Where   *Where // nil when no WHERE predicate
	Pos     Position
	EndPos  Position
}

Match is a MATCH clause.

func (*Match) String

func (m *Match) String() string

String returns the MATCH clause.

type Merge

type Merge struct {
	Pattern  *PathPattern
	OnCreate []*SetItem // actions on ON CREATE SET
	OnMatch  []*SetItem // actions on ON MATCH SET
	Pos      Position
	EndPos   Position
}

Merge is a MERGE clause, with optional ON CREATE and ON MATCH actions.

func (*Merge) String

func (m *Merge) String() string

String returns the MERGE clause.

type MultiQuery

type MultiQuery struct {
	Parts  []*SingleQuery
	Pos    Position
	EndPos Position
	All    bool // true for UNION ALL; false for UNION (deduplicating)
}

MultiQuery is a UNION of SingleQuery nodes.

func (*MultiQuery) String

func (m *MultiQuery) String() string

String returns the Cypher UNION query.

type Node

type Node interface {
	String() string
	// contains filtered or unexported methods
}

Node is the root interface implemented by every AST node. String returns a canonical Cypher representation.

type NodePattern

type NodePattern struct {
	Properties Expression // nil or a MapLiteral / Parameter
	Variable   *string    // nil when anonymous
	Labels     []string   // zero or more labels
	Pos        Position
	EndPos     Position
}

NodePattern represents a node within a path pattern: (n:Label {prop: val}).

func (*NodePattern) String

func (n *NodePattern) String() string

String returns the Cypher node pattern.

type NullLiteral

type NullLiteral struct {
	Pos    Position
	EndPos Position
}

NullLiteral is the literal null.

func (*NullLiteral) String

func (n *NullLiteral) String() string

String returns "null".

type OptionalMatch

type OptionalMatch struct {
	Pattern *Pattern
	Where   *Where // nil when no WHERE predicate
	Pos     Position
	EndPos  Position
}

OptionalMatch is an OPTIONAL MATCH clause.

func (*OptionalMatch) String

func (o *OptionalMatch) String() string

String returns the OPTIONAL MATCH clause.

type OverflowIntLit added in v0.3.0

type OverflowIntLit struct {
	// Text holds the raw decimal digits including any leading sign character.
	Text   string
	Pos    Position
	EndPos Position
}

OverflowIntLit is a sentinel for decimal integer tokens that exceed the int64 range. In most expression contexts it becomes an IntegerOverflow compile error; in the special case where a fractional accessor follows (e.g. NNN.0 lexed as NNN + . + 0), visitPropertyExpression promotes it to a FloatLiteral instead.

func (*OverflowIntLit) String added in v0.3.0

func (o *OverflowIntLit) String() string

String returns the raw decimal text of the overflowing integer.

type Parameter

type Parameter struct {
	Name   string // the name/index without the leading '$'
	Pos    Position
	EndPos Position
}

Parameter is a query parameter: $name or $0.

func (*Parameter) String

func (p *Parameter) String() string

String returns the Cypher parameter reference.

type PathElement

type PathElement struct {
	Node         *NodePattern
	Relationship *RelationshipPattern // nil for the first node
	Next         *PathElement         // nil for the last node
}

PathElement is one alternating step in a path: node (rel node)*. It holds exactly one NodePattern followed by zero or more (rel, node) pairs.

type PathPattern

type PathPattern struct {
	Variable *string      // path variable, nil when absent
	Head     *PathElement // linked list of alternating node/rel steps
	Pos      Position
	EndPos   Position
	// Shortest classifies a shortestPath()/allShortestPaths() wrapper around
	// this path (ShortestNone for an ordinary path). Set by the parser's
	// post-AST shortest-path pass (rmp #1690).
	Shortest ShortestKind
}

PathPattern represents a single path within a pattern: (a)-[r]->(b)-[s]->(c).

func (*PathPattern) String

func (p *PathPattern) String() string

String returns the Cypher path pattern, re-wrapping a shortestPath / allShortestPaths pattern in its function form so the rendering round-trips.

type Pattern

type Pattern struct {
	Paths  []*PathPattern
	Pos    Position
	EndPos Position
}

Pattern represents the comma-separated list of path patterns in a MATCH or CREATE clause.

func (*Pattern) String

func (p *Pattern) String() string

String returns the comma-separated path patterns.

type PatternComprehension

type PatternComprehension struct {
	Predicate  Expression // nil when no WHERE clause
	Projection Expression
	Variable   *string // optional path variable
	Pattern    *PathPattern
	Pos        Position
	EndPos     Position
}

PatternComprehension is a pattern comprehension: [(a)-[r]->(b) WHERE pred | expr].

func (*PatternComprehension) String

func (p *PatternComprehension) String() string

String returns the Cypher pattern comprehension.

type Position

type Position struct {
	Line   uint32
	Column uint32
	Offset uint32
}

Position carries the source location of an AST node. Fields are populated by the parser (task 208); zero values are acceptable during construction.

func (Position) String

func (p Position) String() string

String returns "line:col" for diagnostic output.

type Projection

type Projection struct {
	Skip     Expression // nil if absent
	Limit    Expression // nil if absent
	Items    []*ProjectionItem
	OrderBy  []*SortItem
	Pos      Position
	EndPos   Position
	Distinct bool
	All      bool // SELECT *
}

Projection carries the column list shared by RETURN and WITH.

func (*Projection) String

func (p *Projection) String() string

String returns the Cypher representation of the projection body (without the leading RETURN / WITH keyword).

type ProjectionItem

type ProjectionItem struct {
	Expr   Expression
	Alias  *string // nil when no AS alias is present
	Pos    Position
	EndPos Position
}

ProjectionItem represents a single item in a RETURN or WITH projection, optionally aliased.

func (*ProjectionItem) String

func (p *ProjectionItem) String() string

String returns the Cypher representation of a projection item.

type Property

type Property struct {
	Receiver Expression
	Key      string
	Pos      Position
	EndPos   Position
}

Property is a property access: expr.key.

func (*Property) String

func (p *Property) String() string

String returns the Cypher property access.

type Query

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

Query is the top-level AST node. A query is either a single query or a UNION of single queries.

type RangeQuantifier

type RangeQuantifier struct {
	Min    *int64 // nil means no lower bound specified
	Max    *int64 // nil means no upper bound specified
	Pos    Position
	EndPos Position
}

RangeQuantifier represents a variable-length range on a relationship: *1..3.

func (*RangeQuantifier) String

func (r *RangeQuantifier) String() string

String returns the Cypher range quantifier.

type ReadingClause

type ReadingClause interface {
	Clause
	// contains filtered or unexported methods
}

ReadingClause is implemented by clauses that read from the graph without modifying it: MATCH, OPTIONAL MATCH, UNWIND, CALL (read-only).

type ReduceExpr added in v0.3.0

type ReduceExpr struct {
	Init       Expression
	Source     Expression
	Projection Expression
	AccVar     string
	ElemVar    string
	Pos        Position
	EndPos     Position
}

ReduceExpr is a reduce expression: reduce(acc = init, x IN list | expr). AccVar is the accumulator variable name, Init is the initial value expression, ElemVar is the loop variable name, Source is the list expression, and Projection is the accumulation expression evaluated on each iteration.

func (*ReduceExpr) String added in v0.3.0

func (r *ReduceExpr) String() string

String returns the Cypher reduce expression.

type RelDirection

type RelDirection int8

RelDirection indicates the directionality of a relationship pattern.

const (
	// RelDirectionNone means the relationship has no specified direction: -[r]-
	RelDirectionNone RelDirection = iota
	// RelDirectionOutgoing means left-to-right: -[r]->
	RelDirectionOutgoing
	// RelDirectionIncoming means right-to-left: <-[r]-
	RelDirectionIncoming
)

func (RelDirection) String

func (d RelDirection) String() string

String returns the Cypher token pair for the direction (left side, right side).

type RelationshipPattern

type RelationshipPattern struct {
	Properties Expression       // nil or MapLiteral / Parameter
	Variable   *string          // nil when anonymous
	Range      *RangeQuantifier // nil for fixed-length
	Types      []string         // zero or more relationship types (OR semantics)
	Pos        Position
	EndPos     Position
	Direction  RelDirection
}

RelationshipPattern represents a relationship within a path pattern.

-[r:REL_TYPE {prop: val}]->

func (*RelationshipPattern) String

func (r *RelationshipPattern) String() string

String returns the Cypher relationship pattern (including direction arrows).

type Remove

type Remove struct {
	Items  []*RemoveItem
	Pos    Position
	EndPos Position
}

Remove is a REMOVE clause.

func (*Remove) String

func (r *Remove) String() string

String returns the REMOVE clause.

type RemoveItem

type RemoveItem struct {
	Target Expression // Property or Variable
	Labels []string   // populated for REMOVE n:Label form
	Pos    Position
	EndPos Position
}

RemoveItem represents one item in a REMOVE clause.

func (*RemoveItem) String

func (r *RemoveItem) String() string

String returns the Cypher representation of a REMOVE item.

type Return

type Return struct {
	Projection *Projection
	Pos        Position
	EndPos     Position
}

Return is a RETURN clause.

func (*Return) String

func (r *Return) String() string

String returns the RETURN clause.

type Set

type Set struct {
	Items  []*SetItem
	Pos    Position
	EndPos Position
}

Set is a SET clause.

func (*Set) String

func (s *Set) String() string

String returns the SET clause.

type SetItem

type SetItem struct {
	Target   Expression // Property or Variable
	Value    Expression // right-hand side; nil for label-set forms
	Operator string     // "=", "+=", or "" for label operations
	Labels   []string   // populated for SET n:Label1:Label2 form
	Pos      Position
	EndPos   Position
}

SetItem represents one assignment in a SET clause: variable.property = expr or label assignment patterns.

func (*SetItem) String

func (s *SetItem) String() string

String returns the Cypher representation of a SET assignment.

type ShortestKind added in v0.6.0

type ShortestKind uint8

ShortestKind classifies a path pattern wrapped in shortestPath(...) or allShortestPaths(...). ShortestNone (the zero value) means an ordinary (non-shortest) path. The parser records the kind by stripping the wrapper keyword in a pre-lex normalizer and stamping it back onto the matching named PathPattern after the AST is built (rmp #1690): the grammar itself is left untouched, so the proven TCK-green parser is unchanged.

const (
	// ShortestNone is an ordinary path pattern (no shortest-path wrapper).
	ShortestNone ShortestKind = iota
	// ShortestSingle is shortestPath(...): a single minimum-hop path.
	ShortestSingle
	// ShortestAll is allShortestPaths(...): every minimum-hop path.
	ShortestAll
)

type SingleQuery

type SingleQuery struct {
	Return          *Return // nil when the query has no RETURN
	ReadingClauses  []ReadingClause
	UpdatingClauses []UpdatingClause
	With            []*With // WITH clauses that appear before RETURN
	// LeadingClauseCount records how many ReadingClauses precede the first
	// With clause in the original query text.  Only meaningful when
	// LeadingCountSet is true; set by the parser for MultiPartQ queries.
	// Used by the IR translator to interleave reading clauses and WITH clauses
	// in the correct order: leading[0..LeadingClauseCount-1] → With[*] →
	// trailing[LeadingClauseCount..].
	//
	// When LeadingCountSet is false (the zero value, or manually-constructed
	// ASTs), the translator falls back to the legacy order: all ReadingClauses
	// first, then all With clauses.
	LeadingClauseCount int
	Pos                Position
	EndPos             Position
	// LeadingCountSet is true when the parser has explicitly populated
	// LeadingClauseCount.  False for SinglePartQ queries and for AST nodes
	// constructed directly in tests without going through the parser.
	LeadingCountSet bool
}

SingleQuery is a sequence of reading and updating clauses, terminated by an optional RETURN.

Example

ExampleSingleQuery shows how to inspect the clause structure of a parsed query by type-switching the typed AST nodes.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/GoGraph/cypher/ast"
	"github.com/FlavioCFOliveira/GoGraph/cypher/parser"
)

func main() {
	q, err := parser.Parse("MATCH (n:Person) WHERE n.age > 18 RETURN n.name")
	if err != nil {
		fmt.Println("error:", err)
		return
	}

	sq, ok := q.(*ast.SingleQuery)
	if !ok {
		fmt.Printf("unexpected root: %T\n", q)
		return
	}

	for _, clause := range sq.ReadingClauses {
		switch c := clause.(type) {
		case *ast.Match:
			fmt.Println("MATCH with WHERE:", c.Where != nil)
		default:
			fmt.Printf("other reading clause: %T\n", c)
		}
	}
	fmt.Println("RETURN present:", sq.Return != nil)
}
Output:
MATCH with WHERE: true
RETURN present: true

func (*SingleQuery) String

func (q *SingleQuery) String() string

String returns the Cypher representation of the single query.

type SliceExpr

type SliceExpr struct {
	Expr   Expression
	From   Expression // nil when absent
	To     Expression // nil when absent
	Pos    Position
	EndPos Position
}

SliceExpr is a slice expression: expr[from..to].

func (*SliceExpr) String

func (s *SliceExpr) String() string

String returns the Cypher slice expression.

type SortItem

type SortItem struct {
	Expr       Expression
	Pos        Position
	EndPos     Position
	Descending bool
}

SortItem represents a single ORDER BY term.

func (*SortItem) String

func (s *SortItem) String() string

String returns the Cypher representation of a sort item.

type StarLiteral

type StarLiteral struct {
	Pos    Position
	EndPos Position
}

StarLiteral represents the wildcard * used in COUNT(*) and similar constructs. Its String() returns "*" so that FunctionInvocation.String() produces "count(*)" rather than "count()".

func (*StarLiteral) String

func (*StarLiteral) String() string

String returns "*".

type StringLiteral

type StringLiteral struct {
	Value  string
	Pos    Position
	EndPos Position
}

StringLiteral is a single-quoted or double-quoted string literal.

func (*StringLiteral) String

func (n *StringLiteral) String() string

String returns the value enclosed in single quotes with internal backslashes and single quotes escaped. The backslash is escaped BEFORE the quote so a value ending in a backslash does not fuse with the closing quote when the printed form is later re-parsed (the IR stringify -> reparse round trip used by the CREATE/MERGE/SET property paths); the reparsers and unescapeString reverse exactly this encoding.

type SubscriptExpr

type SubscriptExpr struct {
	Expr   Expression
	Index  Expression
	Pos    Position
	EndPos Position
}

SubscriptExpr is a subscript access: expr[index].

func (*SubscriptExpr) String

func (s *SubscriptExpr) String() string

String returns the Cypher subscript expression.

type UnaryOp

type UnaryOp struct {
	Operand  Expression
	Operator string // e.g. "-", "NOT", "IS NULL", "IS NOT NULL"
	Pos      Position
	EndPos   Position
}

UnaryOp is a unary operator expression: OP expr.

func (*UnaryOp) String

func (u *UnaryOp) String() string

String returns the Cypher prefix expression.

type Union

type Union struct {
	Query  *SingleQuery
	Pos    Position
	EndPos Position
	All    bool
}

Union is a standalone UNION clause (used as an intermediate representation for some parsing strategies). MultiQuery is preferred for the final AST.

func (*Union) String

func (u *Union) String() string

String returns the UNION clause.

type Unwind

type Unwind struct {
	Expr     Expression
	Variable string
	Pos      Position
	EndPos   Position
}

Unwind is an UNWIND clause: UNWIND expr AS variable.

func (*Unwind) String

func (u *Unwind) String() string

String returns the UNWIND clause.

type UpdatingClause

type UpdatingClause interface {
	Clause
	// contains filtered or unexported methods
}

UpdatingClause is implemented by clauses that mutate the graph: CREATE, MERGE, SET, REMOVE, DELETE, DETACH DELETE, CALL (write).

type Variable

type Variable struct {
	Name   string
	Pos    Position
	EndPos Position
}

Variable is a named reference: n, r, x.

func (*Variable) String

func (v *Variable) String() string

String returns the variable name.

type Where

type Where struct {
	Predicate Expression
	Pos       Position
	EndPos    Position
}

Where represents a WHERE predicate attached to MATCH, WITH, or similar. It is modelled as a standalone node rather than a field because it can carry its own position and is shared between reading and filtering clauses.

func (*Where) String

func (w *Where) String() string

String returns the WHERE clause.

type With

type With struct {
	Projection *Projection
	Where      *Where // nil when no WHERE predicate
	Pos        Position
	EndPos     Position
}

With is a WITH clause, used for intermediate projections and filtering.

func (*With) String

func (w *With) String() string

String returns the WITH clause.

type YieldItem

type YieldItem struct {
	Alias  *string // nil when no AS alias
	Name   string
	Pos    Position
	EndPos Position
}

YieldItem represents a single item in a YIELD clause.

func (*YieldItem) String

func (y *YieldItem) String() string

String returns the YIELD item.

Jump to

Keyboard shortcuts

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