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.

Stop

Method

Product: 

Transformer Library

Class: 

Transformer

Defines a global stop pattern that acts as an uncrossable boundary for all variable captures within the transformer.

Syntax

Stop(string)

Parameters

pattern
string
The pattern string that defines the stop boundary.

Return

Rule

Returns the newly created Rule object representing the stop pattern, which can be used to modify or release it.

Remarks

Note: This feature is currently in the design phase and is not yet implemented in the production engine.

The Stop method defines a global "hard stop" boundary for an entire Transformer instance. When any rule's variable (e.g., {body}) is capturing text, it will immediately stop if it encounters a match for a Stop pattern. The stop pattern itself is not consumed and is not part of any match.

This is a powerful feature for parsing text with well-defined but un-consumable terminators, such as an END keyword or a block delimiter that should not be part of any capture.

🎯 Behavior and Precedence

  • Global Scope: A Stop pattern applies to all rules within the Transformer. It is not tied to a specific FromTo or Pattern rule.
  • LIFO Precedence: If you define multiple Stop patterns, the most recently defined one has the highest precedence and will be checked for first.

🆚 Comparison with Other Boundary Mechanisms

It is crucial to understand how Stop differs from other boundary types in uCalc:

MechanismScopeBehaviorUse Case
Rule AnchorRule-specificConsumed. Becomes part of the match ({@Self}).Defining the start or end of a specific pattern.
Statement SeparatorInstance-wideConsumed. A token type (like ;) that terminates a capture if StatementSensitive is true.Parsing code or line-based data where newlines are significant.
{@Stop} DirectiveRule-specificNot Consumed. Truncates what is included in the {@Self} capture for a single rule.Creating a lookahead within a single pattern.
Stop() MethodTransformer-wideNot Consumed. A global boundary that terminates any variable capture in any rule.Defining a universal terminator for a document format.

💡 Why uCalc? (Comparative Analysis)

Transformer.Stop is conceptually similar to a positive lookahead in regular expressions ((?=...pattern...)), which asserts that a pattern must exist without consuming it.

However, uCalc's Stop patterns have a key advantage: they are token-aware. A regex lookahead operates on raw characters and can be difficult to write for structured data. A Stop pattern operates on the token stream, so it inherently respects word boundaries, quoted strings, and other language constructs, making it a more robust and reliable tool for parsing.

Examples