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); }
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); }
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(";"); } }
public abstract void ConstructForNumericStatement(ForNumericStatement node);