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.
IsChildRule = [bool]
Property
Product:Â
Class:Â
Determines if a rule belongs to a nested (local) transformer rather than the main (root) transformer.
Remarks
🌳 Understanding Rule Hierarchy
The IsChildRule property is a boolean flag that indicates whether a rule is part of a nested parsing context. It returns true if the rule was defined on a 'local' transformer—one obtained from another rule's LocalTransformer property. This is a key introspection tool for understanding the scope and hierarchy of your transformation logic.
- Parent Rule (Root): A rule defined directly on a main
Transformerobject. For these rules,IsChildRulereturnsfalse. - Child Rule (Local): A rule defined on the
Transformerobject returned by another rule's@LocalTransformer()property. For these rules,IsChildRulereturnstrue.
This property allows you to distinguish between top-level patterns and sub-patterns that only execute within the scope of a specific parent match. This is crucial for debugging complex, nested parsing logic or for writing generic functions that behave differently based on a rule's scope.
💡 Why uCalc? (Comparative Analysis)
vs. Regular Expressions: Standard regex engines have a 'flat' model; there is no concept of a rule hierarchy. Achieving nested parsing requires complex and often fragile recursive patterns or lookarounds. uCalc's
LocalTransformercreates a true hierarchical parsing model, andIsChildRuleis the built-in tool to inspect this structure. It provides a level of architectural clarity that is absent in traditional regex.vs. Parser Generators (ANTLR, etc.): While parser generators define grammars with clear hierarchical rules (e.g., a
statementcontains anexpression), this hierarchy is static and defined in a grammar file. uCalc's model is entirely dynamic and programmatic. You can build and query these parent-child relationships at runtime, andIsChildRuleis the primary way to do so.
Examples
A succinct example demonstrating the basic distinction between a root rule and a child rule.
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
var rootRule = t.Pattern("root");
var localTransformer = rootRule.LocalTransformer;
var childRule = localTransformer.Pattern("child");
Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}");
Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}");
Is 'rootRule' a child? False
Is 'childRule' a child? True using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); var rootRule = t.Pattern("root"); var localTransformer = rootRule.LocalTransformer; var childRule = localTransformer.Pattern("child"); Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}"); Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc::Transformer t;
auto rootRule = t.Pattern("root");
auto localTransformer = rootRule.LocalTransformer();
auto childRule = localTransformer.Pattern("child");
cout << "Is 'rootRule' a child? " << tf(rootRule.IsChildRule()) << endl;
cout << "Is 'childRule' a child? " << tf(childRule.IsChildRule()) << endl;
}
Is 'rootRule' a child? False
Is 'childRule' a child? 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 rootRule = t.Pattern("root"); auto localTransformer = rootRule.LocalTransformer(); auto childRule = localTransformer.Pattern("child"); cout << "Is 'rootRule' a child? " << tf(rootRule.IsChildRule()) << endl; cout << "Is 'childRule' a child? " << tf(childRule.IsChildRule()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
Dim rootRule = t.Pattern("root")
Dim localTransformer = rootRule.LocalTransformer
Dim childRule = localTransformer.Pattern("child")
Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}")
Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}")
End Sub
End Module
Is 'rootRule' a child? False
Is 'childRule' a child? True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() Dim rootRule = t.Pattern("root") Dim localTransformer = rootRule.LocalTransformer Dim childRule = localTransformer.Pattern("child") Console.WriteLine($"Is 'rootRule' a child? {rootRule.IsChildRule}") Console.WriteLine($"Is 'childRule' a child? {childRule.IsChildRule}") End Sub End Module
Internal Test: Verifies that any rule not on the root transformer is considered a child, regardless of nesting depth.
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
var grandParentRule = t.Pattern("grandparent");
// Create a child
var parentTransformer = grandParentRule.LocalTransformer;
var parentRule = parentTransformer.Pattern("parent");
// Create a grandchild
var childTransformer = parentRule.LocalTransformer;
var childRule = childTransformer.Pattern("child");
Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}");
Console.WriteLine($"Parent is child: {parentRule.IsChildRule}");
Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}");
Grandparent is child: False
Parent is child: True
Child (grandchild) is child: True using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); var grandParentRule = t.Pattern("grandparent"); // Create a child var parentTransformer = grandParentRule.LocalTransformer; var parentRule = parentTransformer.Pattern("parent"); // Create a grandchild var childTransformer = parentRule.LocalTransformer; var childRule = childTransformer.Pattern("child"); Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}"); Console.WriteLine($"Parent is child: {parentRule.IsChildRule}"); Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc::Transformer t;
auto grandParentRule = t.Pattern("grandparent");
// Create a child
auto parentTransformer = grandParentRule.LocalTransformer();
auto parentRule = parentTransformer.Pattern("parent");
// Create a grandchild
auto childTransformer = parentRule.LocalTransformer();
auto childRule = childTransformer.Pattern("child");
cout << "Grandparent is child: " << tf(grandParentRule.IsChildRule()) << endl;
cout << "Parent is child: " << tf(parentRule.IsChildRule()) << endl;
cout << "Child (grandchild) is child: " << tf(childRule.IsChildRule()) << endl;
}
Grandparent is child: False
Parent is child: True
Child (grandchild) is child: 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 grandParentRule = t.Pattern("grandparent"); // Create a child auto parentTransformer = grandParentRule.LocalTransformer(); auto parentRule = parentTransformer.Pattern("parent"); // Create a grandchild auto childTransformer = parentRule.LocalTransformer(); auto childRule = childTransformer.Pattern("child"); cout << "Grandparent is child: " << tf(grandParentRule.IsChildRule()) << endl; cout << "Parent is child: " << tf(parentRule.IsChildRule()) << endl; cout << "Child (grandchild) is child: " << tf(childRule.IsChildRule()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
Dim grandParentRule = t.Pattern("grandparent")
'// Create a child
Dim parentTransformer = grandParentRule.LocalTransformer
Dim parentRule = parentTransformer.Pattern("parent")
'// Create a grandchild
Dim childTransformer = parentRule.LocalTransformer
Dim childRule = childTransformer.Pattern("child")
Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}")
Console.WriteLine($"Parent is child: {parentRule.IsChildRule}")
Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}")
End Sub
End Module
Grandparent is child: False
Parent is child: True
Child (grandchild) is child: True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() Dim grandParentRule = t.Pattern("grandparent") '// Create a child Dim parentTransformer = grandParentRule.LocalTransformer Dim parentRule = parentTransformer.Pattern("parent") '// Create a grandchild Dim childTransformer = parentRule.LocalTransformer Dim childRule = childTransformer.Pattern("child") Console.WriteLine($"Grandparent is child: {grandParentRule.IsChildRule}") Console.WriteLine($"Parent is child: {parentRule.IsChildRule}") Console.WriteLine($"Child (grandchild) is child: {childRule.IsChildRule}") End Sub End Module
LocalTransformer, HasLocalTransformer, IsChildRule
using uCalcSoftware;
var uc = new uCalc();
// Note the change in section/div/h2
var t = uc.NewTransformer();
var rule = t.Pattern("{body} ").SetStatementSensitive(false);
var section = rule.LocalTransformer;
section.FromTo("{text}
", "====> {@Eval: UCase(text)} <====
");
section.SkipOver("&{entity};");
var ch = section.FromTo("{text}
", "SELECTED: {text}
");
Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}");
Console.WriteLine($"rule is a child rule: {rule.IsChildRule}");
Console.WriteLine($"ch is a child rule: {ch.IsChildRule}");
var HtmlText =
"""
Article One
This is the first article.
Article Two
This is the second article.
Article Three
This one is inside a <section>.
Article Four
This is the fourth article.
""";
t.Text = HtmlText;
t.Transform();
Console.WriteLine(t.Text);
Has a local transformer: True
rule is a child rule: False
ch is a child rule: True
<div class="article" data-id="1">
<h2>Article One</h2>
<p>This is the first article.</p>
</div>
<div class="article" data-id="2">
<h2>Article Two</h2>
<p>This is the second article.</p>
</div>
<section>
<div class="article" data-id="3">
<h1>====> ARTICLE THREE <====</h1>
<p>SELECTED: This one is inside a <section>.</p>
</div>
</section>
<div class="article" data-id="4">
<h2>Article Four</h2>
<p>This is the fourth article.</p>
</div> using uCalcSoftware; var uc = new uCalc(); // Note the change in section/div/h2 var t = uc.NewTransformer(); var rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false); var section = rule.LocalTransformer; section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>"); section.SkipOver("&{entity};"); var ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>"); Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}"); Console.WriteLine($"rule is a child rule: {rule.IsChildRule}"); Console.WriteLine($"ch is a child rule: {ch.IsChildRule}"); var HtmlText = """ <div class="article" data-id="1"> <h2>Article One</h2> <p>This is the first article.</p> </div> <div class="article" data-id="2"> <h2>Article Two</h2> <p>This is the second article.</p> </div> <section> <div class="article" data-id="3"> <h2>Article Three</h2> <p>This one is inside a <section>.</p> </div> </section> <div class="article" data-id="4"> <h2>Article Four</h2> <p>This is the fourth article.</p> </div> """; t.Text = HtmlText; t.Transform(); Console.WriteLine(t.Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
// Note the change in section/div/h2
auto t = uc.NewTransformer();
auto rule = t.Pattern("{body} ").SetStatementSensitive(false);
auto section = rule.LocalTransformer();
section.FromTo("{text}
", "====> {@Eval: UCase(text)} <====
");
section.SkipOver("&{entity};");
auto ch = section.FromTo("{text}
", "SELECTED: {text}
");
cout << "Has a local transformer: " << tf(rule.HasLocalTransformer()) << endl;
cout << "rule is a child rule: " << tf(rule.IsChildRule()) << endl;
cout << "ch is a child rule: " << tf(ch.IsChildRule()) << endl;
auto HtmlText =
R"(
Article One
This is the first article.
Article Two
This is the second article.
Article Three
This one is inside a <section>.
Article Four
This is the fourth article.
)";
t.Text(HtmlText);
t.Transform();
cout << t.Text() << endl;
}
Has a local transformer: True
rule is a child rule: False
ch is a child rule: True
<div class="article" data-id="1">
<h2>Article One</h2>
<p>This is the first article.</p>
</div>
<div class="article" data-id="2">
<h2>Article Two</h2>
<p>This is the second article.</p>
</div>
<section>
<div class="article" data-id="3">
<h1>====> ARTICLE THREE <====</h1>
<p>SELECTED: This one is inside a <section>.</p>
</div>
</section>
<div class="article" data-id="4">
<h2>Article Four</h2>
<p>This is the fourth article.</p>
</div> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; // Note the change in section/div/h2 auto t = uc.NewTransformer(); auto rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false); auto section = rule.LocalTransformer(); section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>"); section.SkipOver("&{entity};"); auto ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>"); cout << "Has a local transformer: " << tf(rule.HasLocalTransformer()) << endl; cout << "rule is a child rule: " << tf(rule.IsChildRule()) << endl; cout << "ch is a child rule: " << tf(ch.IsChildRule()) << endl; auto HtmlText = R"( <div class="article" data-id="1"> <h2>Article One</h2> <p>This is the first article.</p> </div> <div class="article" data-id="2"> <h2>Article Two</h2> <p>This is the second article.</p> </div> <section> <div class="article" data-id="3"> <h2>Article Three</h2> <p>This one is inside a <section>.</p> </div> </section> <div class="article" data-id="4"> <h2>Article Four</h2> <p>This is the fourth article.</p> </div> )"; t.Text(HtmlText); t.Transform(); cout << t.Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Note the change in section/div/h2
Dim t = uc.NewTransformer()
Dim rule = t.Pattern("{body} ").SetStatementSensitive(false)
Dim section = rule.LocalTransformer
section.FromTo("{text}
", "====> {@Eval: UCase(text)} <====
")
section.SkipOver("&{entity};")
Dim ch = section.FromTo("{text}
", "SELECTED: {text}
")
Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}")
Console.WriteLine($"rule is a child rule: {rule.IsChildRule}")
Console.WriteLine($"ch is a child rule: {ch.IsChildRule}")
Dim HtmlText =
"
Article One
This is the first article.
Article Two
This is the second article.
Article Three
This one is inside a <section>.
Article Four
This is the fourth article.
"
t.Text = HtmlText
t.Transform()
Console.WriteLine(t.Text)
End Sub
End Module
Has a local transformer: True
rule is a child rule: False
ch is a child rule: True
<div class="article" data-id="1">
<h2>Article One</h2>
<p>This is the first article.</p>
</div>
<div class="article" data-id="2">
<h2>Article Two</h2>
<p>This is the second article.</p>
</div>
<section>
<div class="article" data-id="3">
<h1>====> ARTICLE THREE <====</h1>
<p>SELECTED: This one is inside a <section>.</p>
</div>
</section>
<div class="article" data-id="4">
<h2>Article Four</h2>
<p>This is the fourth article.</p>
</div> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Note the change in section/div/h2 Dim t = uc.NewTransformer() Dim rule = t.Pattern("<section>{body}</section>").SetStatementSensitive(false) Dim section = rule.LocalTransformer section.FromTo("<h2>{text}</h2>", "<h1>====> {@Eval: UCase(text)} <====</h1>") section.SkipOver("&{entity};") Dim ch = section.FromTo("<p>{text}</p>", "<p>SELECTED: {text}</p>") Console.WriteLine($"Has a local transformer: {rule.HasLocalTransformer}") Console.WriteLine($"rule is a child rule: {rule.IsChildRule}") Console.WriteLine($"ch is a child rule: {ch.IsChildRule}") Dim HtmlText = " <div class=""article"" data-id=""1""> <h2>Article One</h2> <p>This is the first article.</p> </div> <div class=""article"" data-id=""2""> <h2>Article Two</h2> <p>This is the second article.</p> </div> <section> <div class=""article"" data-id=""3""> <h2>Article Three</h2> <p>This one is inside a <section>.</p> </div> </section> <div class=""article"" data-id=""4""> <h2>Article Four</h2> <p>This is the fourth article.</p> </div> " t.Text = HtmlText t.Transform() Console.WriteLine(t.Text) End Sub End Module