public static bool IsArithmetic(string content, out ArithmeticCheckResult result) { result = new ArithmeticCheckResult(); foreach (string type in Arithmetic.Keys) { var keywords = Arithmetic[type]; Match match = null; if (keywords.Prefix.IsMatch(content)) { match = keywords.Prefix.Match(content); } else if (keywords.Infix.IsMatch(content)) { match = keywords.Infix.Match(content); } if (match != null) { result.Left = match.Groups[1].Value; result.Right = match.Groups[2].Value; result.Expression = type; return(true); } } return(false); }
private BaseNode CreateNode(ArithmeticCheckResult result) { var expression = new ExpressionNode { Left = CreateNode(result.Left), Right = CreateNode(result.Right), Expression = result.Expression }; return(expression); }
public KirinArithmetic(ArithmeticCheckResult result) { this.NodeTree = CreateNode(result); }