Internal Test: Verifies rule precedence and tag retrieval by traversing the overload chain with NextOverload.
ID: 996
See: Tag = [int]
using uCalcSoftware;
var uc = new uCalc();
// Internal Test: Verifies precedence and tag retrieval via NextOverload
var t = new uCalc.Transformer();
t.Text = "Testing (a b c) Testing x y z! Testing 1 2 3.";
// Rules defined last have higher precedence for the same anchor ("Testing")
var p1 = t.Pattern("Testing {etc}.").SetTag(111);
var p2 = t.Pattern("Testing {etc}!").SetTag(222);
var p3 = t.Pattern("Testing ({etc})").SetTag(333);
// Get the highest precedence rule via Pattern's return value
var highestPriorityRule = p3;
Console.WriteLine($"Highest priority rule tag: {highestPriorityRule.Tag}");
// Walk the overload chain
var midPriorityRule = highestPriorityRule.NextOverload();
Console.WriteLine($"Mid priority rule tag: {midPriorityRule.Tag}");
var lowPriorityRule = midPriorityRule.NextOverload();
Console.WriteLine($"Low priority rule tag: {lowPriorityRule.Tag}");
// The end of the chain should have a tag of 0 (default)
var endOfChain = lowPriorityRule.NextOverload();
Console.WriteLine($"End of chain tag: {endOfChain.Tag}");
Highest priority rule tag: 333
Mid priority rule tag: 222
Low priority rule tag: 111
End of chain tag: 0 using uCalcSoftware; var uc = new uCalc(); // Internal Test: Verifies precedence and tag retrieval via NextOverload var t = new uCalc.Transformer(); t.Text = "Testing (a b c) Testing x y z! Testing 1 2 3."; // Rules defined last have higher precedence for the same anchor ("Testing") var p1 = t.Pattern("Testing {etc}.").SetTag(111); var p2 = t.Pattern("Testing {etc}!").SetTag(222); var p3 = t.Pattern("Testing ({etc})").SetTag(333); // Get the highest precedence rule via Pattern's return value var highestPriorityRule = p3; Console.WriteLine($"Highest priority rule tag: {highestPriorityRule.Tag}"); // Walk the overload chain var midPriorityRule = highestPriorityRule.NextOverload(); Console.WriteLine($"Mid priority rule tag: {midPriorityRule.Tag}"); var lowPriorityRule = midPriorityRule.NextOverload(); Console.WriteLine($"Low priority rule tag: {lowPriorityRule.Tag}"); // The end of the chain should have a tag of 0 (default) var endOfChain = lowPriorityRule.NextOverload(); Console.WriteLine($"End of chain tag: {endOfChain.Tag}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Internal Test: Verifies precedence and tag retrieval via NextOverload
uCalc::Transformer t;
t.Text("Testing (a b c) Testing x y z! Testing 1 2 3.");
// Rules defined last have higher precedence for the same anchor ("Testing")
auto p1 = t.Pattern("Testing {etc}.").SetTag(111);
auto p2 = t.Pattern("Testing {etc}!").SetTag(222);
auto p3 = t.Pattern("Testing ({etc})").SetTag(333);
// Get the highest precedence rule via Pattern's return value
auto highestPriorityRule = p3;
cout << "Highest priority rule tag: " << highestPriorityRule.Tag() << endl;
// Walk the overload chain
auto midPriorityRule = highestPriorityRule.NextOverload();
cout << "Mid priority rule tag: " << midPriorityRule.Tag() << endl;
auto lowPriorityRule = midPriorityRule.NextOverload();
cout << "Low priority rule tag: " << lowPriorityRule.Tag() << endl;
// The end of the chain should have a tag of 0 (default)
auto endOfChain = lowPriorityRule.NextOverload();
cout << "End of chain tag: " << endOfChain.Tag() << endl;
}
Highest priority rule tag: 333
Mid priority rule tag: 222
Low priority rule tag: 111
End of chain tag: 0 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Internal Test: Verifies precedence and tag retrieval via NextOverload uCalc::Transformer t; t.Text("Testing (a b c) Testing x y z! Testing 1 2 3."); // Rules defined last have higher precedence for the same anchor ("Testing") auto p1 = t.Pattern("Testing {etc}.").SetTag(111); auto p2 = t.Pattern("Testing {etc}!").SetTag(222); auto p3 = t.Pattern("Testing ({etc})").SetTag(333); // Get the highest precedence rule via Pattern's return value auto highestPriorityRule = p3; cout << "Highest priority rule tag: " << highestPriorityRule.Tag() << endl; // Walk the overload chain auto midPriorityRule = highestPriorityRule.NextOverload(); cout << "Mid priority rule tag: " << midPriorityRule.Tag() << endl; auto lowPriorityRule = midPriorityRule.NextOverload(); cout << "Low priority rule tag: " << lowPriorityRule.Tag() << endl; // The end of the chain should have a tag of 0 (default) auto endOfChain = lowPriorityRule.NextOverload(); cout << "End of chain tag: " << endOfChain.Tag() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Internal Test: Verifies precedence and tag retrieval via NextOverload
Dim t As New uCalc.Transformer()
t.Text = "Testing (a b c) Testing x y z! Testing 1 2 3."
'// Rules defined last have higher precedence for the same anchor ("Testing")
Dim p1 = t.Pattern("Testing {etc}.").SetTag(111)
Dim p2 = t.Pattern("Testing {etc}!").SetTag(222)
Dim p3 = t.Pattern("Testing ({etc})").SetTag(333)
'// Get the highest precedence rule via Pattern's return value
Dim highestPriorityRule = p3
Console.WriteLine($"Highest priority rule tag: {highestPriorityRule.Tag}")
'// Walk the overload chain
Dim midPriorityRule = highestPriorityRule.NextOverload()
Console.WriteLine($"Mid priority rule tag: {midPriorityRule.Tag}")
Dim lowPriorityRule = midPriorityRule.NextOverload()
Console.WriteLine($"Low priority rule tag: {lowPriorityRule.Tag}")
'// The end of the chain should have a tag of 0 (default)
Dim endOfChain = lowPriorityRule.NextOverload()
Console.WriteLine($"End of chain tag: {endOfChain.Tag}")
End Sub
End Module
Highest priority rule tag: 333
Mid priority rule tag: 222
Low priority rule tag: 111
End of chain tag: 0 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Internal Test: Verifies precedence and tag retrieval via NextOverload Dim t As New uCalc.Transformer() t.Text = "Testing (a b c) Testing x y z! Testing 1 2 3." '// Rules defined last have higher precedence for the same anchor ("Testing") Dim p1 = t.Pattern("Testing {etc}.").SetTag(111) Dim p2 = t.Pattern("Testing {etc}!").SetTag(222) Dim p3 = t.Pattern("Testing ({etc})").SetTag(333) '// Get the highest precedence rule via Pattern's return value Dim highestPriorityRule = p3 Console.WriteLine($"Highest priority rule tag: {highestPriorityRule.Tag}") '// Walk the overload chain Dim midPriorityRule = highestPriorityRule.NextOverload() Console.WriteLine($"Mid priority rule tag: {midPriorityRule.Tag}") Dim lowPriorityRule = midPriorityRule.NextOverload() Console.WriteLine($"Low priority rule tag: {lowPriorityRule.Tag}") '// The end of the chain should have a tag of 0 (default) Dim endOfChain = lowPriorityRule.NextOverload() Console.WriteLine($"End of chain tag: {endOfChain.Tag}") End Sub End Module