Skip to main content

Module parser

Module parser 

Source
Expand description

Full recursive-descent parser for the Active alpha.

Supported surface language:

  • let name = expr
  • [table] blocks with key = expr
  • top-level and nested key = expr
  • env.NAME ?: default
  • secret("…") / secret(env.NAME)
  • integers, floats, bools, null, strings (single & double quoted)
  • unit suffixes on numbers (5s, 512MiB, 100/req/s …) → Quantity nodes
  • full string interpolation "…${ident}…" (and nested simple expressions)
  • arrays [ … ]
  • inline tables { k = v, … }
  • binary operators with correct precedence: || && == != < <= > >= + - * /
  • unary - and !
  • parentheses for grouping

After parsing, a resolution pass turns Ident nodes that match let bindings into Ref nodes and builds the dependency graph.

Structs§

Lexed
Result of tokenizing: the token stream, hard lexical errors, healing diagnostics, and the comments found along the way (trivia for the formatter).
Lexer
ParseOptions
Options controlling parsing and healing behavior.
Token

Enums§

PathSeg
One segment of a patch path (spec §2.9): a table key, optionally followed by an array index (servers[0] lexes as Key+Index).
TokenKind

Functions§

parse
parse_file
Parse a file from the filesystem, resolving include statements against the file’s directory (spec §2.7). Includes are enabled regardless of the passed options’ enable_includes flag; every other option is honored as given.
parse_file_with_trust
Parse a file with overlay enforcement (C-052): identical to parse_file, but every include must carry a valid sibling signature from trusted (E032 otherwise). Use with --trust-keys; without it, parse_file preserves legacy behavior exactly.
parse_recovering
Parse and return the module even when diagnostics were recorded.
parse_text_recovering_with_file
Parse buffer text as above but always return the module, even when diagnostics were recorded. Tooling (editor diagnostics on broken files) needs the partial tree; crucially, the file context is preserved so include statements never fall back to resolving from the process working directory.
parse_text_with_file
Parse buffer text as if it were the file at path: include statements resolve against the file’s directory (spec §2.7), and diagnostics carry the file’s identity. The language server’s dirty-buffer path (C-043): unsaved edits analyze with the saved file’s include context. Includes are enabled regardless of the passed options’ enable_includes flag; every other option is honored as given.
parse_with
validate_patch_path
Validate and split a patch path (a.b[0].c) into segments. Keys follow identifier syntax (ASCII letter or _ first, then ASCII alphanumerics or _); an index suffix [n] may repeat (a[0][1] walks nested arrays). Empty paths/segments, malformed brackets, and non-integer indices are E019 at parse time; missing targets are W004 at apply.