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.
{@Literal}
Product:
Class:
Remarks
Description: A category matcher that identifies any token defined as a literal constant value (e.g., numbers, quoted strings, or booleans).
The {@Literal} directive is a broad matcher used within a uCalc::Transformer to target data values. Unlike specific matchers like {@Number} or {@String}, {@Literal} matches any token that represents a fixed value rather than an identifier or an operator.
Types of Literals
By default, {@Literal} will match:
- Numbers:
123,45.67,0xFF - Strings:
"Hello World",'Single Quote' - Booleans:
true,false(if defined as literal tokens)
Choosing Precision
While {@Literal} is convenient for general data manipulation, uCalc allows for higher precision. If your transformation logic depends on the type of data (e.g., you want to format numbers but leave strings alone), you should use the more specific directives:
{@Number}: For numeric values only.{@String}: For quoted text values only.
Inverse Matching with !
The universal inversion operator ! can be applied to this category:
{@Literal}: Matches any constant value.{!Literal}: Matches any token that is not a literal (e.g., variable names, keywords, operators like+orif).
Why uCalc?
In many parsers, you have to write a complex regex that accounts for every possible numeric format and quote style. {@Literal} leverages uCalc's built-in token categorization, making your patterns immune to changes in how numbers or strings are defined.
Examples
Identifying all literal values in an expression and tagging them.
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@Literal:val}", "VAL({val})");
Console.WriteLine(t.Transform("""
x = 10 + "abc"
"""));
x = VAL(10) + VAL("abc") using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@Literal:val}", "VAL({val})"); Console.WriteLine(t.Transform(""" x = 10 + "abc" """));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@Literal:val}", "VAL({val})");
cout << t.Transform(R"(x = 10 + "abc")") << endl;
}
x = VAL(10) + VAL("abc") #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@Literal:val}", "VAL({val})"); cout << t.Transform(R"(x = 10 + "abc")") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@Literal:val}", "VAL({val})")
Console.WriteLine(t.Transform("x = 10 + ""abc"""))
End Sub
End Module
x = VAL(10) + VAL("abc") Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@Literal:val}", "VAL({val})") Console.WriteLine(t.Transform("x = 10 + ""abc""")) End Sub End Module
(Real World: Value Masking)
using uCalcSoftware;
var uc = new uCalc();
// Creating a "Clean View" of a log or configuration file by replacing all
// actual data values with a placeholder, leaving only the structural identifiers.
var t = new uCalc.Transformer();
// Replace every literal with a generic placeholder
t.FromTo("{@Literal}", "?");
string input = """
setting_a = 500; setting_b = "active";
""";
Console.WriteLine(t.Transform(input));
setting_a = ?; setting_b = ?; using uCalcSoftware; var uc = new uCalc(); // Creating a "Clean View" of a log or configuration file by replacing all // actual data values with a placeholder, leaving only the structural identifiers. var t = new uCalc.Transformer(); // Replace every literal with a generic placeholder t.FromTo("{@Literal}", "?"); string input = """ setting_a = 500; setting_b = "active"; """; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Creating a "Clean View" of a log or configuration file by replacing all
// actual data values with a placeholder, leaving only the structural identifiers.
uCalc::Transformer t;
// Replace every literal with a generic placeholder
t.FromTo("{@Literal}", "?");
string input = R"(setting_a = 500; setting_b = "active";)";
cout << t.Transform(input) << endl;
}
setting_a = ?; setting_b = ?; #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Creating a "Clean View" of a log or configuration file by replacing all // actual data values with a placeholder, leaving only the structural identifiers. uCalc::Transformer t; // Replace every literal with a generic placeholder t.FromTo("{@Literal}", "?"); string input = R"(setting_a = 500; setting_b = "active";)"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Creating a "Clean View" of a log or configuration file by replacing all
'// actual data values with a placeholder, leaving only the structural identifiers.
Dim t As New uCalc.Transformer()
'// Replace every literal with a generic placeholder
t.FromTo("{@Literal}", "?")
Dim input As String = "setting_a = 500; setting_b = ""active"";"
Console.WriteLine(t.Transform(input))
End Sub
End Module
setting_a = ?; setting_b = ?; Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Creating a "Clean View" of a log or configuration file by replacing all '// actual data values with a placeholder, leaving only the structural identifiers. Dim t As New uCalc.Transformer() '// Replace every literal with a generic placeholder t.FromTo("{@Literal}", "?") Dim input As String = "setting_a = 500; setting_b = ""active"";" Console.WriteLine(t.Transform(input)) End Sub End Module