pub struct ExprOptions {
pub op: IndexMap<String, Option<OpDef>>,
pub evaluate: Option<Evaluate>,
pub juxtapose: Option<bool>,
pub values: Vec<String>,
pub node_limit: Option<usize>,
}Expand description
Options for the plugin.
op is an insertion-ordered map, and the order matters: two operators
claiming the same source string resolve to the same token, and the
later entry wins, exactly as it does in the canonical TypeScript. A
None entry deletes an operator the defaults provide.
Fields§
§op: IndexMap<String, Option<OpDef>>§evaluate: Option<Evaluate>§juxtapose: Option<bool>Values side by side, with nothing between them, inside an
expression or a paren group make an implicit list, as jsonic makes
one (f(a b) is a call of [a, b]). With Some(false) they are
refused, with the engine’s unexpected. A document’s own implicit
list, outside any expression, and the items of a list or a map are
unchanged. None reads as true.
values: Vec<String>The value tokens of a host grammar that lexes its own (an
identifier, a number), by name, beside jsonic’s text, number, string
and keyword values. With juxtapose false, one of them after a
value or an expression is refused, with the engine’s unexpected,
wherever it stands: an expression never ends at one, and the rule
the expression is in never sees it. The items of a list or a map
are not exempt.
node_limit: Option<usize>The most nodes one expression may hold, NODE_LIMIT when None.
An expression past it is refused with the engine’s cancel code.
The limit keeps a realized tree shallow enough for the engine’s
recursive walks of a value (display, JSON, drop), which abort the
process past the stack where TypeScript and Go fail or go on. A
host that raises it reduces every expression with an evaluator into
values of its own, whose depth it bounds itself, and never realizes
or simplifies a tree past NODE_LIMIT: the parse, the placing of
an operator and the evaluation walk no deeper on the call stack
however large an expression grows.
Implementations§
Source§impl ExprOptions
impl ExprOptions
Sourcepub fn with_op(self, name: impl Into<String>, def: OpDef) -> Self
pub fn with_op(self, name: impl Into<String>, def: OpDef) -> Self
Add or replace one operator definition.
Sourcepub fn without_op(self, name: impl Into<String>) -> Self
pub fn without_op(self, name: impl Into<String>) -> Self
Delete a default operator, the Rust spelling of plain: null.
Sourcepub fn with_juxtapose(self, juxtapose: bool) -> Self
pub fn with_juxtapose(self, juxtapose: bool) -> Self
Whether values side by side make an implicit list: see
ExprOptions::juxtapose.
Sourcepub fn with_values<I, S>(self, values: I) -> Self
pub fn with_values<I, S>(self, values: I) -> Self
Name a host grammar’s own value tokens: see ExprOptions::values.
Sourcepub fn with_node_limit(self, limit: usize) -> Self
pub fn with_node_limit(self, limit: usize) -> Self
Set the most nodes one expression may hold: see
ExprOptions::node_limit.
Sourcepub fn with_evaluate(
self,
evaluate: impl Fn(&mut EvalSite<'_>, &Op, &[Value]) -> Value + Send + Sync + 'static,
) -> Self
pub fn with_evaluate( self, evaluate: impl Fn(&mut EvalSite<'_>, &Op, &[Value]) -> Value + Send + Sync + 'static, ) -> Self
Set the evaluator that reduces each expression as it closes.
Sourcepub fn from_value(options: &Value) -> Self
pub fn from_value(options: &Value) -> Self
Read the operator table, and juxtapose, out of a serialized option
bag, as the engine hands it to a plugin. Unreadable entries are
ignored, the way the canonical plugin ignores what it cannot use.