Exemplo n.º 1
0
 protected virtual Object[] AnalyseForNumericStatement(ForNumericStatement node, params Object[] args)
 {
     this.Analyse(node.InitialExpression);
     this.Analyse(node.FinalExpression);
     this.Analyse(node.IncrementExpression);
     this.Analyse(node.Body);
     return(null);
 }
Exemplo n.º 2
0
        protected override ASTNode FoldForNumericStatement(ForNumericStatement node, params Object[] args)
        {
            if (node.InitialExpression != null)
            {
                ASTNode init = this.Fold(node.InitialExpression);
                if (init != null)
                {
                    node.SetInitialExpression(init);
                }
                else
                {
                    throw new Exception("Cannot have a numeric for statement without an initial expression.");
                }
            }
            else
            {
                throw new Exception("Cannot have a numeric for statement without an initial expression.");
            }

            if (node.FinalExpression != null)
            {
                ASTNode final = this.Fold(node.FinalExpression);
                if (final != null)
                {
                    node.SetFinalExpression(final);
                }
                else
                {
                    throw new Exception("Cannot have a numeric for statement without a final expression.");
                }
            }
            else
            {
                throw new Exception("Cannot have a numeric for statement without a final expression.");
            }

            if (node.IncrementExpression != null)
            {
                node.SetIncrementExpression(this.Fold(node.IncrementExpression));
            }

            if (node.Body == null)
            {
                throw new Exception("Cannot have a numeric for statement with a null body.");
            }
            node.SetBody(this.FoldStatementList(node.Body));
            return(node);
        }
Exemplo n.º 3
0
 public override void ConstructForNumericStatement(ForNumericStatement node)
 {
     this.WriteIndented("for ");
     this.ConstructVariableExpression(node.Variable);
     this.Write(" = ");
     this.ConstructInternal(node.InitialExpression);
     this.Write(", ");
     this.ConstructInternal(node.FinalExpression);
     if (node.IncrementExpression != null)
     {
         this.Write(", ");
         this.ConstructInternal(node.IncrementExpression);
     }
     this.WriteLine(" do");
     this.Indent( );
     this.ConstructStatementList(node.Body);
     this.Outdent( );
     this.WriteIndented("end");
     if (node.HasSemicolon)
     {
         this.Write(";");
     }
 }
Exemplo n.º 4
0
 public abstract void ConstructForNumericStatement(ForNumericStatement node);