Beispiel #1
0
        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);
        }
Beispiel #2
0
        private BaseNode CreateNode(ArithmeticCheckResult result)
        {
            var expression = new ExpressionNode
            {
                Left       = CreateNode(result.Left),
                Right      = CreateNode(result.Right),
                Expression = result.Expression
            };

            return(expression);
        }
Beispiel #3
0
 public KirinArithmetic(ArithmeticCheckResult result)
 {
     this.NodeTree = CreateNode(result);
 }