Documentation
¶
Overview ¶
Package sulpher provides a parser for the Cypher graph query language.
Cypher is a declarative, SQL-inspired graph query language developed by Neo4j and standardised through the openCypher project. This package parses Cypher queries into an Abstract Syntax Tree (AST) that can be analysed, transformed, or executed in Go.
Example usage:
query, errors := sulpher.Parse(`MATCH (n:Person)-[:KNOWS]->(m) RETURN n.name`)
if len(errors) > 0 {
for _, err := range errors {
fmt.Println("Error:", err)
}
return
}
fmt.Println(query.String())
Index ¶
- func Parse(input string) (*ast.Query, []string)
- func Tokenize(input string) []token.Token
- func Walk(v Visitor, node ast.Node)
- type BooleanLiteral
- type CallClause
- type CaseExpression
- type CaseWhen
- type CountStar
- type CreateClause
- type DeleteClause
- type DynamicPropertyAccess
- type ExistsSubquery
- type Expression
- type FloatLiteral
- type ForeachClause
- type FunctionCall
- type Identifier
- type InExpression
- type InfixExpression
- type Inspector
- func (insp *Inspector) FindFunctionCalls() []*ast.FunctionCall
- func (insp *Inspector) FindMatchClauses() []*ast.MatchClause
- func (insp *Inspector) FindNodePatterns() []*ast.NodePattern
- func (insp *Inspector) FindParameters() []*ast.Parameter
- func (insp *Inspector) FindRelationshipPatterns() []*ast.RelationshipPattern
- func (insp *Inspector) FindReturnClauses() []*ast.ReturnClause
- type IntegerLiteral
- type IsNullExpression
- type LabelExpression
- type ListComprehension
- type ListLiteral
- type ListSlice
- type MapLiteral
- type MapPair
- type MatchClause
- type MergeClause
- type Node
- type NodePattern
- type NullLiteral
- type Parameter
- type Pattern
- type PatternComprehension
- type PatternPart
- type PrefixExpression
- type ProjectionItem
- type PropertyAccess
- type QualifiedName
- type QuantifierExpression
- type Query
- type RelationshipPattern
- type RemoveClause
- type RemoveItem
- type ReturnClause
- type SetClause
- type SetItem
- type ShortestPathExpression
- type SingleQuery
- type SortItem
- type Statement
- type StringLiteral
- type StringPredicate
- type Token
- type UnionPart
- type UnwindClause
- type Visitor
- type WithClause
- type YieldItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses a Cypher query string and returns the AST root and any errors. The returned slice is empty when parsing succeeds without errors.
Types ¶
type DynamicPropertyAccess ¶
type DynamicPropertyAccess = ast.DynamicPropertyAccess
Expression types
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector collects all AST nodes for convenient querying.
func NewInspector ¶
NewInspector creates a new Inspector for the given query AST.
func (*Inspector) FindFunctionCalls ¶
func (insp *Inspector) FindFunctionCalls() []*ast.FunctionCall
FindFunctionCalls returns all function call expressions in the AST.
func (*Inspector) FindMatchClauses ¶
func (insp *Inspector) FindMatchClauses() []*ast.MatchClause
FindMatchClauses returns all MATCH clauses in the AST.
func (*Inspector) FindNodePatterns ¶
func (insp *Inspector) FindNodePatterns() []*ast.NodePattern
FindNodePatterns returns all node patterns in the AST.
func (*Inspector) FindParameters ¶
FindParameters returns all parameter references in the AST.
func (*Inspector) FindRelationshipPatterns ¶
func (insp *Inspector) FindRelationshipPatterns() []*ast.RelationshipPattern
FindRelationshipPatterns returns all relationship patterns in the AST.
func (*Inspector) FindReturnClauses ¶
func (insp *Inspector) FindReturnClauses() []*ast.ReturnClause
FindReturnClauses returns all RETURN clauses in the AST.
type ShortestPathExpression ¶
type ShortestPathExpression = ast.ShortestPathExpression
Expression types
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ast defines the Abstract Syntax Tree nodes for Cypher.
|
Package ast defines the Abstract Syntax Tree nodes for Cypher. |
|
cmd
|
|
|
example
command
Command example demonstrates sulpher's public API.
|
Command example demonstrates sulpher's public API. |
|
Package lexer implements a lexical scanner for Cypher.
|
Package lexer implements a lexical scanner for Cypher. |
|
Graph label boolean expression miniparser for sulpher.
|
Graph label boolean expression miniparser for sulpher. |
|
pkg
|
|
|
version
Package version exposes the current version of sulpher.
|
Package version exposes the current version of sulpher. |
|
Package token defines constants representing the lexical tokens of Cypher.
|
Package token defines constants representing the lexical tokens of Cypher. |