Retrieving the precedence levels of built-in arithmetic operators to compare their binding strength.

ID: 655

				
					using uCalcSoftware;

var uc = new uCalc();
var plus_op = uc.ItemOf("+", uCalc.Properties(ItemIs.Infix));
var mul_op = uc.ItemOf("*", uCalc.Properties( ItemIs.Infix));

Console.WriteLine($"Precedence of '+': {plus_op.Precedence}");
Console.WriteLine($"Precedence of '*': {mul_op.Precedence}");
Console.WriteLine($"Does '*' bind tighter than '+'? {mul_op.Precedence > plus_op.Precedence}");
				
			
Precedence of '+': 50
Precedence of '*': 60
Does '*' bind tighter than '+'? True
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   auto plus_op = uc.ItemOf("+", uCalc::Properties(ItemIs::Infix));
   auto mul_op = uc.ItemOf("*", uCalc::Properties( ItemIs::Infix));

   cout << "Precedence of '+': " << plus_op.Precedence() << endl;
   cout << "Precedence of '*': " << mul_op.Precedence() << endl;
   cout << "Does '*' bind tighter than '+'? " << tf(mul_op.Precedence() > plus_op.Precedence()) << endl;
}
				
			
Precedence of '+': 50
Precedence of '*': 60
Does '*' bind tighter than '+'? True
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim plus_op = uc.ItemOf("+", uCalc.Properties(ItemIs.Infix))
      Dim mul_op = uc.ItemOf("*", uCalc.Properties( ItemIs.Infix))
      
      Console.WriteLine($"Precedence of '+': {plus_op.Precedence}")
      Console.WriteLine($"Precedence of '*': {mul_op.Precedence}")
      Console.WriteLine($"Does '*' bind tighter than '+'? {mul_op.Precedence > plus_op.Precedence}")
   End Sub
End Module
				
			
Precedence of '+': 50
Precedence of '*': 60
Does '*' bind tighter than '+'? True