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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ttr_parser-0.8.4-py3-none-any.whl (174.1 kB view details)

Uploaded Python 3

File details

Details for the file ttr_parser-0.8.4-py3-none-any.whl.

File metadata

  • Download URL: ttr_parser-0.8.4-py3-none-any.whl
  • Upload date:
  • Size: 174.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ttr_parser-0.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c97dab34da650f42aa1bf751025ff0778d22a42e09f37b48245c88d55baec0de
MD5 4d23664e939c478333e23d34153ba27f
BLAKE2b-256 0aef4e2f5c42ac03e34e27504a8f1c53378cac51f40f996ec03a923eed4b7468

See more details on using hashes here.

Provenance

The following attestation bundles were made for ttr_parser-0.8.4-py3-none-any.whl:

Publisher: publish-python.yml on Collite/tatrman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.13.0

1 file

This release

0.8.4 This release

1 file

0.8.2

1 file

0.8.1

1 file

0.8.0

1 file

0.7.0

1 file

0.1.0

1 file

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