A Python package for parsing Cypher queries using ANTLR4.
Project description
antlr4-cypher
antlr4-cypher is a Python package that provides the Lexer and Parser for the Cypher query language, generated using ANTLR with the command java -jar antlr-4.13.2-complete.jar -Dlanguage=Python3 -listener -visitor CypherParser.g4. The project includes the necessary grammar, lexer, and parser files, as well as empty listener and visitor classes that serve as a reference for implementing custom logic.
Installation
You can install the package using pip:
pip install antlr4-cypher
Grammar Source
The grammar files (CypherLexer.g4 and CypherParser.g4) are sourced from the ANTLR grammars-v4 repository. These files define the syntax and structure of the Cypher query language.
Usage
To use the lexer and parser in your project, you can import them as follows:
from antlr4 import InputStream, CommonTokenStream
from antlr4_cypher import CypherLexer, CypherParser
# Example input
input_query = "MATCH (n) RETURN n"
# Create a lexer and parser
input_stream = InputStream(input_query)
lexer = CypherLexer(input_stream)
token_stream = CommonTokenStream(lexer)
parser = CypherParser(token_stream)
# Parse the input
tree = parser.cypher()
# Use the tree for further processing
Custom Listeners and Visitors
The package includes empty listener and visitor classes that you can extend to implement custom logic for traversing the parse tree. For example:
from antlr4_cypher import CypherListener
class MyCypherListener(CypherListener):
def enterMatchSt(self, ctx):
print("Entering MATCH clause")
def exitMatchSt(self, ctx):
print("Exiting MATCH clause")
This README provides a basic overview of the antlr4-cypher project. For more detailed information, please refer to the source code and the ANTLR documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file antlr4_cypher-0.1.0.tar.gz.
File metadata
- Download URL: antlr4_cypher-0.1.0.tar.gz
- Upload date:
- Size: 39.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbdae87152c7eb900e8a31ed094ae3e30d11a1a3e1b7ce57cc955b6a34adeba1
|
|
| MD5 |
49182cefbbc880d96608f43f1db0c4e2
|
|
| BLAKE2b-256 |
90bbf57fffebf17825dc359d721f049429f29c95820789240a9a95ef5988a581
|
Provenance
The following attestation bundles were made for antlr4_cypher-0.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on qi-hua/antlr4-cypher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
antlr4_cypher-0.1.0.tar.gz -
Subject digest:
cbdae87152c7eb900e8a31ed094ae3e30d11a1a3e1b7ce57cc955b6a34adeba1 - Sigstore transparency entry: 158273552
- Sigstore integration time:
-
Permalink:
qi-hua/antlr4-cypher@13c79e2258809453ca5370dd901979447c9af06e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/qi-hua
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@13c79e2258809453ca5370dd901979447c9af06e -
Trigger Event:
push
-
Statement type:
File details
Details for the file antlr4_cypher-0.1.0-py3-none-any.whl.
File metadata
- Download URL: antlr4_cypher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c11a4fd205342911e0c13382e0788f299dc5443c24920e3905be6e6e6ed5b87b
|
|
| MD5 |
6f8fa47db12b7faecb230d099f4e05c0
|
|
| BLAKE2b-256 |
99f4c7b84090e65f762e5d25a5d3db1c49aa49f1331147c3cfe11dc709859498
|
Provenance
The following attestation bundles were made for antlr4_cypher-0.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on qi-hua/antlr4-cypher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
antlr4_cypher-0.1.0-py3-none-any.whl -
Subject digest:
c11a4fd205342911e0c13382e0788f299dc5443c24920e3905be6e6e6ed5b87b - Sigstore transparency entry: 158273558
- Sigstore integration time:
-
Permalink:
qi-hua/antlr4-cypher@13c79e2258809453ca5370dd901979447c9af06e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/qi-hua
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@13c79e2258809453ca5370dd901979447c9af06e -
Trigger Event:
push
-
Statement type: