public void Visit(PyAst.WhileStatement node) { AppendLineWithIndentation($"while {Visit(node.Test)}:"); using (new Indenter(this)) { Visit(node.Body); } }
//while_stmt: 'while' expression ':' suite ['else' ':' suite] private WhileStatement ParseWhileStmt() { Eat(TokenKind.KeywordWhile); var start = GetStart(); Expression expr = ParseExpression(); var mid = GetEnd(); Statement body = ParseLoopSuite(); Statement else_ = null; if (MaybeEat(TokenKind.KeywordElse)) { else_ = ParseSuite(); } WhileStatement ret = new WhileStatement(expr, body, else_); ret.SetLoc(_globalParent, start, mid, GetEnd()); return ret; }
internal While(WhileStatement stmt) : this() { _test = Convert(stmt.Test); _body = ConvertStatements(stmt.Body); _orelse = ConvertStatements(stmt.ElseStatement, true); }
public override bool Walk(WhileStatement node) { node.Parent = _currentScope; // we only push the loop for the body of the loop // so we need to walk the while statement ourselves if (node.Test != null) { node.Test.Walk(this); } PushLoop(node); if (node.Body != null) { node.Body.Walk(this); } PopLoop(); if (node.ElseStatement != null) { node.ElseStatement.Walk(this); } return false; }
public override bool Walk(WhileStatement node) { loopCount++; return true; }
public override void PostWalk(WhileStatement node) { loopCount--; }
public override bool Walk(WhileStatement node) { CommonWalk(node); return true; }
public override void PostWalk(WhileStatement node) { string elseSt = node.ElseStatement != null ? Content() : null; string body = Content(); string test = Content(); StringBuilder sb = new StringBuilder(); sb.Append(Indent()); sb.AppendFormat("while ({0}) {{", test); sb.AppendLine(); sb.AppendLine(body); if (elseSt != null) { sb.AppendLine(); sb.Append(Indent(indent + 1)); sb.AppendFormat("if (!({0})) {{", test); sb.AppendLine(); sb.AppendLine(elseSt); sb.Append(Indent(indent + 1)); sb.AppendLine("}"); } sb.Append(Indent()); sb.AppendLine("}"); Content(sb.ToString()); CommonPostWalk(node, true); }
// WhileStatement public bool Walk(WhileStatement node) { return Process(node); }
public void PostWalk(WhileStatement node) { PostProcess(node); }
// WhileStmt public override bool Walk(WhileStatement node) { // Walk the expression node.Test.Walk(this); BitArray opte = node.ElseStatement != null ? new BitArray(_bits) : null; BitArray exit = new BitArray(_bits.Length, true); PushLoop(exit); node.Body.Walk(this); PopLoop(); _bits.And(exit); if (node.ElseStatement != null) { // Flow the else BitArray save = _bits; _bits = opte; node.ElseStatement.Walk(this); // Restore the bits _bits = save; // Intersect _bits.And(opte); } return false; }
public override bool Walk(WhileStatement node) { Emit(node); return false; }
public override bool Walk(WhileStatement node) { return true; }
public virtual void PostWalk(WhileStatement node) { }
// WhileStatement public virtual bool Walk(WhileStatement node) { return true; }
//while_stmt: 'while' test ':' suite ['else' ':' suite] private WhileStatement ParseWhileStmt() { Eat(TokenKind.KeywordWhile); Location start = GetStart(); Expression test = ParseTest(); Location mid = GetEnd(); Statement body = ParseSuite(); Statement else_ = null; if (MaybeEat(TokenKind.KeywordElse)) { else_ = ParseSuite(); } WhileStatement ret = new WhileStatement(test, body, else_); ret.SetLoc(GetExternal(), start, mid, GetEnd()); return ret; }