Skip to main content

Module projectional

Module projectional 

Source
Expand description

Projectional authoring — structure is the source of truth, text is a view (W1).

This module implements the projectional authoring model for VibeScript:

  • Project: Convert an AST Program back to canonical source text. The AST is the source of truth; the text is a projection of it.
  • Edit: Apply structural edits to a Program without round-tripping through text. Edits are typed operations, not string patches.
  • Round-trip: parse → project → parse yields an equivalent AST.
  • Trivia preservation: When a CST is available (trivia collected), the projector can interleave comments and whitespace from the original source.

This stops LLMs and humans from forking a second syntax: the structure is authoritative, and text is always derivable from it.

Reference: docs/vibescript-full-impl-PLAN.md W1.

Structs§

ProjectOptions
Options controlling how the projector formats source text.

Enums§

Edit
A structural edit operation on a Program.

Functions§

apply_edit
Apply a structural edit to a program, returning a new program.
apply_edits
Apply a sequence of edits, producing the final program.
make_binary
Helper: build a binary expression.
make_call
Helper: build a call expression.
make_field
Helper: build a simple field declaration.
make_float
Helper: build a float literal expression.
make_ident
Helper: build an identifier expression.
make_int
Helper: build an integer literal expression.
make_law
Helper: build a simple law declaration.
make_material
Helper: build a simple material declaration.
make_member
Helper: build a member access expression.
make_string
Helper: build a string literal expression.
project_item
Project a single top-level item.
project_program
Project a Program AST to canonical source text.
project_with_trivia
Project a program with trivia preservation.
try_apply_edit
Apply a structural edit with bounds and target-kind validation. Returns Err if the target index is out of range or has an incompatible item kind.