示例#1
0
//------------------------------------------------------------
        public void Visit(NWhileStmt node)
        {
            Console.WriteLine($"+++++++++++++++ NWhileStmt ++++++++++++++++");
            if (pasones == 2)
            {
                inloop++;
            }
            VisitChildren(node);
            if (pasones == 2)
            {
                inloop--;
            }
        }
示例#2
0
        // Returns NWhileStmt
        public Node WhileStmt()
        {
            NWhileStmt nWhileStmt = new NWhileStmt();

            Expect(TokenCategory.WHILE);
            Expect(TokenCategory.PARENTHESIS_LEFT);
            nWhileStmt.Add(Expr());
            Expect(TokenCategory.PARENTHESIS_RIGHT);
            Expect(TokenCategory.CURLY_BRACE_LEFT);
            NStmtList nStmtList = new NStmtList();

            while (firstOfStatement.Contains(CurrentToken))
            {
                Stmt(nStmtList);
            }
            nWhileStmt.Add(nStmtList);
            Expect(TokenCategory.CURLY_BRACE_RIGHT);
            return(nWhileStmt);
        }
        public string Visit(NWhileStmt nWhileStmt)
        {
            string retVal        = "";
            string continueLabel = GenerateLabel();
            string breakLabel    = GenerateLabel();

            string lastContinueLabel = currentContinueLabel;
            string lastBreakLabel    = currentBreakLabel;

            currentContinueLabel = continueLabel;
            currentBreakLabel    = breakLabel;

            retVal += continueLabel + ":\n";
            retVal += Visit((dynamic)nWhileStmt[0]);
            retVal += "\t\tbrfalse " + breakLabel + "\n";
            retVal += Visit((dynamic)nWhileStmt[1]);
            retVal += "\t\tbr " + continueLabel + "\n";
            retVal += breakLabel + ":\n";

            currentContinueLabel = lastContinueLabel;
            currentBreakLabel    = lastBreakLabel;

            return(retVal);
        }
 public void Visit(NWhileStmt nWhileStmt)
 {
     ++nestedLoopCount;
     GenericChildVisitor(nWhileStmt);
     --nestedLoopCount;
 }