std/path/z/evaluate

Standard Library documentation

Pure Zuzu evaluator for ZPath expressions.

Module

Name
std/path/z/evaluate
Area
Standard Library
Source
modules/std/path/z/evaluate.zzm

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

  • Evaluator

    Pure-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: ast is an AST node and ctx is a Ctx. Returns: Array. Evaluates with optional debug dumping.

    • evaluator.eval_expr(ast, ctx)

      Parameters: ast is an AST node and ctx is a Ctx. Returns: Array. Evaluates an expression to a node set.

    • evaluator.nested_ctx(ctx, ... PairList extras)

      Parameters: ctx is a Ctx or null and extras are metadata. Returns: Ctx or null. Creates a nested evaluation context.

    • evaluator.eval_binop(ast, ctx), evaluator.eval_unop(ast, ctx)

      Parameters: ast is an operator AST node and ctx is a Ctx. Returns: Array. Evaluates a binary or unary operator.

    • evaluator.eval_path(path_ast, ctx)

      Parameters: path_ast is a path AST node and ctx is a Ctx. Returns: Array. Evaluates a path expression to selected nodes.

    • evaluator.maybe_apply_action(node, ctx)

      Parameters: node is a Node and ctx is a Ctx. Returns: Node. Applies any pending path action.

    • evaluator.eval_fn(fn_ast, ctx)

      Parameters: fn_ast is a function-call AST node and ctx is a Ctx. 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: nodes is an array of nodes. Returns: Array. Removes duplicate nodes while preserving order.

    • evaluator.truthy(n)

      Parameters: n is a node or value. Returns: Boolean. Applies ZPath truthiness.

    • evaluator.to_number(n), evaluator.to_string(n)

      Parameters: n is a node or value. Returns: Number or String. Coerces a ZPath value.

    • evaluator.equals(a, b)

      Parameters: a and b are 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.