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.
uCalc allows you to group segments of a pattern using curly braces { ... }. This is primarily used to delimit the scope of Alternative Parts (|) or to create complex structures inside variables.
Recursive Nesting:Patterns can be nested arbitrarily deep. For example:
{ A | B } can contain an Optional part [ ... ].Menu { Open [ Recent { File | Project } ] | Save }.Syntax:
Start { OptionA | OptionB } End{name: OptionA | OptionB }{name}.Ambiguity Resolution:Since {name} denotes a variable and { pattern } denotes a group, uCalc distinguishes them based on content:
{x}).| or multiple tokens (e.g., { A | B }).(...):() for grouping and capturing. uCalc uses curly braces {} for everything—variables, groups, and blocks. This creates a unified syntax where "everything dynamic is in braces."(A|B) captures automatically (Group 1). You have to use (?:A|B) to avoid capturing. In uCalc, { A | B } is purely structural (non-capturing) unless you explicitly name it {val: A | B}. This avoids "index shifting" bugs.ID: 242
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Matches "File Open" or "File Close".
// Capture needs explicit naming.
t.FromTo("File {cmd: Open | Close }", "Command: {cmd}");
Console.WriteLine(t.Transform("File Open"));
Console.WriteLine(t.Transform("File Close"));
Command: Open
Command: Close using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Matches "File Open" or "File Close". // Capture needs explicit naming. t.FromTo("File {cmd: Open | Close }", "Command: {cmd}"); Console.WriteLine(t.Transform("File Open")); Console.WriteLine(t.Transform("File Close"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Matches "File Open" or "File Close".
// Capture needs explicit naming.
t.FromTo("File {cmd: Open | Close }", "Command: {cmd}");
cout << t.Transform("File Open") << endl;
cout << t.Transform("File Close") << endl;
}
Command: Open
Command: Close #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Matches "File Open" or "File Close". // Capture needs explicit naming. t.FromTo("File {cmd: Open | Close }", "Command: {cmd}"); cout << t.Transform("File Open") << endl; cout << t.Transform("File Close") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Matches "File Open" or "File Close".
'// Capture needs explicit naming.
t.FromTo("File {cmd: Open | Close }", "Command: {cmd}")
Console.WriteLine(t.Transform("File Open"))
Console.WriteLine(t.Transform("File Close"))
End Sub
End Module
Command: Open
Command: Close Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Matches "File Open" or "File Close". '// Capture needs explicit naming. t.FromTo("File {cmd: Open | Close }", "Command: {cmd}") Console.WriteLine(t.Transform("File Open")) Console.WriteLine(t.Transform("File Close")) End Sub End Module
ID: 243
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Pattern: "Set" followed by (Color OR (Size followed by Big/Small))
t.FromTo("Set {prop: Color | Size { Big | Small } }", "Property: {prop}");
Console.WriteLine(t.Transform("Set Color"));
Console.WriteLine(t.Transform("Set Size Big"));
Console.WriteLine(t.Transform("Set Size Small"));
Property: Color
Property: Size Big
Property: Size Small using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Pattern: "Set" followed by (Color OR (Size followed by Big/Small)) t.FromTo("Set {prop: Color | Size { Big | Small } }", "Property: {prop}"); Console.WriteLine(t.Transform("Set Color")); Console.WriteLine(t.Transform("Set Size Big")); Console.WriteLine(t.Transform("Set Size Small"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Pattern: "Set" followed by (Color OR (Size followed by Big/Small))
t.FromTo("Set {prop: Color | Size { Big | Small } }", "Property: {prop}");
cout << t.Transform("Set Color") << endl;
cout << t.Transform("Set Size Big") << endl;
cout << t.Transform("Set Size Small") << endl;
}
Property: Color
Property: Size Big
Property: Size Small #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Pattern: "Set" followed by (Color OR (Size followed by Big/Small)) t.FromTo("Set {prop: Color | Size { Big | Small } }", "Property: {prop}"); cout << t.Transform("Set Color") << endl; cout << t.Transform("Set Size Big") << endl; cout << t.Transform("Set Size Small") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Pattern: "Set" followed by (Color OR (Size followed by Big/Small))
t.FromTo("Set {prop: Color | Size { Big | Small } }", "Property: {prop}")
Console.WriteLine(t.Transform("Set Color"))
Console.WriteLine(t.Transform("Set Size Big"))
Console.WriteLine(t.Transform("Set Size Small"))
End Sub
End Module
Property: Color
Property: Size Big
Property: Size Small Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Pattern: "Set" followed by (Color OR (Size followed by Big/Small)) t.FromTo("Set {prop: Color | Size { Big | Small } }", "Property: {prop}") Console.WriteLine(t.Transform("Set Color")) Console.WriteLine(t.Transform("Set Size Big")) Console.WriteLine(t.Transform("Set Size Small")) End Sub End Module
ID: 244
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Structure:
// 1. Alternation: "Open" OR "Save"
// 2. Inside "Open": Optional "Recent"
// 3. Inside "Recent": Alternation "File" OR "Project"
var pattern = "Menu { Open [ Recent {type: File | Project } ] | Save }";
t.FromTo(pattern, "Action Detected");
Console.WriteLine(t.Transform("Menu Save")); // Match (Simple Alternation)
Console.WriteLine(t.Transform("Menu Open")); // Match (Optional omitted)
Console.WriteLine(t.Transform("Menu Open Recent File")); // Match (Deep nesting)
Console.WriteLine(t.Transform("Menu Open Recent Project")); // Match (Deep nesting alt)
Action Detected
Action Detected
Action Detected
Action Detected using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Structure: // 1. Alternation: "Open" OR "Save" // 2. Inside "Open": Optional "Recent" // 3. Inside "Recent": Alternation "File" OR "Project" var pattern = "Menu { Open [ Recent {type: File | Project } ] | Save }"; t.FromTo(pattern, "Action Detected"); Console.WriteLine(t.Transform("Menu Save")); // Match (Simple Alternation) Console.WriteLine(t.Transform("Menu Open")); // Match (Optional omitted) Console.WriteLine(t.Transform("Menu Open Recent File")); // Match (Deep nesting) Console.WriteLine(t.Transform("Menu Open Recent Project")); // Match (Deep nesting alt)
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Structure:
// 1. Alternation: "Open" OR "Save"
// 2. Inside "Open": Optional "Recent"
// 3. Inside "Recent": Alternation "File" OR "Project"
auto pattern = "Menu { Open [ Recent {type: File | Project } ] | Save }";
t.FromTo(pattern, "Action Detected");
cout << t.Transform("Menu Save") << endl; // Match (Simple Alternation)
cout << t.Transform("Menu Open") << endl; // Match (Optional omitted)
cout << t.Transform("Menu Open Recent File") << endl; // Match (Deep nesting)
cout << t.Transform("Menu Open Recent Project") << endl; // Match (Deep nesting alt)
}
Action Detected
Action Detected
Action Detected
Action Detected #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Structure: // 1. Alternation: "Open" OR "Save" // 2. Inside "Open": Optional "Recent" // 3. Inside "Recent": Alternation "File" OR "Project" auto pattern = "Menu { Open [ Recent {type: File | Project } ] | Save }"; t.FromTo(pattern, "Action Detected"); cout << t.Transform("Menu Save") << endl; // Match (Simple Alternation) cout << t.Transform("Menu Open") << endl; // Match (Optional omitted) cout << t.Transform("Menu Open Recent File") << endl; // Match (Deep nesting) cout << t.Transform("Menu Open Recent Project") << endl; // Match (Deep nesting alt) }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Structure:
'// 1. Alternation: "Open" OR "Save"
'// 2. Inside "Open": Optional "Recent"
'// 3. Inside "Recent": Alternation "File" OR "Project"
Dim pattern = "Menu { Open [ Recent {type: File | Project } ] | Save }"
t.FromTo(pattern, "Action Detected")
Console.WriteLine(t.Transform("Menu Save")) '// Match (Simple Alternation)
Console.WriteLine(t.Transform("Menu Open")) '// Match (Optional omitted)
Console.WriteLine(t.Transform("Menu Open Recent File")) '// Match (Deep nesting)
Console.WriteLine(t.Transform("Menu Open Recent Project")) '// Match (Deep nesting alt)
End Sub
End Module
Action Detected
Action Detected
Action Detected
Action Detected Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Structure: '// 1. Alternation: "Open" OR "Save" '// 2. Inside "Open": Optional "Recent" '// 3. Inside "Recent": Alternation "File" OR "Project" Dim pattern = "Menu { Open [ Recent {type: File | Project } ] | Save }" t.FromTo(pattern, "Action Detected") Console.WriteLine(t.Transform("Menu Save")) '// Match (Simple Alternation) Console.WriteLine(t.Transform("Menu Open")) '// Match (Optional omitted) Console.WriteLine(t.Transform("Menu Open Recent File")) '// Match (Deep nesting) Console.WriteLine(t.Transform("Menu Open Recent Project")) '// Match (Deep nesting alt) End Sub End Module