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 -o ./antlr4_cypher CypherLexer.g4 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.script()
# 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 CypherParserListener
class MyCypherListener(CypherParserListener):
def enterMatchSt(self, ctx):
print("Entering MATCH clause")
def exitMatchSt(self, ctx):
print("Exiting MATCH clause")
from antlr4_cypher import CypherParserVisitor
class CustomCypherParserVisitor(CypherParserVisitor):
def __init__(self, mapping: dict):
super().__init__()
self.mapping = mapping
def visit(self, tree):
print("Visiting node:", tree.getText())
return tree.accept(self)
# Example of overriding a specific visit method
def visitMatchSt(self, ctx):
print("Processing MATCH clause with mapping:", self.mapping)
return self.visitChildren(ctx)
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.
Metadata
Release files for antlr4-cypher 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| antlr4_cypher-0.1.2.tar.gz | 56.4 kB | With provenance | Details for antlr4_cypher-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| antlr4_cypher-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for antlr4_cypher-0.1.2-py3-none-any.whl |
Total release size: 113.9 kB
Release files / antlr4_cypher-0.1.2.tar.gz
| Download URL | antlr4_cypher-0.1.2.tar.gz |
|---|---|
| Size | 56.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7216ab43cd6ddbedc330fde3e4e0b319b33b0c8e1be7d799c907c90d884d3fb8
|
|
BLAKE2b-256 checksum How to use checksums |
7022e3e94ff1a4642f458365cc8e8b3a7b538fc165628a4c21d1fe3f8981b0a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 14, 2025.
Transparency logRelease files / antlr4_cypher-0.1.2-py3-none-any.whl
| Download URL | antlr4_cypher-0.1.2-py3-none-any.whl |
|---|---|
| Size | 57.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79d5df69caead19e8ecb56c59fcdbae64d5853c6f8100700afecf73b050a962b
|
|
BLAKE2b-256 checksum How to use checksums |
fe7fca16aed1613472e092df12a94c8b59f9d271193a4efbb1c6f6808fe1f41c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 14, 2025.
Transparency logSecurity for antlr4-cypher 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for antlr4_cypher-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 14, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.