예제 #1
0
        /// <summary>
        /// Validate the statements for errors.
        /// </summary>
        /// <param name="stmts">Statements to validate</param>
        /// <returns></returns>
        public RunResult Validate(List<Expr> stmts)
        {
            var start = DateTime.Now;
            if (stmts == null || stmts.Count == 0)
                return new RunResult(start, start, true, "No nodes to validate");

            _ctx = stmts[0].Ctx;

            // Reset the errors.
            _errors = new List<ScriptError>();
            _parseStk = new ParseStackManager();

            // Use the visitor to walk the AST tree of statements/expressions
            var visitor = new AstVisitor((astnode1) => Validate(astnode1), (astnode2) =>OnNodeEnd(astnode2));
            visitor.Visit(stmts);

            var end = DateTime.Now;
            // Now check for success.
            bool success = _errors.Count == 0;
            _results = new RunResult(start, end, success, _errors);
            _results.Errors = _errors;
            return _results;
        }