Example #1
0
 /// <summary>
 /// consume current token (get next token); throw exception if the current token doesn't
 /// match the expected symbol.
 /// </summary>
 protected internal Scanner.Token ConsumeToken(Scanner.Symbol expected)
 {
     if (token.Symbol != expected)
     {
         Fail(expected);
     }
     return(ConsumeToken());
 }
Example #2
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);
        }
Example #3
0
 /// <summary>
 /// throw exception
 /// </summary>
 protected internal virtual void Fail(Scanner.Symbol expected)
 {
     Fail(expected.ToString());
 }