dump

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dump renders an ast.Node as a stable, human-reviewable tree.

It serves two purposes described in PLAN.md, both standing in for the upstream parse-tree goldens SQLite cannot produce:

  • Committed AST snapshots for a curated slice of the corpus, reviewed by humans in diffs but never authoritative over the accept/reject oracle.
  • The comparison key for the round-trip property, where a tree is rendered back to SQL, re-parsed, and the two trees must match.

The renderer is reflective rather than a type switch, so it never falls behind the node set: a field added to a node shows up in the dump, and in any snapshot diff, without anyone having to remember.

Index

Constants

This section is empty.

Variables

View Source
var Snapshot = Options{Positions: true, Raw: true}

Snapshot is the option set for committed snapshots: everything.

View Source
var Structure = Options{}

Structure is the option set for comparing two trees for equality of shape. It drops spans and Raw text, which are exactly the things meyer's renderer declines to promise: re-parsing rendered SQL moves every offset and may respell any token.

Functions

func FirstDiff

func FirstDiff(want, got string) string

FirstDiff reports the first differing line of two dumps, with its number, so a failure names the field that changed instead of printing two trees.

func Node

func Node(n ast.Node, opts Options) string

Node renders one node.

func Stmts

func Stmts(stmts []ast.Stmt, opts Options) string

Stmts renders a whole script.

Types

type Options

type Options struct {
	// Positions includes each node's byte span.
	Positions bool
	// Raw includes the Raw fields that hold verbatim source text.
	Raw bool
}

Options controls which source-fidelity detail the dump carries.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL