Skip to main content

Module dump

Module dump 

Source
Expand description

Tools for inspecting and testing what the library holds in memory: parsed and processed trees, computed tables, and diagnostics.

The library’s own tests, the tests of a program or extension crate built on it, and the flm dump command of the flm program all use this module. It is ordinary public interface rather than test-only code: no cargo feature switches it on, so a program writes its test fixtures against the same functions the library’s tests use.

The module renders what the library holds in two different forms, and keeps them apart:

  • The projection (project) is a one-way rendering of a tree, a node, a table or a diagnostic as a techy serialized value (SerialValue, techy’s format-independent data model), in a vocabulary this library owns and keeps stable (elem, chars, args, children, and so on; spans as line:col on request). It is what tests compare and what flm dump --view compact prints. It never shows a parsing state, and it cannot be read back into a tree.
  • The wire form (session) is techy’s serialization of a parse, which crate::lang::serialize implements for FLM. It is lossless and verbose, and it can be read back into in-memory objects with their sharing and identity intact. flm dump --view wire prints it as JSON, one segment (the unit of output a session emits) per line (json::segment_line).

A program that writes such data as JSON opens its output with a header, Meta: the kind of output, the version of FLM that wrote it, and the version of the kind’s format.

§Map

Every public item of the submodules is re-exported here.

golden is the only part of flm-core that reads or writes files; no stage, rule or entry point of the processing touches the file system.

Re-exports§

pub use diag::DiagExpect;
pub use diag::ExpectDiag;
pub use diag::expect;
pub use diag::expect_none;
pub use golden::GoldenError;
pub use golden::GoldenMode;
pub use golden::UPDATE_GOLDEN;
pub use golden::assert_json_golden;
pub use golden::assert_text_golden;
pub use golden::check_json_golden;
pub use golden::check_text_golden;
pub use json::JsonError;
pub use json::from_json;
pub use json::from_serde;
pub use json::segment_from_line;
pub use json::segment_line;
pub use json::to_json;
pub use json::to_json_pretty;
pub use meta::Meta;
pub use project::ProjectOptions;
pub use project::Projector;
pub use project::TableProjection;
pub use project::TreeSource;
pub use project::node_ref_value;
pub use project::project_diagnostic;
pub use project::project_diagnostics;
pub use project::project_node;
pub use project::project_nodes;
pub use project::project_payload;
pub use project::project_table;
pub use project::project_tree;
pub use project::tree_ref_value;
pub use session::AmbiguousElement;
pub use session::ElementResolver;
pub use session::ElementTable;
pub use session::FALLBACK_GATE_IDENTIFIER;
pub use session::FRAGMENT_IDENTIFIER;
pub use session::FRAGMENTS_TABLE;
pub use session::FragmentIndex;
pub use session::FragmentSerdeDriver;
pub use session::PRESENTATION_IDENTIFIER;
pub use session::PayloadReader;
pub use session::PayloadReaders;
pub use session::ReadEnvironment;
pub use session::SYNTHESIZED_IDENTIFIER;
pub use session::WriteEnvironment;
pub use session::fragments_table;
pub use session::known_providers;
pub use session::read_fragment;
pub use session::read_tree;
pub use session::reader;
pub use session::reader_with;
pub use session::register;
pub use session::write_fragment;
pub use session::write_tree;
pub use session::writer;

Modules§

diag
Assertions on diagnostics for tests: select a diagnostic by its identifier, then narrow the selection by the source text its span covers, its line:col position, its severity, its number of traceback frames or its data, never by its message.
golden
Golden files: compare a test’s output with the expected output kept in a file, and rewrite that file on request.
json
Conversion between JSON text and techy’s serialized values and wire segments.
meta
The header of a JSON output: what kind of output it is, which version of FLM wrote it, and which version of that kind’s format it follows.
project
The projection: a one-way rendering of a tree, a node, a computed table or a diagnostic as a techy serialized value (SerialValue), in a vocabulary this library owns and keeps stable.
session
Serialization sessions for FLM: writing parsed fragments and trees in techy’s serialized form (the wire form) and reading them back into in-memory objects.