/// <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); }
/// <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)); }
/// <summary> /// dynmamic := <START_EVAL_DYNAMIC> expr <END_EVAL> /// deferred := <START_EVAL_DEFERRED> expr <END_EVAL> /// </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); }