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_directoryreturn a typed, frozen AST faithful to grammar v2.2, with accurate source locations on every node. - Semantics (
ttr_parser.semantics) —SymbolTable, the six-stepResolver, the portableValidatorsubset, the stock CNC vocabulary, and theProject/load_projectconvenience 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ttr_parser-0.8.0-py3-none-any.whl.
File metadata
- Download URL: ttr_parser-0.8.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88a92d7f89f3b9fc4aafa557897c130ed45ab87ee09cc7daa692d32fac2de255
|
|
| MD5 |
5eec8fc90684ed87cff58c1bd47c2312
|
|
| BLAKE2b-256 |
31f677e3eb6f34cad6b35e55dba1a88c5027b94e7dac417408db2d60c22474e3
|
Provenance
The following attestation bundles were made for ttr_parser-0.8.0-py3-none-any.whl:
Publisher:
publish-python.yml on Collite/modeler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ttr_parser-0.8.0-py3-none-any.whl -
Subject digest:
88a92d7f89f3b9fc4aafa557897c130ed45ab87ee09cc7daa692d32fac2de255 - Sigstore transparency entry: 1982730088
- Sigstore integration time:
-
Permalink:
Collite/modeler@4e86b33f09d3ba9d90d003c91b6f93fc8db1ec35 -
Branch / Tag:
refs/tags/python/v0.8.0 - Owner: https://github.com/Collite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@4e86b33f09d3ba9d90d003c91b6f93fc8db1ec35 -
Trigger Event:
push
-
Statement type: