Metadata-Version: 2.4
Name: circuitdk-lossless-sexpr
Version: 0.1.1
Summary: A lossless concrete syntax tree and text editing library for S-expressions
Keywords: cst,parser,s-expression,source-preserving
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/td2sk/circuitdk
Project-URL: Repository, https://github.com/td2sk/circuitdk
Project-URL: Issues, https://github.com/td2sk/circuitdk/issues
Description-Content-Type: text/markdown

# circuitdk-lossless-sexpr

`circuitdk-lossless-sexpr` provides a small, lossless concrete syntax tree for S-expressions.
Parsing and rendering an unchanged document preserves its source text byte for byte, including
whitespace, comments, number formatting, and unknown syntax.

The distribution is maintained as part of CircuitDK, but the Python package can be used
independently.

## Installation

```console
uv add circuitdk-lossless-sexpr
```

## Usage

```python
from lossless_sexpr import TextEdit, apply_edits, parse

source = '(property "Value" "10 k" (at 1 2))'
document = parse(source)

value = document.lists("property")[0].atom(2)
assert value is not None

updated = apply_edits(source, [TextEdit(value.span, '"47 k"')])
assert updated == '(property "Value" "47 k" (at 1 2))'
```

Overlapping edits are rejected, and parse errors include source locations. The library deliberately
contains no KiCad or circuit-specific semantics.
