#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Practical: Basic Syntax Highlighter uCalc::Transformer t; // Define categories with integer tags auto TAG_KEYWORD = 1; auto TAG_STRING = 2; auto TAG_COMMENT = 3; // Define rules and tag them t.Pattern("{ if | else | for | while }").SetTag(TAG_KEYWORD); t.Pattern("{@String}").SetTag(TAG_STRING); t.Pattern("// {text}").SetTag(TAG_COMMENT); t.Text(R"(for (i=0; i<10; i++) { s = "hello"; // comment })"); t.Find(); for(auto match : t.Matches()) { auto tag = match.Rule().Tag(); if (tag == TAG_KEYWORD) { cout << "TAG_KEYWORD: " << match.Text() << endl; } else if (tag == TAG_STRING) { cout << "TAG_STRING: " << match.Text() << endl; } else if (tag == TAG_COMMENT) { cout << "TAG_COMMENT: " << match.Text() << endl; } } }