Skip to main content

Parser, walker and reference resolver for the TTR modeling language

Project description

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.

Project details


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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ttr_parser-0.8.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37e355ca0c3e690e562190e60673f7310195da34a5df12c1d8ef82f9f69e9e90
MD5 e30a61f6373e59ab2207ee212a4926d0
BLAKE2b-256 9515facf5c8b181d989708d72c8370e8aa2d4c9147f727f08a48f35909e52126

See more details on using hashes here.

Provenance

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

Publisher: publish-python.yml on Collite/modeler

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page