Finding the precedence level of an operator
ID: 24
using uCalcSoftware;
var uc = new uCalc();
uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence);
Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"));
uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence);
Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"));
true
false using uCalcSoftware; var uc = new uCalc(); uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence); Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5")); uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence); Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence());
cout << uc.EvalStr("true Or false ## 2 > 5") << endl;
uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence());
cout << uc.EvalStr("true Or false ## 2 > 5") << endl;
}
true
false #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence()); cout << uc.EvalStr("true Or false ## 2 > 5") << endl; uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence()); cout << uc.EvalStr("true Or false ## 2 > 5") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence)
Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"))
uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence)
Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5"))
End Sub
End Module
true
false Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.DefineOperator("{a As Bool} ## {b As Bool} As Bool = a And b", uc.ItemOf("And").Precedence) Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5")) uc.ItemOf("##").SetPrecedence(uc.ItemOf("Or").Precedence) Console.WriteLine(uc.EvalStr("true Or false ## 2 > 5")) End Sub End Module