Demonstrates the difference in variable capture behavior when StatementSensitive is enabled versus disabled.
ID: 988
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
string txt = "start one; two end";
// Default behavior is StatementSensitive(true), so {body} stops at the semicolon
// and the 'end' anchor is never found. The transform fails.
var rule = t.FromTo("start {body} end", "[{body}]");
Console.WriteLine($"Sensitive (default): {t.Transform(txt)}");
rule.StatementSensitive = false;
// With StatementSensitive(false), {body} captures across the semicolon.
Console.WriteLine($"Insensitive: {t.Transform(txt)}");
Sensitive (default): start one; two end
Insensitive: [one; two] using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); string txt = "start one; two end"; // Default behavior is StatementSensitive(true), so {body} stops at the semicolon // and the 'end' anchor is never found. The transform fails. var rule = t.FromTo("start {body} end", "[{body}]"); Console.WriteLine($"Sensitive (default): {t.Transform(txt)}"); rule.StatementSensitive = false; // With StatementSensitive(false), {body} captures across the semicolon. Console.WriteLine($"Insensitive: {t.Transform(txt)}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
string txt = "start one; two end";
// Default behavior is StatementSensitive(true), so {body} stops at the semicolon
// and the 'end' anchor is never found. The transform fails.
auto rule = t.FromTo("start {body} end", "[{body}]");
cout << "Sensitive (default): " << t.Transform(txt) << endl;
rule.StatementSensitive(false);
// With StatementSensitive(false), {body} captures across the semicolon.
cout << "Insensitive: " << t.Transform(txt) << endl;
}
Sensitive (default): start one; two end
Insensitive: [one; two] #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; string txt = "start one; two end"; // Default behavior is StatementSensitive(true), so {body} stops at the semicolon // and the 'end' anchor is never found. The transform fails. auto rule = t.FromTo("start {body} end", "[{body}]"); cout << "Sensitive (default): " << t.Transform(txt) << endl; rule.StatementSensitive(false); // With StatementSensitive(false), {body} captures across the semicolon. cout << "Insensitive: " << t.Transform(txt) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
Dim txt As String = "start one; two end"
'// Default behavior is StatementSensitive(true), so {body} stops at the semicolon
'// and the 'end' anchor is never found. The transform fails.
Dim rule = t.FromTo("start {body} end", "[{body}]")
Console.WriteLine($"Sensitive (default): {t.Transform(txt)}")
rule.StatementSensitive = false
'// With StatementSensitive(false), {body} captures across the semicolon.
Console.WriteLine($"Insensitive: {t.Transform(txt)}")
End Sub
End Module
Sensitive (default): start one; two end
Insensitive: [one; two] Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() Dim txt As String = "start one; two end" '// Default behavior is StatementSensitive(true), so {body} stops at the semicolon '// and the 'end' anchor is never found. The transform fails. Dim rule = t.FromTo("start {body} end", "[{body}]") Console.WriteLine($"Sensitive (default): {t.Transform(txt)}") rule.StatementSensitive = false '// With StatementSensitive(false), {body} captures across the semicolon. Console.WriteLine($"Insensitive: {t.Transform(txt)}") End Sub End Module