uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Retrieves the parent Transformer instance that owns this rule, providing a navigational link back to the rule's execution context.
Every Rule object exists within the context of a parent Transformer that owns it. The ParentTransformer property provides the crucial link back to this owner, allowing you to navigate "up" the object hierarchy from a specific rule to its container.
This is essential for introspection and for writing context-aware transformation logic, especially when dealing with nested transformers.
Contextual Introspection: When you retrieve a Rule from a Match object, you can use ParentTransformer to access the state of the Transformer that found the match. This allows you to read its Description, check its other rules, or inspect its token set.
Distinguishing Local vs. Global Context: When using a LocalTransformer for nested parsing, this property is the primary way to determine which level of the hierarchy a rule belongs to. A rule inside a LocalTransformer will have that LocalTransformer as its parent, not the main, top-level Transformer.
This parent-child relationship is a common design pattern for creating navigable object trees.
vs. DOM (Document Object Model): The relationship between a Rule and its ParentTransformer is analogous to an HTML element and its parentElement in the DOM. It provides a structured, predictable way to traverse the hierarchy of your parsing logic. Just as you might walk up the DOM tree from a specific <div> to find its container, you can walk up from a Rule to its owning Transformer.
vs. Ad-Hoc Rule Management: Without this built-in link, you would need to manually track which Transformer owns which Rule, likely using external dictionaries or wrapper classes. This is complex and error-prone. By making ParentTransformer a first-class property, uCalc provides a clean, reliable, and integrated solution for managing the relationship between rules and their execution context.
ID: 960
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
var myRule = t.FromTo("A", "B");
// Get the parent from the rule
var parent = myRule.ParentTransformer;
// Check if the parent is the original transformer using its unique memory index
Console.WriteLine(parent.MemoryIndex == t.MemoryIndex);
True using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); var myRule = t.FromTo("A", "B"); // Get the parent from the rule var parent = myRule.ParentTransformer; // Check if the parent is the original transformer using its unique memory index Console.WriteLine(parent.MemoryIndex == t.MemoryIndex);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc::Transformer t;
auto myRule = t.FromTo("A", "B");
// Get the parent from the rule
auto parent = myRule.ParentTransformer();
// Check if the parent is the original transformer using its unique memory index
cout << tf(parent.MemoryIndex() == t.MemoryIndex()) << endl;
}
True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uCalc::Transformer t; auto myRule = t.FromTo("A", "B"); // Get the parent from the rule auto parent = myRule.ParentTransformer(); // Check if the parent is the original transformer using its unique memory index cout << tf(parent.MemoryIndex() == t.MemoryIndex()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
Dim myRule = t.FromTo("A", "B")
'// Get the parent from the rule
Dim parent = myRule.ParentTransformer
'// Check if the parent is the original transformer using its unique memory index
Console.WriteLine(parent.MemoryIndex = t.MemoryIndex)
End Sub
End Module
True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() Dim myRule = t.FromTo("A", "B") '// Get the parent from the rule Dim parent = myRule.ParentTransformer '// Check if the parent is the original transformer using its unique memory index Console.WriteLine(parent.MemoryIndex = t.MemoryIndex) End Sub End Module
ID: 961
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.Description = "My Main Transformer";
t.Text = "apple banana apple";
var appleRule = t.FromTo("apple", "APPLE");
var bananaRule = t.FromTo("banana", "BANANA");
t.Find();
foreach(var match in t.Matches) {
var rule = match.Rule;
var parent = rule.ParentTransformer;
Console.WriteLine($"Match '{match.Text}' found by rule '{rule.Name}' in transformer '{parent.Description}'");
}
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
Match 'banana' found by rule 'banana' in transformer 'My Main Transformer'
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer' using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.Description = "My Main Transformer"; t.Text = "apple banana apple"; var appleRule = t.FromTo("apple", "APPLE"); var bananaRule = t.FromTo("banana", "BANANA"); t.Find(); foreach(var match in t.Matches) { var rule = match.Rule; var parent = rule.ParentTransformer; Console.WriteLine($"Match '{match.Text}' found by rule '{rule.Name}' in transformer '{parent.Description}'"); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.Description("My Main Transformer");
t.Text("apple banana apple");
auto appleRule = t.FromTo("apple", "APPLE");
auto bananaRule = t.FromTo("banana", "BANANA");
t.Find();
for(auto match : t.Matches()) {
auto rule = match.Rule();
auto parent = rule.ParentTransformer();
cout << "Match '" << match.Text() << "' found by rule '" << rule.Name() << "' in transformer '" << parent.Description() << "'" << endl;
}
}
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
Match 'banana' found by rule 'banana' in transformer 'My Main Transformer'
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.Description("My Main Transformer"); t.Text("apple banana apple"); auto appleRule = t.FromTo("apple", "APPLE"); auto bananaRule = t.FromTo("banana", "BANANA"); t.Find(); for(auto match : t.Matches()) { auto rule = match.Rule(); auto parent = rule.ParentTransformer(); cout << "Match '" << match.Text() << "' found by rule '" << rule.Name() << "' in transformer '" << parent.Description() << "'" << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.Description = "My Main Transformer"
t.Text = "apple banana apple"
Dim appleRule = t.FromTo("apple", "APPLE")
Dim bananaRule = t.FromTo("banana", "BANANA")
t.Find()
For Each match In t.Matches
Dim rule = match.Rule
Dim parent = rule.ParentTransformer
Console.WriteLine($"Match '{match.Text}' found by rule '{rule.Name}' in transformer '{parent.Description}'")
Next
End Sub
End Module
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
Match 'banana' found by rule 'banana' in transformer 'My Main Transformer'
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.Description = "My Main Transformer" t.Text = "apple banana apple" Dim appleRule = t.FromTo("apple", "APPLE") Dim bananaRule = t.FromTo("banana", "BANANA") t.Find() For Each match In t.Matches Dim rule = match.Rule Dim parent = rule.ParentTransformer Console.WriteLine($"Match '{match.Text}' found by rule '{rule.Name}' in transformer '{parent.Description}'") Next End Sub End Module
ID: 962
using uCalcSoftware;
var uc = new uCalc();
var main_t = new uCalc.Transformer();
main_t.Description = "Main Transformer";
// Create an outer rule in the main transformer
var outerRule = main_t.Pattern("OUTER({body})");
// Get a local transformer for the outer rule
var local_t = outerRule.LocalTransformer;
local_t.Description = "Local Transformer";
// Create an inner rule inside the local transformer
var innerRule = local_t.FromTo("INNER", "inner_match");
// Verify the parent of the outer rule is the main transformer
Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}");
// Verify the parent of the inner rule is the local transformer
Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}");
Outer rule's parent: Main Transformer
Inner rule's parent: Local Transformer using uCalcSoftware; var uc = new uCalc(); var main_t = new uCalc.Transformer(); main_t.Description = "Main Transformer"; // Create an outer rule in the main transformer var outerRule = main_t.Pattern("OUTER({body})"); // Get a local transformer for the outer rule var local_t = outerRule.LocalTransformer; local_t.Description = "Local Transformer"; // Create an inner rule inside the local transformer var innerRule = local_t.FromTo("INNER", "inner_match"); // Verify the parent of the outer rule is the main transformer Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}"); // Verify the parent of the inner rule is the local transformer Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer main_t;
main_t.Description("Main Transformer");
// Create an outer rule in the main transformer
auto outerRule = main_t.Pattern("OUTER({body})");
// Get a local transformer for the outer rule
auto local_t = outerRule.LocalTransformer();
local_t.Description("Local Transformer");
// Create an inner rule inside the local transformer
auto innerRule = local_t.FromTo("INNER", "inner_match");
// Verify the parent of the outer rule is the main transformer
cout << "Outer rule's parent: " << outerRule.ParentTransformer().Description() << endl;
// Verify the parent of the inner rule is the local transformer
cout << "Inner rule's parent: " << innerRule.ParentTransformer().Description() << endl;
}
Outer rule's parent: Main Transformer
Inner rule's parent: Local Transformer #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer main_t; main_t.Description("Main Transformer"); // Create an outer rule in the main transformer auto outerRule = main_t.Pattern("OUTER({body})"); // Get a local transformer for the outer rule auto local_t = outerRule.LocalTransformer(); local_t.Description("Local Transformer"); // Create an inner rule inside the local transformer auto innerRule = local_t.FromTo("INNER", "inner_match"); // Verify the parent of the outer rule is the main transformer cout << "Outer rule's parent: " << outerRule.ParentTransformer().Description() << endl; // Verify the parent of the inner rule is the local transformer cout << "Inner rule's parent: " << innerRule.ParentTransformer().Description() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim main_t As New uCalc.Transformer()
main_t.Description = "Main Transformer"
'// Create an outer rule in the main transformer
Dim outerRule = main_t.Pattern("OUTER({body})")
'// Get a local transformer for the outer rule
Dim local_t = outerRule.LocalTransformer
local_t.Description = "Local Transformer"
'// Create an inner rule inside the local transformer
Dim innerRule = local_t.FromTo("INNER", "inner_match")
'// Verify the parent of the outer rule is the main transformer
Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}")
'// Verify the parent of the inner rule is the local transformer
Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}")
End Sub
End Module
Outer rule's parent: Main Transformer
Inner rule's parent: Local Transformer Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim main_t As New uCalc.Transformer() main_t.Description = "Main Transformer" '// Create an outer rule in the main transformer Dim outerRule = main_t.Pattern("OUTER({body})") '// Get a local transformer for the outer rule Dim local_t = outerRule.LocalTransformer local_t.Description = "Local Transformer" '// Create an inner rule inside the local transformer Dim innerRule = local_t.FromTo("INNER", "inner_match") '// Verify the parent of the outer rule is the main transformer Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}") '// Verify the parent of the inner rule is the local transformer Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}") End Sub End Module
ID: 132
using uCalcSoftware;
var uc = new uCalc();
var Txt = "Test a b c. x y z";
var FirstTransform = uc.NewTransformer().SetText(Txt).SetDescription("First Transformer");
var aaa = FirstTransform.FromTo("Test {etc}.", "[{etc}]");
var SecondTransform = uc.NewTransformer().SetDescription("Second Transformer");
var bbb = SecondTransform.FromTo("Test {etc}.", "({etc})");
Console.WriteLine(aaa.ParentTransformer.Description);
Console.WriteLine(FirstTransform.Transform().Text);
Console.WriteLine("");
Console.WriteLine(SecondTransform.Description);
Console.WriteLine(bbb.ParentTransformer.Transform(Txt).Text);
First Transformer
[a b c] x y z
Second Transformer
(a b c) x y z using uCalcSoftware; var uc = new uCalc(); var Txt = "Test a b c. x y z"; var FirstTransform = uc.NewTransformer().SetText(Txt).SetDescription("First Transformer"); var aaa = FirstTransform.FromTo("Test {etc}.", "[{etc}]"); var SecondTransform = uc.NewTransformer().SetDescription("Second Transformer"); var bbb = SecondTransform.FromTo("Test {etc}.", "({etc})"); Console.WriteLine(aaa.ParentTransformer.Description); Console.WriteLine(FirstTransform.Transform().Text); Console.WriteLine(""); Console.WriteLine(SecondTransform.Description); Console.WriteLine(bbb.ParentTransformer.Transform(Txt).Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto Txt = "Test a b c. x y z";
auto FirstTransform = uc.NewTransformer().SetText(Txt).SetDescription("First Transformer");
auto aaa = FirstTransform.FromTo("Test {etc}.", "[{etc}]");
auto SecondTransform = uc.NewTransformer().SetDescription("Second Transformer");
auto bbb = SecondTransform.FromTo("Test {etc}.", "({etc})");
cout << aaa.ParentTransformer().Description() << endl;
cout << FirstTransform.Transform().Text() << endl;
cout << "" << endl;
cout << SecondTransform.Description() << endl;
cout << bbb.ParentTransformer().Transform(Txt).Text() << endl;
}
First Transformer
[a b c] x y z
Second Transformer
(a b c) x y z #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto Txt = "Test a b c. x y z"; auto FirstTransform = uc.NewTransformer().SetText(Txt).SetDescription("First Transformer"); auto aaa = FirstTransform.FromTo("Test {etc}.", "[{etc}]"); auto SecondTransform = uc.NewTransformer().SetDescription("Second Transformer"); auto bbb = SecondTransform.FromTo("Test {etc}.", "({etc})"); cout << aaa.ParentTransformer().Description() << endl; cout << FirstTransform.Transform().Text() << endl; cout << "" << endl; cout << SecondTransform.Description() << endl; cout << bbb.ParentTransformer().Transform(Txt).Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim Txt = "Test a b c. x y z"
Dim FirstTransform = uc.NewTransformer().SetText(Txt).SetDescription("First Transformer")
Dim aaa = FirstTransform.FromTo("Test {etc}.", "[{etc}]")
Dim SecondTransform = uc.NewTransformer().SetDescription("Second Transformer")
Dim bbb = SecondTransform.FromTo("Test {etc}.", "({etc})")
Console.WriteLine(aaa.ParentTransformer.Description)
Console.WriteLine(FirstTransform.Transform().Text)
Console.WriteLine("")
Console.WriteLine(SecondTransform.Description)
Console.WriteLine(bbb.ParentTransformer.Transform(Txt).Text)
End Sub
End Module
First Transformer
[a b c] x y z
Second Transformer
(a b c) x y z Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim Txt = "Test a b c. x y z" Dim FirstTransform = uc.NewTransformer().SetText(Txt).SetDescription("First Transformer") Dim aaa = FirstTransform.FromTo("Test {etc}.", "[{etc}]") Dim SecondTransform = uc.NewTransformer().SetDescription("Second Transformer") Dim bbb = SecondTransform.FromTo("Test {etc}.", "({etc})") Console.WriteLine(aaa.ParentTransformer.Description) Console.WriteLine(FirstTransform.Transform().Text) Console.WriteLine("") Console.WriteLine(SecondTransform.Description) Console.WriteLine(bbb.ParentTransformer.Transform(Txt).Text) End Sub End Module