Exemplo n.º 1
0
        private static string ProcessBoolExpression(string expression, bool debugMode)
        {
            if (debugMode)
            {
                TextProc.WriteProcess("preprocessing");
            }

            expression = ConstantsValidator.ValidateBoolExpression(expression);

            if (expression.Length == 0)
            {
                return("error (length)");
            }
            if (!CharValidator.Validate(CharValidator.ExpressionType.Bool, expression, debugMode))
            {
                return("error (chars)");
            }
            if (!BracketsValidator.Validate(BracketsValidator.BracketsTypes.Round, expression, debugMode))
            {
                return("error (brackets)");
            }
            if (!SequenceValidator.ValidateBoolExpression(expression, debugMode))
            {
                return("error (sequence)");
            }

            if (debugMode)
            {
                TextProc.WriteProcess("processing");
            }

            return("" + BoolProcessor.GetBoolExpressionResolve(
                       BoolProcessor.ProcessBoolExpression(expression, debugMode), debugMode));
        }
Exemplo n.º 2
0
        private static string ProcessMatrixExpression(string expression, bool debugMode)
        {
            if (debugMode)
            {
                TextProc.WriteProcess("preprocessing");
            }

            expression = ConstantsValidator.ValidateMatrixExpression(expression);

            if (expression.Length == 0)
            {
                return("error (length)");
            }
            if (!CharValidator.Validate(CharValidator.ExpressionType.Matrix, expression, debugMode))
            {
                return("error (chars)");
            }
            if (!BracketsValidator.Validate(BracketsValidator.BracketsTypes.Round, expression, debugMode))
            {
                return("error (brackets)");
            }
            if (!BracketsValidator.Validate(BracketsValidator.BracketsTypes.Square, expression, debugMode))
            {
                return("error (brackets)");
            }
            if (!PointersValidator.Validate('.', expression, debugMode))
            {
                return("error (pointers)");
            }
            if (!SequenceValidator.ValidateMatrixExpression(expression, debugMode))
            {
                return("error (sequence)");
            }

            if (debugMode)
            {
                TextProc.WriteProcess("processing");
            }
            var separatedExpression = MatrixProcessor.GetExpressionSeparated(expression, debugMode);

            if (!MatrixValidator.Validate(separatedExpression, debugMode))
            {
                return("error (matrix)");
            }

            if (debugMode)
            {
                TextProc.WriteProcess("calculating");
            }
            return(MatrixProcessor.ResolveExpression(separatedExpression));
        }
Exemplo n.º 3
0
        private static string ProcessRegularExpression(string expression, bool debugMode)
        {
            if (debugMode)
            {
                TextProc.WriteProcess("preprocessing");
            }
            expression = ConstantsValidator.ValidateRegExpression(expression);

            if (expression.Length == 0)
            {
                return("error (length)");
            }
            if (!CharValidator.Validate(CharValidator.ExpressionType.Reg, expression, debugMode))
            {
                return("error (chars)");
            }
            if (!BracketsValidator.Validate(BracketsValidator.BracketsTypes.Round, expression, debugMode))
            {
                return("error (brackets)");
            }
            if (!SequenceValidator.ValidateRegExpression(expression, debugMode))
            {
                return("error (sequence)");
            }
            if (!PointersValidator.Validate(',', expression, debugMode))
            {
                return("error (pointers)");
            }

            if (debugMode)
            {
                TextProc.WriteProcess("processing");
            }
            return("" + Processor.ResolveExpression(
                       Processor.GetExpressionSeparated(expression, debugMode)));
        }