コード例 #1
0
        /// <summary>
        /// eval := dynamic | deferred
        /// </summary>
        protected internal virtual AstEval Eval()
        {
            AstEval e = Eval(false, false);

            if (e == null)
            {
                e = Eval(false, true);
                if (e == null)
                {
                    Fail(Scanner.Symbol.START_EVAL_DEFERRED + "|" + Scanner.Symbol.START_EVAL_DYNAMIC);
                }
            }
            return(e);
        }
コード例 #2
0
        /// <summary>
        /// tree := text? ((dynamic text?)+ | (deferred text?)+)?
        /// </summary>
        public virtual Tree Tree()
        {
            ConsumeToken();
            AstNode t = Text();

            if (token.Symbol == Scanner.Symbol.EOF)
            {
                if (t == null)
                {
                    t = new AstText("");
                }
                return(new Tree(t, functions, identifiers, false));
            }
            AstEval e = Eval();

            if (token.Symbol == Scanner.Symbol.EOF && t == null)
            {
                return(new Tree(e, functions, identifiers, e.Deferred));
            }
            List <AstNode> list = new List <AstNode>();

            if (t != null)
            {
                list.Add(t);
            }
            list.Add(e);
            t = Text();
            if (t != null)
            {
                list.Add(t);
            }
            while (token.Symbol != Scanner.Symbol.EOF)
            {
                if (e.Deferred)
                {
                    list.Add(Eval(true, true));
                }
                else
                {
                    list.Add(Eval(true, false));
                }
                t = Text();
                if (t != null)
                {
                    list.Add(t);
                }
            }
            return(new Tree(CreateAstComposite(list), functions, identifiers, e.Deferred));
        }
コード例 #3
0
        /// <summary>
        /// dynmamic := &lt;START_EVAL_DYNAMIC&gt; expr &lt;END_EVAL&gt;
        /// deferred := &lt;START_EVAL_DEFERRED&gt; expr &lt;END_EVAL&gt;
        /// </summary>
        protected internal virtual AstEval Eval(bool required, bool deferred)
        {
            AstEval v = null;

            Scanner.Symbol start_eval = deferred ? Scanner.Symbol.START_EVAL_DEFERRED : Scanner.Symbol.START_EVAL_DYNAMIC;
            if (token.Symbol == start_eval)
            {
                ConsumeToken();
                v = new AstEval(Expr(true), deferred);
                ConsumeToken(Scanner.Symbol.END_EVAL);
            }
            else if (required)
            {
                Fail(start_eval);
            }
            return(v);
        }