uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026

Warning

uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.

Introduction

Product: 

Class: 

Remarks

Description: A comprehensive guide to the functional syntax, logic directives, and structural anchors used to define and evaluate transformation rules in uCalc.

Pattern Methods are specialized instructions enclosed in { } that allow the uCalc Transformer to move beyond literal text matching. These methods interact with the uCalc engine to identify token categories, perform calculations, or even execute external logic during a transformation.

1. The Evaluation Timeline (@ vs @@)

The most powerful aspect of uCalc Pattern Methods is the ability to control when logic is executed using the @ prefix. This applies to almost all Directives:

SyntaxNameTimingBehavior
{@Method}Static DirectiveRule CreationEvaluated once when the rule is defined. Ideal for constant calculations or loading external templates.
{@@Method}Dynamic DirectiveMatch TimeEvaluated every time the pattern finds a match. Ideal for logic that depends on captured text.

2. Functional Categories

Directives (Commands)

Directives perform actions. Note that variables captured in the pattern (e.g., {@Number:val}) are accessed by name without additional curly braces inside these directives.

  • {@Eval} / {@@Eval}: Evaluates an expression. Example: {@@Eval:val * 2}.
  • {@File} / {@@File}: Inserts file content. Example: {@@File:filename} where filename is a captured variable.
  • {@Define} / {@@Define}: Defines variables/functions in the uCalc evaluator space.
  • {@Exec} / {@@Exec}: Executes code without returning a value to the pattern/replacement.
  • {@Comment}: Annotates patterns; ignored during parsing (irrelevant to @/@@).

Structural Matchers (Anchors)

These identify specific locations in the text stream:

  • {@Beginning}: Matches only if at the start of the source string.
  • {@End}: Matches only if at the very end of the source string.
  • {@All}: Captures the entire source string as a single entity.
  • {@Stop}: Truncates the saved match at this specific point in the pattern.

Replacement-Only Keywords

Reserved for the "To" part of a transformation:

  • {@Self}: The entire captured pattern.
  • {@Doc}: The entire source document string.
  • {@Param:n}: References a specific captured sub-part by number.

**Character Literals (`

Injects characters by ASCII code. {#65#66#67} results in ABC. Useful for non-printing characters like {#0} (Null) or {#10} (Line Feed).

Examples