Search code examples
syntaxneo4jcypherbnf

Is there a Cypher syntax definition anywhere?


I'm looking for a definition of the syntax for the Cypher query language. I tried the docs but they're very vague.

Ideally, I'd like a BNF (or any variant) definition, or one of those "graph" definitions like this or this. Really, anything resembling a formal definition.


Solution

  • What you are looking for will be available in openCypher. Several items will be released as part of the project, one of the first of which is the BNF grammar.


    • Update 2016-01-30: A first draft of the grammar is now avialable at \https://github.com/opencypher/openCypher/blob/master/grammar.ebnf.
    • Update: 2016-10-17: EBNF and Antlr grammars, TCK, railroad diagrams, and a list of community projects are available at http://www.opencypher.org/#resources

    Take a look at the recently announced (Oct 2015) openCypher project. It involves releasing the language specification, among other things.

    From the announcement:

    1. Cypher reference documentation: A comprehensive user documentation describing use of the Cypher query language with examples and tutorials.

    2. Technology compatibility kit (TCK): The TCK consists of a number of tests that a software supplier would run in order to self-certify support for a given version of Cypher.

    3. Reference implementation: Distributed under the Apache 2.0 license, the reference implementation is a fully functional implementation of key parts of the stack needed to support Cypher inside a data platform or tool. The first planned deliverable is a parser that will take a Cypher statement and parse it into an AST (abstract syntax tree) representation. The reference implementation complements the documentation and tests by providing working implementations of Cypher – which are permissively licensed – and can be used as examples or as a foundation for one’s own implementation.

    4. Cypher language specification: Licensed under a Creative Commons license, the Cypher language specification is a technical expression of the language syntax to enable parsers to auto-generate the query syntax. A full semantic specification is also planned as a part of the openCypher project.

    The same announcement also says that the process is open and that it is possible to submit, review and comment on language proposals.