Skip to main content

Parse, format, lint, and edit GMAT mission scripts from Python — a tree-sitter grammar and tooling.

Project description

gmat-script

Parse, format, lint, and edit GMAT .script mission files from Python — built on a tree-sitter grammar. The whole stack operates on script text; nothing here requires a GMAT install.

It ships the parser, a typed AST with a mutation API, and a canonical formatter, plus a gmat-script command-line tool over the same engine. The linter and editor tooling build on top of the same tree as they land.

Install

pip install gmat-script

gmat-script supports Python 3.10, 3.11, and 3.12. The wheel bundles a precompiled grammar, so the install needs no C or Node toolchain — and never GMAT.

Quick start

Parse a script — parse never raises on malformed input: it returns a tree carrying ERROR / MISSING nodes localised to the broken construct, surfaced through tree.errors.

from gmat_script import parse

tree = parse("Create Spacecraft Sat\nSat.SMA = 7000\n")

tree.has_errors      # False — the script is well-formed
tree.to_source()     # round-trips byte-for-byte to the input

Edit it through the typed AST — typed resources with dict-like field access. Each edit splices the source and re-parses, so untouched bytes are never disturbed and a corrupting edit is refused.

from gmat_script import Script

script = Script.parse("Create Spacecraft Sat\nSat.SMA = 7000\n")

script.spacecraft["Sat"]["SMA"]         # 7000 — read a field
script.spacecraft["Sat"]["SMA"] = 8000  # set it
script.rename_resource("Sat", "MainSat")  # rename, rewriting references
script.to_source()                      # the edited source

Format it — a deterministic, idempotent pretty-printer that re-lays-out without reordering.

from gmat_script import format

format("GMAT Sat.SMA=7000;\n")   # 'Sat.SMA = 7000\n'

Command line

The same engine drives the gmat-script command-line tool — a fast, install-free gate for CI:

$ gmat-script parse mission.script     # print the syntax tree; exit non-zero on a syntax error
$ gmat-script format --check *.script   # fail if any file is not in canonical form

format rewrites files in place by default, or checks / diffs them with ruff-style exit codes. It also ships pre-commit hooks, so scripts are formatted on every commit — add the repo to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/astro-tools/gmat-script
    rev: v0.2.0
    hooks:
      - id: gmat-script-format        # auto-format on commit
      # - id: gmat-script-format-check  # or: check only, never write (CI)

The grammar surface

The tree-sitter grammar parses GMAT scripts (.script) and GmatFunctions (.gmf) — the same grammar for both — and re-emits any input byte-for-byte, comments and layout included. It is a deliberately permissive superset: Create <Type> <name> accepts any resource type and unknown command keywords parse as generic command nodes, so a new resource or command never needs a grammar change. The acceptance bar is concrete: every one of the 162 .script and 9 .gmf files shipped with NASA GMAT R2026a parses with zero errors and round-trips exactly.

See the grammar surface reference for the node taxonomy and the covered / deferred constructs.

The GMAT-free guarantee

Reading, checking, formatting, and transforming a script needs only this package — never a GMAT install. pip install gmat-script never pulls in, requires, or looks for GMAT or gmatpy; the only runtime dependency is tree-sitter. (GMAT is used at build time only, to generate the field catalogue that later semantic tooling will check against.)

GMAT version

The grammar targets GMAT R2026a. Because it never enumerates resource types or command keywords, parsing is effectively version-independent — scripts from other releases parse too. Semantics that do vary by release (valid field names, enums, defaults) belong to the later linter and are scoped to R2026a.

What gmat-script is not

  • Not a propagator or astrodynamics engine. It reads and transforms script text; it computes no orbits and models no physics.
  • Not a mission runner. Running a script is GMAT's job — gmat-script does no execution.
  • Not an engine-dependent validator. "Does it parse" is a structural question answered here; "does it run / converge" is a different question that needs GMAT.

Documentation

Full documentation — getting started, the grammar surface, the typed AST and editing guides, the formatter, the command-line tool, the error-reporting model, and the API reference — is at astro-tools.github.io/gmat-script.

License

MIT — part of the astro-tools organization.

Project details


Download files

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

Source Distribution

gmat_script-0.2.0.tar.gz (376.4 kB view details)

Uploaded Source

Built Distributions

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

gmat_script-0.2.0-cp310-abi3-win_amd64.whl (60.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

gmat_script-0.2.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (70.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

gmat_script-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (57.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

gmat_script-0.2.0-cp310-abi3-macosx_10_9_x86_64.whl (56.8 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

Details for the file gmat_script-0.2.0.tar.gz.

File metadata

  • Download URL: gmat_script-0.2.0.tar.gz
  • Upload date:
  • Size: 376.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gmat_script-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fb0948f26a16bcd477891c38901301668636589a90cb2260b9d33fe60aa898be
MD5 3e16240cdc729f7595a21ed6e5b03036
BLAKE2b-256 677f4bd7990e88de3114ad1ec923265bec499b434c028978a377000937340d8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmat_script-0.2.0.tar.gz:

Publisher: release.yml on astro-tools/gmat-script

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

File details

Details for the file gmat_script-0.2.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: gmat_script-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 60.0 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gmat_script-0.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0681789a70ba41c1a4f3c6f78c600a38de8db19a162ae18c6ed5544f779f42c6
MD5 1d195dcc2c2e2e636fb9fa372f95279f
BLAKE2b-256 560f1299fe3a296309bcbfd6222a404f53cb28cf7ea0485890ee2a54e6923c69

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmat_script-0.2.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on astro-tools/gmat-script

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

File details

Details for the file gmat_script-0.2.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for gmat_script-0.2.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8eddc71ad5aec953f83a1fc959521a395d7795f1d1591866f3cf79e686d463d2
MD5 66b6be82d0635628fa0910f8aa17732f
BLAKE2b-256 4fb351bd1954952738a90707d754525df6a515929e1c438eac71b24a2a78b4f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmat_script-0.2.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yml on astro-tools/gmat-script

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

File details

Details for the file gmat_script-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gmat_script-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a1a08046c554872593306a3da183d69d0cea2cec496079f138f689efc5113686
MD5 ff9301808a5e9b00c0f89507f1191a7f
BLAKE2b-256 cb331e469d47c982c2bee5432909048983f5c05a2ffaaf023d4a61cf3f691bc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmat_script-0.2.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on astro-tools/gmat-script

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

File details

Details for the file gmat_script-0.2.0-cp310-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gmat_script-0.2.0-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 662b43e7110b738d76bcce67a63f5b27d63e87b12cf835e1575649a417be00b8
MD5 a9c538b73ebcd605c82e0185604be1fb
BLAKE2b-256 297e7295036f03b3e2bf3b2912c65870091008e474d9ed84a2e426ba11a851e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmat_script-0.2.0-cp310-abi3-macosx_10_9_x86_64.whl:

Publisher: release.yml on astro-tools/gmat-script

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