Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

The Xtext grammar

wuetherich edited this page Oct 12, 2016 · 14 revisions

The openCypher Xtext grammar is the corner stone of this openCypher implementation. If you're new to Xtext or the Xtext grammar, please have a look at the excellent documentation of the Xtext The Grammar Language.

Xtext-mapping of the openCypher grammar

The openCypher grammar is provided as a antlr4 grammar. Although Xtext uses antlr internally, it is not possible to reuse the provided antl4r grammar as it is. Instead it is necessary to map the antlr4 grammar to an Xtext grammar, which fortunately is rather straight forward. The mapped Xtext grammar is located at

plugins/org.slizaa.neo4j.opencypher/src/org/slizaa/neo4j/opencypher/OpenCypher.xtext.

It defines the grammar as well as the structure of the in-memory representation. The Xtext grammar is - of course - heavily based on the provided antlr4 grammar but differs in several points.

Whitespaces

The Xtext grammar allows it to specify the usage of whitespaces and comments for the entire grammar. As the result all whitespace / comment definitions have been removed from the individual clauses.

Example:

Grammar Clause
antlr4 configurationOption : symbolicName ws '=' ws symbolicName ;
Xtext ConfigurationOption: key=SYMBOLIC_NAME '=' value=SYMBOLIC_NAME;
  • The Xtext grammar allows it also to specify the case-insensitivity for the entire grammar. As the result all whitespace / comment definitions have been removed from the individual clauses. Setting the flag ignoreCase = true in the parser generator options makes it obsolete to specify the case-insensitivity for the individual keywords.

User Guide

Developer Guide

Clone this wiki locally