formatter

package
v1.74.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package formatter produces a canonical, opinionated formatting of an MX Script source file. It walks the token stream (with comments and newlines preserved by the lexer's CollectComments flag) and emits a new source string with consistent indentation and operator spacing.

Conventions:

  • 2-space indent, scoped by `{`/`}`/`(`/`)`/`[`/`]` depth.
  • One blank line max between statements; blank lines inside blocks are preserved (a single newline stays a single newline; two or more collapse to one blank line).
  • Standard operator spacing: a + b, a == b, a && b, ...
  • Comma-separated lists: `a, b, c` (no leading space, trailing space).
  • Braces: `{` stays on the same line as the keyword, `}` on its own line.
  • Comments: preserved in place. A trailing `// ...` keeps its trailing position; a leading `// ...` stays above the next statement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(src string) (string, error)

Format normalizes the source string. Returns the formatted source and any lexing error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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