Documentation
¶
Overview ¶
Graph label boolean expression miniparser for sulpher.
Neo4j 5 introduced a boolean expression grammar for label and relationship-type filters inside node and relationship patterns:
(n:Person&Employee) — node must have both labels (n:Person|Employee) — node must have at least one label (n:!Deleted) — node must not have the label (n:%) — node may have any label (wildcard) (n:(Person|Employee)&!Bot) — grouped expression -[:KNOWS|LIKES]-> — simple form (already handled by pattern.go) -[:(KNOWS|LIKES)&!BLOCKED]->— boolean type filter (new form)
Grammar (precedence, low to high):
LabelOr = LabelAnd ( "|" LabelAnd )*
LabelAnd = LabelNot ( "&" LabelNot )*
LabelNot = "!" LabelNot | LabelAtom
LabelAtom = LabelName | "%" | "(" LabelOr ")"
This miniparser owns only the label expression itself. The surrounding colon and pattern brackets are consumed by the pattern miniparser (pattern.go), which calls parseLabelFilter() when it detects a boolean operator after the first label.
Package parser implements a recursive-descent parser for Cypher.
The parser follows the openCypher 9 grammar as its specification target. It produces an *ast.Query root node and accumulates parse errors as strings (matching the tsqlparser error-reporting convention) rather than panicking.
Expression parsing uses the Pratt (top-down operator precedence) technique, identical to the approach in tsqlparser.
CALL subquery block miniparser for sulpher.
Neo4j 5 introduced CALL {} as a first-class clause distinct from the CALL procedureName(…) procedure invocation. This file owns all parsing for the block subquery form.
Supported forms:
CALL (var1, var2) { query }
CALL (var1, var2) { query } IN TRANSACTIONS
CALL (var1, var2) { query } IN TRANSACTIONS OF n ROWS
CALL (var1, var2) { query } IN n CONCURRENT TRANSACTIONS
CALL (var1, var2) { query } IN n TRANSACTIONS -- alias
The deprecated importing-WITH form (Neo4j 4.x style) is also accepted:
CALL { WITH var1 … }
Detection: in parseClause(), when CALL is followed by ( or { (not an identifier), this parser is called instead of parseCallClause().
Index ¶
Constants ¶
const ( LOWEST int OR_PREC // OR, XOR AND_PREC // AND NOT_PREC // NOT COMPARE // =, <>, <, >, <=, >= STRING_OP // STARTS WITH, ENDS WITH, CONTAINS, =~ IN_PREC // IN, IS NULL, IS NOT NULL SUM // +, - PRODUCT // *, /, % UNARY // unary -, + POWER // ^ CALL // function calls, subscript PROPERTY // .property, [index] )
Operator precedence levels — higher number binds tighter.
Variables ¶
This section is empty.
Functions ¶
This section is empty.