Skip to main content

Crate tabnas_yaml

Crate tabnas_yaml 

Source
Expand description

A core-subset YAML grammar plugin for the tabnas parsing engine.

Unlike most tabnas grammars this one layers on tabnas_jsonic rather than on the bare engine: YAML’s flow collections are relaxed JSON, and the block forms are added around jsonic’s val / map / list / pair / elem rules.

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let value = tabnas_yaml::parse("name: Alice\nitems:\n  - one\n  - two\n")?;
    assert_eq!(
        value.to_string(),
        r#"{"name":"Alice","items":["one","two"]}"#
    );
    Ok(())
}

Structs§

TranslationPart
One optional alchemy translation source and its explicit entry point.
TranslationParts
The package-local structural translation interface.
YamlError
Errors this crate returns are the engine’s, re-exported so a caller does not need tabnas in scope to name them.
YamlOptions
The options this plugin takes.

Enums§

Schema
A schema a plain scalar may be resolved by.

Constants§

VERSION
VERSION is this package’s version. It MUST equal ts/package.json “version”: the release orchestrator rewrites all three constants, and tests/version_test.rs fails the build if they drift. Mirrors const VERSION in ts/src/yaml.ts and go/yaml.go.

Functions§

make
Build a YAML parser with the default options.
make_with
Build a YAML parser with caller options.
manifest_text
The plugin’s manifest, tabnas.plugin.json, as the repository carries it. Its translate object is what a host that translates reads: the shape YAML is read as and written from (tree), the file that holds the render, the sentences that say what the render does not keep, and the file that holds the transducer part (transduce), the document’s JSON events from the grammar’s rule passes under its default options, through which a host that reads parser events reads a document. The crate embeds its own copies, translate/manifest.json and translate/transduce.alc, since a packaged crate holds nothing outside rs/; tests/translate_test.rs holds each copy to its file.
parse
Parse a YAML source string with the shared default parser.
plugin
The plugin form of yaml, for Tabnas::use_plugin. Installed this way the grammar is re-applied to derived instances, as every native plugin is.
render_text
YAML’s render, alchemy/render.alc, the file the manifest’s translate.render names: a library of alchemy definitions, with no export, whose entry point yaml-render writes a tree’s events as one YAML document. A host links it with its own program. The crate embeds its own copy, translate/render.alc, held to the file as the manifest’s is.
translate
Return YAML’s immutable translation parts.
yaml
Install YAML on a jsonic-enabled parser.