Exemple #1
0
        /// <summary>
        /// Parse a query and return the first instruction.
        /// </summary>
        private ParseTreeNode RunNonQueryTest(string script)
        {
            var result = ExpressionGrammar.ParseMacro(script);

            var expression  = CheckTerm(result.Root, Terms.Expression);
            var instruction = expression.ChildNodes[0];

            return(instruction);
        }
Exemple #2
0
        /// <summary>
        /// Convert a string into an expression tree and perform static evaluation.
        /// </summary>
        /// <param name="script">The script to parse.</param>
        /// <param name="settings">Additional settings that control parsing. In particular, contains the type of the root context object, if any.</param>
        /// <returns>An expression tree.</returns>
        public IExpression Compile(string script, BuilderSettings settings)
        {
            using (EntryPointContext.AppendEntryPoint("ExprCompile"))
                using (new SecurityBypassContext( ))
                    using (Profiler.Measure("ExpressionEngine.Compile"))
                    {
                        // Parse the expression
                        ParseTree     parseTree = ExpressionGrammar.ParseMacro(script);
                        ParseTreeNode parseRoot = parseTree.Root;

                        // Compile the parse tree
                        IExpression result = CompileParseTreeNode(parseRoot, settings);
                        return(result);
                    }
        }