Skip to content

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.

from gmat_script import parse

tree = parse("Create Spacecraft Sat\nSat.SMA = 7000\n")
tree.has_errors      # False
tree.to_source()     # round-trips byte-for-byte to the input

gmat-script ships the parser, a typed AST with a mutation API, a canonical formatter, and a static linter, with a gmat-script command-line tool over the same engine — plus a language server and a VS Code extension that bring it all to your editor.

What it is

  • A tree-sitter grammar for GMAT scripts (.script) and GmatFunctions (.gmf) that parses the full R2026a sample corpus and re-emits it byte-for-byte.
  • A Python library that loads that grammar from a vendored, precompiled binding — so pip install gmat-script needs no C or Node toolchain, and never GMAT.
  • A gmat-script command-line tool that parses, formats, and lints scripts from the shell or CI.

What it is not

  • Not a propagator or astrodynamics engine — it reads and transforms script text; computing orbits and running a mission is GMAT's job.
  • Not dependent on a GMAT install at runtime. Reading, checking, formatting, and editing a script needs only this package.
  • Not an engine-dependent validator — "does it parse" is structural and answered here; "does it run / converge" needs GMAT.

Where to go next

  • Getting started — install and run your first parse.
  • Grammar surface — the node taxonomy and what is covered / deferred.
  • Typed AST — typed resources and dict-like field access over the tree.
  • Editing — set fields, rename resources, and splice commands.
  • Formatter — canonical, idempotent re-emission.
  • Linter — structural checks against the bundled field catalogue.
  • Field catalogue — the version-pinned knowledge base behind the linter and editor.
  • CLI — the parse syntax gate and the format and lint commands.
  • Language server — diagnostics, hover, and completion in any LSP editor.
  • VS Code extension — highlighting, diagnostics, and format-on-save in VS Code.
  • Error reporting — how malformed input is surfaced.
  • API reference — the public Python surface.
  • Design decisions — the grammar scope, CST node taxonomy, and the build/vendoring contract the implementation is built against.

Installation

pip install gmat-script

gmat-script supports Python 3.10, 3.11, and 3.12.