A postfix modifier that instructs a pattern variable to ignore balanced nesting levels (brackets, parentheses, etc.) and stop at the literal next terminal token even if inside brackets
Product:
Class:
Warning
uCalc API Preview Release Notice:The uCalc engine has successfully transitioned to modern cross-platform environments.The next phase envolves some structural changes, performance optimizations, and API refinements.The API is subject to breaking changes prior to the stable release. Please evaluate the preview version thoroughly before production use.
Shortcut: ^
Associated Property: BracketSensitive
By default, uCalc is Bracket Sensitive. This means balanced bracket pairs with text inside of them are treated as a unit, somewhat like quoted text. A variable match will not straddle the outside and inside of a bracket structure and match just part of the structure. Unlike quoted text, however, patterns from other rules can be matched within a bracket structure as long as the match is fully confined within the structure boundaries.
The Bracket Nesting Override (^) is used to break this structural integrity for specific, surgical transformations.
While the ^ symbol provides per-variable control, you can toggle this behavior for the entire rule using the BracketSensitive property on the rule.
rule.BracketSensitive = true: (Default) All variables in a rule respect bracket levels.rule.BracketSensitive = false: All variables in a rule behave as if they have the ^ postfix unless otherwise specified.To affect all rules in a transformer, use the DefaultRuleSet property.
ID: 212
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("begin {body} end", "bracket not ignored: <{@Self}>");
t.FromTo("begin_ {body^} end", "bracket ignored: <{@Self}>");
Console.WriteLine(t.Transform("begin (a b c end) end"));
Console.WriteLine(t.Transform("begin_ (a b c end) end"));
bracket not ignored: <begin (a b c end) end>
bracket ignored: <begin_ (a b c end>) end using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("begin {body} end", "bracket not ignored: <{@Self}>"); t.FromTo("begin_ {body^} end", "bracket ignored: <{@Self}>"); Console.WriteLine(t.Transform("begin (a b c end) end")); Console.WriteLine(t.Transform("begin_ (a b c end) end"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("begin {body} end", "bracket not ignored: <{@Self}>");
t.FromTo("begin_ {body^} end", "bracket ignored: <{@Self}>");
cout << t.Transform("begin (a b c end) end") << endl;
cout << t.Transform("begin_ (a b c end) end") << endl;
}
bracket not ignored: <begin (a b c end) end>
bracket ignored: <begin_ (a b c end>) end #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("begin {body} end", "bracket not ignored: <{@Self}>"); t.FromTo("begin_ {body^} end", "bracket ignored: <{@Self}>"); cout << t.Transform("begin (a b c end) end") << endl; cout << t.Transform("begin_ (a b c end) end") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("begin {body} end", "bracket not ignored: <{@Self}>")
t.FromTo("begin_ {body^} end", "bracket ignored: <{@Self}>")
Console.WriteLine(t.Transform("begin (a b c end) end"))
Console.WriteLine(t.Transform("begin_ (a b c end) end"))
End Sub
End Module
bracket not ignored: <begin (a b c end) end>
bracket ignored: <begin_ (a b c end>) end Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("begin {body} end", "bracket not ignored: <{@Self}>") t.FromTo("begin_ {body^} end", "bracket ignored: <{@Self}>") Console.WriteLine(t.Transform("begin (a b c end) end")) Console.WriteLine(t.Transform("begin_ (a b c end) end")) End Sub End Module
This page last modified on: