Metadata-Version: 2.4
Name: spacetime-dsl
Version: 0.1.1
Summary: Compiler for a DSL describing Lamport space-time diagrams, from source file to SVG diagram
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: lark==1.3.1

## Setup

Requires Python 3.10 or newer (developed and tested on 3.13).

Run `./setup.sh` to create the virtual environment and install the project.
It performs an editable install (`pip install --editable . --group dev`), so
`import spacetime` resolves to this checkout and the `spacetime` command is
available inside `.venv/bin/`. Dependencies live in `pyproject.toml`.

The environment lives **only** in `.venv/`. Do not create one in place at the
repository root (`python3 -m venv .`): `setup.sh` refuses to run in that
situation, and the stray `bin/`, `lib/`, `include/` and `pyvenv.cfg` would
shadow the real environment.

## Running

Compile a DSL file and print its SVG space-time diagram to stdout:

```bash
source .venv/bin/activate
spacetime example.txt        # equivalently: python -m spacetime example.txt
```

To inspect every compiler stage instead, add `--print-stages`. Only the
frontend runs: it prints the Lark parse tree, the intermediate `Ast`, and
the refined AST, each under a header, and no SVG is rendered:

```bash
spacetime --print-stages example.txt
```

Run the test suite:

```bash
source .venv/bin/activate
pytest -q
```

## Specification

- [`spacetime/grammar.lark`](spacetime/grammar.lark) — the entire
  specification: the concrete syntax, plus the semantic rules documented
  as an attribute grammar in comments.
- [`docs/qualidade.md`](docs/qualidade.md) — language and grammar quality
  evaluation (TP1, task 4), with metrics from `docs/metricas_gramatica.py`.

## Linguagem para escrever lamport space-time diagrams

Example:
```
Processes {
  p
  q
  r
}

Messages {
  request := "Request o que quiser"
  ack := "Ack"
  vote := "Votes for leader"
}

History {
  m1 := Send(request) :: p -> q
  Recv(m1) :: q

  m2 := Send(ack) :: q -> p, q, r
  Recv(m2) :: p, q

  m3 := Send(request) :: r -> q
  Recv(m3) :: q
}
```


Results in:

![Space time diagram](./docs/sample.svg)
