This repository contains a lanuguage-independent ANTLR grammar for Graph Query Language (GQL) based on the August 2023 GQL Specification Draft. It is designed to be included as a submodule in other repositories.
Using the ANTLR tools, language-dependent parsers can be generated by infrastructure code in the parent repository.
GQL Parser for Go is an example of a repository that uses the GQL ANTLR grammar by including this repository as a submodule.
The original version of the grammar file was generated using gramgen, a command line program that generates an ANTLR parser and lexeer file from an XML representation of the BNF for the GQL grammar. The XML file is an artifact of the official ISO Specification for GQL.
This generated version was then hand tweaked to make it more suitable for ANTLR consumption. Among other changes, mutually left recursive productions were folded into parent productions. The main focus of the changes were related to the value expression and primary value expression productions.
The Grammar itself is more permissive than a GQL implementation would be. Some type checking and other syntatic analysis would be required as post-processing steps to parsing using the grammar.
Not a lot of testing has been done to date, besides spot checking using various hand generated snippets of GQL. In the future this grammar will be validated using a Test Compatibilty Kit (TCK) for GQL.