Example #1
0
        public override object VisitForeachStmt([NotNull] CalculatorParser.ForeachStmtContext context)
        {
            var enumerable = context.expression().Accept(this) as IEnumerable <object>;
            var enumerator = enumerable.GetEnumerator();

            context.declaration().Accept(this);
            var varName = m_iterName;

            while (enumerator.MoveNext())
            {
                m_stack.Set(varName, enumerator.Current);
                context.block().Accept(this);
            }
            m_iterName = "";
            return(null);
        }
Example #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CalculatorParser.foreachStmt"/>.
 /// <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 VisitForeachStmt([NotNull] CalculatorParser.ForeachStmtContext context)
 {
     return(VisitChildren(context));
 }