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.13.0-py3-none-any.whl (209.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ttr_parser-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 209.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ttr_parser-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f3d6a96ab6faad09f62346c97ad7c93e42fc8f039ad9607edc40a354ddc23c0
MD5 13f305da8951044a541f473c3dcfeaba
BLAKE2b-256 9142025e5acec57943adfd1314f9f4b8248a9b1d6d1f8471ee7c196c65b03915

See more details on using hashes here.

Provenance

The following attestation bundles were made for ttr_parser-0.13.0-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

This release

0.13.0 This release

1 file

0.8.4

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