Skip to content
andyfeng edited this page Mar 15, 2021 · 2 revisions

Grammar

We use the same grammar as open cypher but remove features that are not yet supported. See issue#57 for a list of features that are currently removed.

Parser

Parser class structure closely follows open cypher grammar.

Graph Pattern

  • NodePattern: (a:Person)
    • name, type
  • RelPattern: -[e1:knows]->
    • name, label, direction
  • PatternElementChain: -[e1:knows]->(b:Student)
    • relPattern, nodePattern
  • PatternElement: (a:Person) -[e1:knows]->(b:Student) -[e2]->(c)
    • nodePattern, vector<PatternElementChain>
  • MatchStatement: MATCH ..., ...
    • vector<PatternElement>
  • SingleQuery MATCH ... MATCH ...
    • vector<MatchStatement>

Expressions

  • Boolean Connection
    • AND, XOR, OR, NOT
  • Comparison
    • = , <>, >, <, >=, <=
  • Arithmetic
    • +, - , *, /, %, ^
  • String Operator
    • STARTS WITH, ENDS WITH, CONTAINS
  • Null Operator
    • IS NULL, IS NOT NULL
  • Property
    • e.g. a.name
  • Function Invocation
    • functionName(param1, param2, ..)
  • Parenthesized Expression Support
    • (a.isStudent AND a.isMale) OR a.name CONTAINS "Xiyang"
  • Variable (Leaf Expression)
  • Literal (Leaf Expression)
    • INT, DOUBLE, BOOLEAN, STRING, NULL

Class Structure

  • Every expression is represented as ParsedExpression with 3 attributes
    • ExpressionType
    • string text (used to store content for LiteralExpression, VaraibleName, FunctionName and PropertyName)
    • vector<ParsedExpression> children (empty for leaf expression)