Documentation
¶
Overview ¶
Package ast defines the abstract syntax tree (AST) representation for Cypher queries. It provides data structures that represent the parsed structure of Cypher statements including CREATE, MATCH, SET, DELETE, and REMOVE clauses.
Index ¶
- type AST
- type Assignment
- type Clause
- type ComparisonOp
- type CreateClause
- type DeleteClause
- type Expression
- type Identifier
- type Literal
- type MatchClause
- type NodePattern
- type Pattern
- type PatternElement
- type PropertyAccess
- type PropertyLookup
- type RelDirection
- type RelationPattern
- type RelationVariable
- type RemoveClause
- type RemoveItem
- type RemoveItemType
- type ReturnClause
- type ReturnItem
- type SetClause
- type Statement
- type WhereClause
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AST ¶
type AST struct {
Statements []Statement
}
AST represents a parsed Cypher query containing multiple statements.
type Assignment ¶
type Assignment struct {
Property PropertyAccess
Value Expression
}
Assignment represents a property assignment in a SET clause.
type Clause ¶
type Clause interface {
// contains filtered or unexported methods
}
Clause is implemented by all Cypher clause types. It is used to identify the type of clause in a statement.
type ComparisonOp ¶
type ComparisonOp struct {
Left Expression
Operator string
Right Expression
}
ComparisonOp represents a comparison expression with a left operand, operator, and right operand.
type CreateClause ¶
type CreateClause struct {
Pattern Pattern
}
CreateClause represents a CREATE clause that creates new nodes and relationships.
type DeleteClause ¶
type DeleteClause struct {
Detach bool
Expressions []Expression
Where *WhereClause
}
DeleteClause represents a DELETE clause that removes nodes and relationships. The Detach field indicates whether to also delete connected relationships.
type Expression ¶
type Expression interface {
// contains filtered or unexported methods
}
Expression is implemented by all expression types in the AST.
type Identifier ¶
type Identifier struct {
Name string
}
Identifier represents an identifier expression.
type Literal ¶
type Literal struct {
Value interface{}
}
Literal represents a literal value expression.
type MatchClause ¶
type MatchClause struct {
Pattern Pattern
Where *WhereClause
Return *ReturnClause
Delete *DeleteClause
}
MatchClause represents a MATCH clause that queries for existing graph patterns. It may include WHERE conditions, RETURN projections, and DELETE operations.
type NodePattern ¶
NodePattern represents a node in a Cypher pattern, with optional variable, labels, and properties.
type Pattern ¶
type Pattern struct {
Elements []PatternElement
}
Pattern represents a graph pattern consisting of connected nodes and relationships.
type PatternElement ¶
type PatternElement struct {
Node *NodePattern
Relation *RelationPattern
}
PatternElement represents a node pattern optionally followed by a relationship pattern.
type PropertyAccess ¶
PropertyAccess represents a property lookup expression (e.g., n.property).
type PropertyLookup ¶
PropertyLookup represents a property lookup on a node or relationship.
type RelDirection ¶
type RelDirection string
RelDirection represents the direction of a relationship pattern.
const ( RelDirOutgoing RelDirection = "->" RelDirIncoming RelDirection = "<-" RelDirBoth RelDirection = "-" )
func (RelDirection) String ¶
func (r RelDirection) String() string
String returns the string representation of the relationship direction.
type RelationPattern ¶
type RelationPattern struct {
Variable string
RelType string
Dir RelDirection
StartNode *NodePattern
EndNode *NodePattern
Properties map[string]interface{}
MinHops int
MaxHops int
}
RelationPattern represents a relationship pattern between two nodes. It includes the relationship type, direction, variable, and properties.
type RelationVariable ¶
type RelationVariable struct {
Name string
}
RelationVariable represents a relationship variable reference.
type RemoveClause ¶
type RemoveClause struct {
Removals []RemoveItem
Where *WhereClause
}
RemoveClause represents a REMOVE clause that removes labels or properties from nodes.
type RemoveItem ¶
type RemoveItem struct {
Type RemoveItemType
Label string
Property PropertyAccess
}
RemoveItem represents a single removal operation in a REMOVE clause.
type RemoveItemType ¶
type RemoveItemType int
RemoveItemType specifies the type of removal operation.
const ( RemoveItemTypeLabel RemoveItemType = iota RemoveItemTypeProperty )
type ReturnClause ¶
type ReturnClause struct {
Items []ReturnItem
}
ReturnClause represents a RETURN clause specifying which expressions to return.
type ReturnItem ¶
type ReturnItem struct {
Expression Expression
Alias string
}
ReturnItem represents a single return expression with an optional alias.
type SetClause ¶
type SetClause struct {
Assignments []Assignment
Where *WhereClause
}
SetClause represents a SET clause that updates node properties.
type Statement ¶
type Statement struct {
Clause Clause
}
Statement represents a single statement in a Cypher query.
type WhereClause ¶
type WhereClause struct {
Expression Expression
}
WhereClause represents a WHERE clause containing a filter expression.