internal static string ToString(string str1, string str2, TwoOperatorType v) { switch (v) { case TwoOperatorType.Plus: case TwoOperatorType.Minus: return($"{str1} {ToChar(v)} {str2}"); case TwoOperatorType.Multiply: case TwoOperatorType.Divide: case TwoOperatorType.Pow: return($"{str1}{ToChar(v)}{str2}"); default: throw new NotImplementedException(); } }
internal static bool IsSequence(TwoOperatorType v) { switch (v) { case TwoOperatorType.Minus: case TwoOperatorType.Divide: case TwoOperatorType.Pow: return(true); case TwoOperatorType.Plus: case TwoOperatorType.Multiply: return(false); default: throw new NotImplementedException(); } }
internal static int GetPriority(TwoOperatorType v) { switch (v) { case TwoOperatorType.Plus: case TwoOperatorType.Minus: return(1); case TwoOperatorType.Multiply: case TwoOperatorType.Divide: return(2); case TwoOperatorType.Pow: return(3); default: throw new NotImplementedException(); } }
internal static char ToChar(TwoOperatorType v) { switch (v) { case TwoOperatorType.Plus: return('+'); case TwoOperatorType.Minus: return('-'); case TwoOperatorType.Multiply: return('*'); case TwoOperatorType.Divide: return('/'); case TwoOperatorType.Pow: return('^'); default: throw new NotImplementedException(); } }
internal static Block Create(Block a, Block b, TwoOperatorType type) { return(new TwoOperatorBlock(a, b, type)); }
private TwoOperatorBlock(Block a, Block b, TwoOperatorType type) { this.a = a; this.b = b; this.type = type; }