Beispiel #1
0
        /// <summary>
        /// text := &lt;TEXT&gt;
        /// </summary>
        protected internal virtual AstNode Text()
        {
            AstNode v = null;

            if (token.Symbol == Scanner.Symbol.TEXT)
            {
                v = new AstText(token.Image);
                ConsumeToken();
            }
            return(v);
        }
Beispiel #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));
        }