public string Visit(NDoWhileStmt nDoWhileStmt) { string retVal = ""; string continueLabel = GenerateLabel(); string breakLabel = GenerateLabel(); string jumpBody = GenerateLabel(); string lastContinueLabel = currentContinueLabel; string lastBreakLabel = currentBreakLabel; currentContinueLabel = continueLabel; currentBreakLabel = breakLabel; retVal += jumpBody + ":\n"; retVal += Visit((dynamic)nDoWhileStmt[0]); retVal += continueLabel + ":\n"; retVal += Visit((dynamic)nDoWhileStmt[1]); retVal += "\t\tbrtrue " + jumpBody + "\n"; retVal += breakLabel + ":\n"; currentContinueLabel = lastContinueLabel; currentBreakLabel = lastBreakLabel; return(retVal); }
//------------------------------------------------------------ public void Visit(NDoWhileStmt node) { Console.WriteLine($"+++++++++++++++ NDoWhileStmt ++++++++++++++++"); if (pasones == 2) { inloop++; } VisitChildren(node); if (pasones == 2) { inloop--; } }
// Returns NDoWhileStmt public Node DoWhileStmt() { NDoWhileStmt nDoWhileStmt = new NDoWhileStmt(); Expect(TokenCategory.DO); Expect(TokenCategory.CURLY_BRACE_LEFT); NStmtList nStmtList = new NStmtList(); while (firstOfStatement.Contains(CurrentToken)) { Stmt(nStmtList); } nDoWhileStmt.Add(nStmtList); Expect(TokenCategory.CURLY_BRACE_RIGHT); Expect(TokenCategory.WHILE); Expect(TokenCategory.PARENTHESIS_LEFT); nDoWhileStmt.Add(Expr()); Expect(TokenCategory.PARENTHESIS_RIGHT); Expect(TokenCategory.SEMICOLON); return(nDoWhileStmt); }
public void Visit(NDoWhileStmt nDoWhileStmt) { ++nestedLoopCount; GenericChildVisitor(nDoWhileStmt); --nestedLoopCount; }