Metadata-Version: 2.4
Name: fastparse
Version: 0.1.0rc13
Summary: Python binding for the FastParse Tree-sitter parser library with bundled native runtime
Project-URL: Homepage, https://github.com/natan-sysview/fast_parser
Project-URL: Repository, https://github.com/natan-sysview/fast_parser
Project-URL: Documentation, https://github.com/natan-sysview/fast_parser/tree/main/docs
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# FastParse Python Binding

Small `ctypes` binding for the FastParse native C library.

The binding keeps the same design boundary as the native library:

- Python owns file I/O.
- Python passes bytes already loaded in RAM.
- FastParse returns JSON, CSV, MessagePack binary, diagnostics, or stats in RAM.
- Python copies the returned native buffer and frees the native result.

## Install

From PyPI, once the package is published:

```bash
pip install fastparse
```

From a downloaded wheel:

```bash
pip install fastparse-0.1.0rc13-py3-none-macosx_11_0_arm64.whl
```

The wheel includes the native library for its platform, so normal users do not need `FASTPARSE_LIBRARY_PATH`.

## Quick Use

```python
from fastparse import FastParse

parser = FastParse()
source = b"class Demo { void run() {} }"

result = parser.parse_bytes(
    source,
    language="java",
    output_format="json",
    fields=["rule", "text", "byte_range"],
)

print(result.node_count)
print(result.json())
```

Binary MessagePack output:

```python
result = tsmp.parse_bytes(
    source,
    language="java",
    output_format="binary",
    fields=["rule", "text", "byte_range"],
)

print(result.node_count)
print(result.data)  # MessagePack bytes
```

If the caller only needs node/output counts and does not need to copy the generated JSON/CSV into Python:

```python
summary = parser.parse_bytes_summary(
    source,
    language="java",
    output_format="json",
)

print(summary.node_count)
print(summary.output_length)
```

Use `FASTPARSE_LIBRARY_PATH` to point at a specific native library:

```bash
FASTPARSE_LIBRARY_PATH=/path/to/libfastparse.dylib python your_script.py
```
