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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ttr_parser-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 143.4 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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b230550bc23db909a12d5d2960933ed632a5e9856518c8e15a4ebc0ff4f96174
MD5 a62f216504d0dc068db64a306b22fd79
BLAKE2b-256 e8e1e462b7f2735255bd0a8fdc13beed30cd53eac75b1799fa970536c09490fd

See more details on using hashes here.

Provenance

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