public StringBuilder SyntaxAnalysisInfixNotation(IMathMeta token, StringBuilder outputString, Stack <MathMetaBase> block) { if (token.IsNumber()) { outputString.Append(token.ToString()); } else if (token.IsFunction() || token.GetType().IsAssignableFrom(typeof(LeftParenthesis)) ) { block.Push(token as MathMetaBase); } else if (token.GetType().IsAssignableFrom(typeof(RightParenthesis))) { string elem; while ((elem = block.Pop().ToString()) != new LeftParenthesis().ToString()) { outputString.Append(elem); } if (block.Count > 0 && block.Peek().IsFunction()) { outputString.Append(block.Pop()); } } else { while (block.Count > 0 && (token as MathMetaBase) < block.Peek()) { outputString.Append(block.Pop().ToString()); } block.Push(token as MathMetaBase); } return(outputString); }
public static bool Is(this IMathMeta meta, Type @interface) { return(@interface.IsAssignableFrom(meta.GetType())); }
public static bool IsNumber(this IMathMeta meta) { return(typeof(NumberResult).IsAssignableFrom(meta.GetType())); }