Metadata-Version: 2.4
Name: esql-parser
Version: 9.1.3
Summary: Python parser for Elasticsearch ESQL
Author-email: Michael Bischoff <michael@bischoff.dev>
License-Expression: Elastic-2.0
Project-URL: Homepage, https://github.com/mjmbischoff/esql-check
Project-URL: Issues, https://github.com/mjmbischoff/esql-check/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE.txt
Requires-Dist: antlr4-python3-runtime==4.13.1
Dynamic: license-file

# esql-parser

A Python package providing an ANTLR4-based parser and lexer for
**Elasticsearch ESQL (Event Query Language)**.

The grammar is derived from the official [Elasticsearch repository](https://github.com/elastic/elasticsearch)
and adapted for the Python ANTLR runtime.

## Installation

```bash
pip install esql-parser
```

## Usage
```
from antlr4 import InputStream, CommonTokenStream
from esql_parser.EsqlBaseLexer import EsqlBaseLexer
from esql_parser.EsqlBaseParser import EsqlBaseParser

# Example: parse a simple ESQL query
input_stream = InputStream("FROM logs | STATS count(*) BY host")
lexer = EsqlBaseLexer(input_stream)
token_stream = CommonTokenStream(lexer)
parser = EsqlBaseParser(token_stream)

tree = parser.singleStatement()
print(tree.toStringTree(recog=parser))
```

## Versioning

The version number of esql-parser matches the corresponding
Elasticsearch version from which the grammar was taken
(e.g. esql-parser==9.1.3 → Elasticsearch 9.1.3).
