mirror of
https://github.com/chylex/Query.git
synced 2025-06-02 19:34:05 +02:00
29 lines
469 B
C#
29 lines
469 B
C#
namespace AppCalc {
|
|
static class Operators {
|
|
internal static readonly string[] With2Operands = { "+", "-", "*", "/", "%", "^" };
|
|
|
|
internal static int GetPrecedence(string token) {
|
|
switch (token) {
|
|
case "^":
|
|
return 4;
|
|
|
|
case "*":
|
|
case "/":
|
|
case "%":
|
|
return 3;
|
|
|
|
case "+":
|
|
case "-":
|
|
return 2;
|
|
|
|
default:
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
internal static bool IsRightAssociative(string token) {
|
|
return token == "^";
|
|
}
|
|
}
|
|
}
|