NAME
std/path/z/evaluate - Pure Zuzu evaluator for ZPath expressions.
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
This module provides the pure-Zuzu evaluator used by ZPath.
EXPORTS
Classes
EvaluatorPure-Zuzu evaluator for parsed ZPath AST values.
evaluator.operator_definitions()Parameters: none. Returns:
Array. Returns the active operator definition table.evaluator.function_definitions()Parameters: none. Returns:
Array. Returns the active function definition table.evaluator.eval_expr_wrap(ast, ctx)Parameters:
astis an AST node andctxis aCtx. Returns:Array. Evaluates with optional debug dumping.evaluator.eval_expr(ast, ctx)Parameters:
astis an AST node andctxis aCtx. Returns:Array. Evaluates an expression to a node set.evaluator.nested_ctx(ctx, ... PairList extras)Parameters:
ctxis aCtxornullandextrasare metadata. Returns:Ctxornull. Creates a nested evaluation context.evaluator.eval_binop(ast, ctx),evaluator.eval_unop(ast, ctx)Parameters:
astis an operator AST node andctxis aCtx. Returns:Array. Evaluates a binary or unary operator.evaluator.eval_path(path_ast, ctx)Parameters:
path_astis a path AST node andctxis aCtx. Returns:Array. Evaluates a path expression to selected nodes.evaluator.maybe_apply_action(node, ctx)Parameters:
nodeis aNodeandctxis aCtx. Returns:Node. Applies any pending path action.evaluator.eval_fn(fn_ast, ctx)Parameters:
fn_astis a function-call AST node andctxis aCtx. Returns:Array. Evaluates a ZPath function call.evaluator.string_replace(string, pattern, replacement)Parameters: all arguments are strings or regex-like values. Returns:
String. Applies ZPath string replacement.evaluator.dedup_nodes(nodes)Parameters:
nodesis an array of nodes. Returns:Array. Removes duplicate nodes while preserving order.evaluator.truthy(n)Parameters:
nis a node or value. Returns:Boolean. Applies ZPath truthiness.evaluator.to_number(n),evaluator.to_string(n)Parameters:
nis a node or value. Returns:NumberorString. Coerces a ZPath value.evaluator.equals(a, b)Parameters:
aandbare nodes or values. Returns:Boolean. Compares two ZPath values.
COPYRIGHT AND LICENCE
std/path/z/evaluate is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.