#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto t = uc.NewTransformer(); auto Pattern = t.Pattern("< {etc} >"); t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >"); // Note the difference in the final match Pattern.BracketSensitive(true); // true is the default cout << "BracketSensitive: " << tf(Pattern.BracketSensitive()) << endl; cout << "----------------------" << endl; t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; Pattern.BracketSensitive(false); cout << "BracketSensitive: " << tf(Pattern.BracketSensitive()) << endl; cout << "-----------------------" << endl; t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; t.Str("( a b ( c ) d e )"); // Here parentheses are captured as regular tokens, not bracket pairs auto Pattern2a = t.Pattern("( {etc} ("); auto Pattern2b = t.Pattern(") {etc} )"); cout << "Brackets used as part of pattern" << endl; cout << "--------------------------------" << endl; Pattern2a.BracketSensitive(true); Pattern2b.BracketSensitive(true); t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; Pattern2a.BracketSensitive(false); Pattern2b.BracketSensitive(false); t.Find(); cout << t.Matches().Text() << endl; }