How adding tokens affects their index and, therefore, their precedence.

ID: 1036

See: IndexOf
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
var tokens = t.Tokens;
tokens.Clear();
tokens.Add("."); // Add a fallback token at index 0

// The order of definition determines the index (precedence)
var tokenA = tokens.Add("A");
var tokenB = tokens.Add("B");

Console.WriteLine($"Index of A: {tokens.IndexOf(tokenA)}"); // Will have a lower index
Console.WriteLine($"Index of B: {tokens.IndexOf(tokenB)}"); // Will have a higher index, thus higher precedence
				
			
Index of A: 1
Index of B: 2
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   auto tokens = t.Tokens();
   tokens.Clear();
   tokens.Add("."); // Add a fallback token at index 0

   // The order of definition determines the index (precedence)
   auto tokenA = tokens.Add("A");
   auto tokenB = tokens.Add("B");

   cout << "Index of A: " << tokens.IndexOf(tokenA) << endl; // Will have a lower index
   cout << "Index of B: " << tokens.IndexOf(tokenB) << endl; // Will have a higher index, thus higher precedence
}
				
			
Index of A: 1
Index of B: 2
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      Dim tokens = t.Tokens
      tokens.Clear()
      tokens.Add(".") '// Add a fallback token at index 0
      
      '// The order of definition determines the index (precedence)
      Dim tokenA = tokens.Add("A")
      Dim tokenB = tokens.Add("B")
      
      Console.WriteLine($"Index of A: {tokens.IndexOf(tokenA)}") '// Will have a lower index
      Console.WriteLine($"Index of B: {tokens.IndexOf(tokenB)}") '// Will have a higher index, thus higher precedence
   End Sub
End Module
				
			
Index of A: 1
Index of B: 2