Skip to main content

plugin

Function plugin 

Source
pub fn plugin() -> Plugin
Expand description

The plugin, for Tabnas::use_plugin, carrying the default operator table as its declared defaults.

Call-site options are deep-merged over those defaults by the engine, so an entry naming a default operator extends it and a null entry deletes it, exactly as in the canonical TypeScript. An evaluator cannot travel in a serialized option bag: pass one with plugin_with.

use tabnas::Value;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut parser = tabnas_jsonic::make();
    parser.use_plugin(tabnas_expr::plugin(), None)?;
    let value = tabnas_expr::realize(&parser.parse("1+2")?);
    assert_eq!(tabnas_expr::simplify(&value).to_string(), "[\"+\",1,2]");
    Ok::<(), Box<dyn std::error::Error>>(())
}