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.

{@Bracket}

Product: 

Class: 

Remarks

Description: A category matcher that identifies any token defined as an opening bracket (e.g., (, [, {, or custom patterns like < or begin).

The {@Bracket} token directive is a high-level matcher within a uCalc::Transformer. Unlike a character literal, it does not look for a specific symbol; instead, it queries the uCalc engine to see if the next token in the input stream belongs to the Opening Bracket category.

The Power of Category Definition

By default, uCalc defines (, [, and { as opening brackets. However, these are not hard-coded. Because {@Bracket} relies on the underlying token definitions:

  • Multi-character support: If you define the word begin as an opening bracket, {@Bracket} will match it.
  • Customizability: You can add angle brackets (<) or remove default ones based on your language requirements.
  • Ambiguity Handling: Angle brackets are excluded by default to prevent conflict with mathematical "less-than" operators.

Integration with {@CloseBracket}

{@Bracket} matches only the opening component. To build patterns that capture content between brackets, it is used in tandem with {@CloseBracket} (Topic 804). This separation allows for granular control over how different styles of scopes are opened and closed.

Inverse Matching with !

You can invert the logic of this directive using the ! operator.

  • {@Bracket}: Matches any token that is an opening bracket.
  • {!Bracket}: Matches any token that is not an opening bracket.

This is extremely useful for "negative matching," such as identifying all content that exists outside of a bracketed scope.

Examples

Matching by token type
				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();

t.FromTo("{@String:txt}", "<<InnerQuote={txt}><TxtWithQuotes={txt(0)}>>");
t.FromTo("{@Number:MyNum}", "<NumericValue={MyNum}>");
t.FromTo("{@Bracket:MyBrack}", "<Brack={MyBrack}>");
t.FromTo("{@CloseBracket:CloseBr}", "<CloseBrack={CloseBr}>");
t.FromTo("{@StatementSeparator:Sep}", "<Separator={Sep}>");
t.FromTo("{@Alphanumeric:alpha}", "<Alpha={alpha}>");
t.FromTo("{@Whitespace:ws}", "<whitespace count={@Eval: Length(ws)}>");
t.FromTo("{@Reducible:r}", "<Reducible={r}>");
t.FromTo("{@Newline}", "<New line{@Newline}>");

var s = """
This is   55.2*6 "Hello world";
'Single quote'(parenth)
""";

Console.WriteLine(t.Filter(s).Matches.Text);
				
			
<Alpha=This>
<whitespace count=1>
<Alpha=is>
<whitespace count=3>
<NumericValue=55.2>
<Reducible=*>
<NumericValue=6>
<whitespace count=1>
<<InnerQuote=Hello world><TxtWithQuotes="Hello world">>
<Separator=;>
<New line
>
<<InnerQuote=Single quote><TxtWithQuotes='Single quote'>>
<Brack=(>
<Alpha=parenth>
<CloseBrack=)>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();

   t.FromTo("{@String:txt}", "<<InnerQuote={txt}><TxtWithQuotes={txt(0)}>>");
   t.FromTo("{@Number:MyNum}", "<NumericValue={MyNum}>");
   t.FromTo("{@Bracket:MyBrack}", "<Brack={MyBrack}>");
   t.FromTo("{@CloseBracket:CloseBr}", "<CloseBrack={CloseBr}>");
   t.FromTo("{@StatementSeparator:Sep}", "<Separator={Sep}>");
   t.FromTo("{@Alphanumeric:alpha}", "<Alpha={alpha}>");
   t.FromTo("{@Whitespace:ws}", "<whitespace count={@Eval: Length(ws)}>");
   t.FromTo("{@Reducible:r}", "<Reducible={r}>");
   t.FromTo("{@Newline}", "<New line{@Newline}>");

   auto s = R"(This is   55.2*6 "Hello world";
'Single quote'(parenth))";

   cout << t.Filter(s).Matches().Text() << endl;
}
				
			
<Alpha=This>
<whitespace count=1>
<Alpha=is>
<whitespace count=3>
<NumericValue=55.2>
<Reducible=*>
<NumericValue=6>
<whitespace count=1>
<<InnerQuote=Hello world><TxtWithQuotes="Hello world">>
<Separator=;>
<New line
>
<<InnerQuote=Single quote><TxtWithQuotes='Single quote'>>
<Brack=(>
<Alpha=parenth>
<CloseBrack=)>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      
      t.FromTo("{@String:txt}", "<<InnerQuote={txt}><TxtWithQuotes={txt(0)}>>")
      t.FromTo("{@Number:MyNum}", "<NumericValue={MyNum}>")
      t.FromTo("{@Bracket:MyBrack}", "<Brack={MyBrack}>")
      t.FromTo("{@CloseBracket:CloseBr}", "<CloseBrack={CloseBr}>")
      t.FromTo("{@StatementSeparator:Sep}", "<Separator={Sep}>")
      t.FromTo("{@Alphanumeric:alpha}", "<Alpha={alpha}>")
      t.FromTo("{@Whitespace:ws}", "<whitespace count={@Eval: Length(ws)}>")
      t.FromTo("{@Reducible:r}", "<Reducible={r}>")
      t.FromTo("{@Newline}", "<New line{@Newline}>")
      
      Dim s = "This is   55.2*6 ""Hello world"";
'Single quote'(parenth)"
      
      Console.WriteLine(t.Filter(s).Matches.Text)
   End Sub
End Module
				
			
<Alpha=This>
<whitespace count=1>
<Alpha=is>
<whitespace count=3>
<NumericValue=55.2>
<Reducible=*>
<NumericValue=6>
<whitespace count=1>
<<InnerQuote=Hello world><TxtWithQuotes="Hello world">>
<Separator=;>
<New line
>
<<InnerQuote=Single quote><TxtWithQuotes='Single quote'>>
<Brack=(>
<Alpha=parenth>
<CloseBrack=)>
Normalizing mixed input by replacing any opening bracket style with a standard parenthesis.
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@Bracket}", "(");

Console.WriteLine(t.Transform("{ x + [ y ] }"));
				
			
( x + ( y ] }
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.FromTo("{@Bracket}", "(");

   cout << t.Transform("{ x + [ y ] }") << endl;
}
				
			
( x + ( y ] }
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.FromTo("{@Bracket}", "(")
      
      Console.WriteLine(t.Transform("{ x + [ y ] }"))
   End Sub
End Module
				
			
( x + ( y ] }
(Real World: Structure Identification) Labeling the start of complex data structures in a mixed text stream.
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@Bracket}", "[START_SCOPE]");

string input = "func { data [ 1, 2 ] }";
Console.WriteLine(t.Transform(input));
				
			
func [START_SCOPE] data [START_SCOPE] 1, 2 ] }
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.FromTo("{@Bracket}", "[START_SCOPE]");

   string input = "func { data [ 1, 2 ] }";
   cout << t.Transform(input) << endl;
}
				
			
func [START_SCOPE] data [START_SCOPE] 1, 2 ] }
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.FromTo("{@Bracket}", "[START_SCOPE]")
      
      Dim input As String = "func { data [ 1, 2 ] }"
      Console.WriteLine(t.Transform(input))
   End Sub
End Module
				
			
func [START_SCOPE] data [START_SCOPE] 1, 2 ] }
(Negative Match) Ensuring that `{@Bracket}` does not match common "bracket-like" characters that are not in its definition (like angle brackets).
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@Bracket}", "FOUND");

// Angle brackets are not included in {@Bracket} by default
Console.WriteLine(t.Transform("vector <int>"));
				
			
vector <int>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.FromTo("{@Bracket}", "FOUND");

   // Angle brackets are not included in {@Bracket} by default
   cout << t.Transform("vector <int>") << endl;
}
				
			
vector <int>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.FromTo("{@Bracket}", "FOUND")
      
      '// Angle brackets are not included in {@Bracket} by default
      Console.WriteLine(t.Transform("vector <int>"))
   End Sub
End Module
				
			
vector <int>