Skip to main content

ttr-parser

A pure-Python parser, walker and reference resolver for the TTR modeling language (@grammar-version 2.2). Parses .ttr models into a typed AST and resolves cross-references through the same six-step chain the platform uses — no JVM required at install or runtime (the ANTLR parser is generated and bundled into the wheel).

pip install ttr-parser

Requires CPython 3.13+.

Quickstart

from ttr_parser import parse_file, load_project
from ttr_parser.semantics import ResolutionContext

# Parse a single file into a typed AST.
result = parse_file("model.ttr")
for definition in result.definitions:
    print(definition.kind, definition.name)

# Load a whole project: parses every *.ttr under the root and pre-loads the
# stock CNC vocabulary, all into one symbol table.
project = load_project("path/to/project")

# Resolve a reference the way the platform does (lexical → same-package →
# imports → stock auto-import → fully-qualified).
result = project.resolve(
    "artikl", ResolutionContext(schema_code="er", namespace="entity")
)
print(result)  # Resolved(symbol=..., via_step="same-package") | Unresolved(...)

# Aggregated parse + resolution + validation diagnostics.
for diagnostic in project.diagnostics():
    print(diagnostic.code, diagnostic.message)

What's in the box

  • Parser / walker (ttr_parser) — parse_string / parse_file / parse_directory return a typed, frozen AST faithful to grammar v2.2, with accurate source locations on every node.
  • Semantics (ttr_parser.semantics) — SymbolTable, the six-step Resolver, the portable Validator subset, the stock CNC vocabulary, and the Project / load_project convenience entry point.

The AST and resolution output are pinned byte-for-byte to the reference TypeScript/Kotlin implementations by a conformance harness, so a Python consumer sees exactly what the platform sees.

License

Apache-2.0.

Metadata

Release files for ttr-parser 0.18.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for ttr-parser 0.18.5
File Interpreter ABI Platform Actions
ttr_parser-0.18.5-py3-none-any.whl Python 3 none any Details for ttr_parser-0.18.5-py3-none-any.whl

Release files / ttr_parser-0.18.5-py3-none-any.whl

Download URL ttr_parser-0.18.5-py3-none-any.whl
Size 294.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f87408a67740e4bbca89157ef9f2ec43a9e5970c6ae4319d9dd8a47839fabf11
BLAKE2b-256 checksum
How to use checksums
3456b9d49e9806260fe9b86dc325a85b92e4c9cbe1eb7409632e37ea7c4eb35b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for ttr-parser 0.18.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 1 file in this release has been uploaded with provenance metadata.

Attestation for ttr_parser-0.18.5-py3-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page