Demonstrates the basic functionality of clearing default tokens and adding a single new one.

ID: 1021

See: Clear
				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("is", "<IS>");

Console.WriteLine("--- With Default Tokens ---");
// By default, 'is' is a whole word (token)
Console.WriteLine(t.Transform("This is a test"));

// Clear all default token definitions
t.Tokens.Clear();

// Add a new, simple token that matches any single character
t.Tokens.Add(".");

Console.WriteLine("");
Console.WriteLine("--- After Clearing and Adding '.' Token ---");
// Now, 'i' and 's' are matched as separate characters
t.FromTo("is", "<IS>"); // The rule must be redefined
Console.WriteLine(t.Transform("This is a test"));
				
			
--- With Default Tokens ---
This <IS> a test

--- After Clearing and Adding '.' Token ---
Th<IS> <IS> a test
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.FromTo("is", "<IS>");

   cout << "--- With Default Tokens ---" << endl;
   // By default, 'is' is a whole word (token)
   cout << t.Transform("This is a test") << endl;

   // Clear all default token definitions
   t.Tokens().Clear();

   // Add a new, simple token that matches any single character
   t.Tokens().Add(".");

   cout << "" << endl;
   cout << "--- After Clearing and Adding '.' Token ---" << endl;
   // Now, 'i' and 's' are matched as separate characters
   t.FromTo("is", "<IS>"); // The rule must be redefined
   cout << t.Transform("This is a test") << endl;
}
				
			
--- With Default Tokens ---
This <IS> a test

--- After Clearing and Adding '.' Token ---
Th<IS> <IS> a test
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.FromTo("is", "<IS>")
      
      Console.WriteLine("--- With Default Tokens ---")
      '// By default, 'is' is a whole word (token)
      Console.WriteLine(t.Transform("This is a test"))
      
      '// Clear all default token definitions
      t.Tokens.Clear()
      
      '// Add a new, simple token that matches any single character
      t.Tokens.Add(".")
      
      Console.WriteLine("")
      Console.WriteLine("--- After Clearing and Adding '.' Token ---")
      '// Now, 'i' and 's' are matched as separate characters
      t.FromTo("is", "<IS>") '// The rule must be redefined
      Console.WriteLine(t.Transform("This is a test"))
   End Sub
End Module
				
			
--- With Default Tokens ---
This <IS> a test

--- After Clearing and Adding '.' Token ---
Th<IS> <IS> a test