Esempio n. 1
0
        // log override


        public override Value VisitIf_stat(AbstractIfStmtParser.If_statContext context)
        {
            AbstractIfStmtParser.Condition_blockContext[] conditions = context.condition_block();
            bool evaluatedBlock = false;
            int  i    = 0;
            int  size = conditions.GetLength(0);

            while (i < size)
            {
                AbstractIfStmtParser.Condition_blockContext condition = conditions[i++];

                Value evaluated = this.Visit(condition.expr());

                bool evalVal = getBoolValue(evaluated);


                if (evalVal)
                {
                    evaluatedBlock = true;
                    // evaluate this block whose expr==true
                    this.Visit(condition.stat_block());

                    break;
                }
            }

            if (!evaluatedBlock && context.stat_block() != null)
            {
                // evaluate the else-stat_block (if present == not null)
                this.Visit(context.stat_block());
            }

            return(new Value(false));
        }
Esempio n. 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="AbstractIfStmtParser.condition_block"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitCondition_block([NotNull] AbstractIfStmtParser.Condition_blockContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by <see cref="AbstractIfStmtParser.condition_block"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCondition_block([NotNull] AbstractIfStmtParser.Condition_blockContext context)
 {
 }