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
Programback to canonical source text. The AST is the source of truth; the text is a projection of it. - Edit: Apply structural edits to a
Programwithout round-tripping through text. Edits are typed operations, not string patches. - Round-trip:
parse → project → parseyields 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§
- Project
Options - 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
ProgramAST 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
Errif the target index is out of range or has an incompatible item kind.