# sysml-v2-parser

SysML v2 textual notation parser for Rust.

This crate parses SysML v2 and related KerML textual syntax into an AST and also exposes a resilient editor-oriented parsing mode that returns partial AST + diagnostics.

## Changelog

Release notes and migration hints: [`CHANGELOG.md`](CHANGELOG.md).

## Current status

- library parser for a broad SysML v2 subset
- strict and resilient parsing entry points
- BNF coverage gate: all 640 SysML/KerML textual productions classified as `implemented` (see [`docs/BNF_COVERAGE.md`](docs/BNF_COVERAGE.md))
- green unit/integration test suite (including `cargo test --test bnf_compliance`)
- green full validation and std-library gates when run with the SysML v2 release fixtures

## API

The main public entry points are:

- `parse(input)` for strict parsing
- `parse_for_editor(input)` for partial AST + diagnostics

Example:

```rust
use sysml_v2_parser::parse;

fn main() {
    let model = parse("package Demo;").expect("valid SysML");
    assert_eq!(model.elements.len(), 1);
}
```

## Development

Run the default test suite:

```bash
cargo test
```

Run formatting/lint checks used in CI:

```bash
cargo clippy -- -W clippy::all
```

Run the full validation suite against the SysML v2 release tree (required in CI):

```bash
cargo test --test validation -- --include-ignored
```

If you change AST fields or body-element shapes, refresh the checked-in AST snapshots in the same PR — see [validation test README](tests/validation/README.md) and [regression gates](docs/PARSER_BACKLOG_ROADMAP.md#ast-snapshot-refresh-when-ast-shape-changes).

Fetch the pinned SysML v2 release fixtures into `./sysml-v2-release`:

```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\fetch-sysml-v2-release.ps1
```

```bash
./scripts/fetch-sysml-v2-release.sh
```

If the release fixtures live somewhere else, set:

```bash
SYSML_V2_RELEASE_DIR=/path/to/SysML-v2-Release
```

## Documentation

- **[Parser backlog & roadmap](docs/PARSER_BACKLOG_ROADMAP.md)** — open work (Spec42, LSP, grammar depth)
- [Spec42 diagnostics parser spec](docs/SPEC42-DIAGNOSTICS-PARSER-IMPROVEMENTS.md)
- [Error recovery](docs/ERROR_RECOVERY.md)
- [BNF coverage gate](docs/BNF_COVERAGE.md)
- [SysML v2 compliance gap](docs/SYSML_V2_COMPLIANCE_GAP.md)
- [Parser technical debt](docs/PARSER_TECHNICAL_DEBT.md)
- [Language server backlog](docs/LANGUAGE_SERVER_BACKLOG.md) (detail; summarized in backlog doc)
