Example #1
0
 public forStatementConCondFuntAST(exprAST d, conditionAST c, exprAST f, statementAST s)
 {
     this.decl      = d;
     this.condition = c;
     this.funtion   = f;
     this.statement = s;
 }
Example #2
0
 public forStatementConFuntionAST(exprAST d, exprAST f, statementAST s)
 {
     this.decl      = d;
     this.funtion   = f;
     this.statement = s;
 }
Example #3
0
 public unStatementAST(statementAST s)
 {
     statement = s;
 }
 public forStatementConConditionAST(exprAST d, conditionAST c, statementAST s)
 {
     this.decl = d;
     this.condition = c;
     this.statement = s;
 }
Example #5
0
 public unStatementAST(statementAST s)
 {
     statement = s;
 }
 public ifStatementSinELseAST(conditionAST cnd, statementAST stat)
 {
     this.condition = cnd;
     this.statement1 = stat;
 }
Example #7
0
 public whileStatementAST(conditionAST c, statementAST s)
 {
     condition = c;
     statement = s;
 }
Example #8
0
 public ifStatementSinELseAST(conditionAST cnd, statementAST stat)
 {
     this.condition  = cnd;
     this.statement1 = stat;
 }
Example #9
0
 public ifStatementConELseAST(conditionAST cnd, statementAST stat1, statementAST stat2)
 {
     this.condition  = cnd;
     this.statement1 = stat1;
     this.statement2 = stat2;
 }
Example #10
0
 public forStatementSoloDeclAST(exprAST d, statementAST s)
 {
     this.decl      = d;
     this.statement = s;
 }
 public ifStatementConELseAST(conditionAST cnd, statementAST stat1, statementAST stat2)
 {
     this.condition = cnd;
     this.statement1 = stat1;
     this.statement2 = stat2;
 }
 public forStatementSoloDeclAST(exprAST d,statementAST s)
 {
     this.decl = d;
     this.statement = s;
 }
Example #13
0
        public statementAST parseStat()
        { //Statement
            //case id
            designatorAST desig = null;
            exprAST       expr  = null;
            actParsAST    actP  = null;
            designatorStatementAumentoAST    aum  = null;
            designatorStatementDecrementoAST decr = null;
            Boolean actPBoo = false;
            //case if
            conditionAST      condi = null;
            statementAST      stat = null;
            statementAST      stat2 = null;
            Boolean           elseBoo = false;
            listStatementsAST tempStat, tempStat2, result;
            exprAST           forexpr1 = null;
            conditionAST      forexpr2 = null;
            exprAST           forexpr3 = null;
            statementAST      forstat  = null;

            switch (currentToken.sym)
            {
            case sym.ID:
            {
                desig = parseDesignator();
                switch (currentToken.sym)
                {
                case sym.IGUAL:
                {
                    acceptIt();
                    expr = parseExpr();
                    break;
                }

                case sym.P_ABI:
                {
                    acceptIt();
                    if (currentToken.sym == sym.RES || currentToken.sym == sym.ID || currentToken.sym == sym.NUM || currentToken.sym == sym.CHARCONS || currentToken.sym == sym.TRUE || currentToken.sym == sym.FALSE || currentToken.sym == sym.NEW || currentToken.sym == sym.P_ABI)
                    {
                        actP    = parseActPars();
                        actPBoo = true;
                    }
                    accept(sym.P_CER, ")");
                    break;
                }

                case sym.SUM_SUM:
                {
                    aum = new designatorStatementAumentoAST();
                    acceptIt();
                    break;
                }

                case sym.IGU_IGU:
                {
                    decr = new designatorStatementDecrementoAST();
                    acceptIt();
                    break;
                }
                    accept(sym.PYCOMA, ";");
                    //Designator ( "=" Expr | "(" [ ActPars ] ")" | "++" | "--" ) ";"
                }
                if (expr != null)
                {
                    return(new designatorStatementAsignacionAST(expr));
                }
                else

                if (actP != null)
                {
                    return(new designatorStatementUnActParsAST(actP));            //revisar
                }

                else

                if (actPBoo == true)
                {
                    return(new designatorStatementUnActParsAST(actP));        //revisar
                }

                else

                if (actPBoo == false)              //analizar posible fallo
                {
                    return(new designatorStatementSinActParsAST());
                }


                break;
            }

            case sym.IF:
            {
                accept(sym.IF, "if");
                accept(sym.P_ABI, "(");
                condi = parseCondition();
                accept(sym.P_CER, ")");
                stat = parseStat();
                //tempStat = new unStatementAST(stat);
                if (currentToken.sym == sym.ELSE)
                {
                    elseBoo = true;
                    stat2   = parseStat();
                }
                if (elseBoo == true)
                {
                    return(new ifStatementConELseAST(condi, stat, stat2));
                }
                else
                {
                    return(new ifStatementSinELseAST(condi, stat));
                }
                break;
            }

            case sym.FOR:
            {
                accept(sym.FOR, "for");
                accept(sym.P_ABI, "(");
                forexpr1 = parseExpr();
                accept(sym.PYCOMA, ";");
                if (currentToken.sym == sym.RES || currentToken.sym == sym.ID || currentToken.sym == sym.NUM || currentToken.sym == sym.CHARCONS || currentToken.sym == sym.TRUE || currentToken.sym == sym.FALSE || currentToken.sym == sym.NEW || currentToken.sym == sym.P_ABI)
                {
                    forexpr2 = parseCondition();
                }
                accept(sym.PYCOMA, ";");
                if (currentToken.sym == sym.RES || currentToken.sym == sym.ID || currentToken.sym == sym.NUM || currentToken.sym == sym.CHARCONS || currentToken.sym == sym.TRUE || currentToken.sym == sym.FALSE || currentToken.sym == sym.NEW || currentToken.sym == sym.P_ABI)
                {
                    forexpr3 = parseExpr();
                }
                accept(sym.PYCOMA, ";");
                forstat = parseStat();
                if (forexpr2 != null && forexpr3 == null)
                {
                    return(new forStatementConConditionAST(forexpr1, forexpr2, forstat));
                }

                if (forexpr3 != null && forexpr2 == null)
                {
                    return(new forStatementConFuntionAST(forexpr1, forexpr3, forstat));
                }
                if (forexpr3 == null && forexpr2 == null)
                {
                    return(new forStatementSoloDeclAST(forexpr1, forstat));
                }
                if (forexpr3 != null && forexpr2 != null)
                {
                    return(new forStatementConCondFuntAST(forexpr1, forexpr2, forexpr3, forstat));
                }


                break;
            }

            case sym.WHILE:
            {
                accept(sym.WHILE, "WHILE");
                accept(sym.P_ABI, "(");
                condi = parseCondition();
                accept(sym.P_CER, ")");
                stat = parseStat();
                return(new whileStatementAST(condi, stat));

                break;
            }

            case sym.BREAK: {
                accept(sym.PYCOMA);
                break;
            }

            case sym.RETURN:
            { Boolean ind = false;
              acceptIt();
              if (currentToken.sym == sym.RES || currentToken.sym == sym.ID || currentToken.sym == sym.NUM || currentToken.sym == sym.CHARCONS || currentToken.sym == sym.TRUE || currentToken.sym == sym.FALSE || currentToken.sym == sym.NEW || currentToken.sym == sym.P_ABI)
              {
                  expr = parseExpr();
                  ind  = true;
              }
              accept(sym.PYCOMA, ";");
              if (ind == true)
              {
                  return(new returnStatementConExprAST(expr));
              }
              else
              {
                  return(new returnStatementSinExprAST());
              }
              break; }

            case sym.READ:
            {
                acceptIt();
                accept(sym.P_ABI, "(");
                desig = parseDesignator();

                accept(sym.P_CER, ")");
                accept(sym.PYCOMA, ";");
                return(new readStatementAST(desig));        //revisar este return

                break;
            }

            case sym.WRITE:
            {
                accept(sym.P_ABI, "(");
                expr = parseExpr();
                Symbol tempsimbol = null;
                if (currentToken.sym == sym.COMA)
                {
                    accept(sym.COMA, ",");
                    tempsimbol = currentToken;
                    accept(sym.NUM, "number");
                }
                accept(sym.P_CER, ")");
                accept(sym.PYCOMA, ";");
                if (tempsimbol != null)
                {
                    return(new writeStatementConNumAST(tempsimbol, expr));
                }
                else
                {
                    return(new writeStatementSinNumAST(expr));
                }
                //                    "write" "(" Expr [ "," number ] ")" ";"
            }

            case sym.COR_A:
            {
                parseBlock();
                break;
            }

            case sym.PYCOMA:
            {
                acceptIt();
                break;
            }
            }


            return(null);
        }
Example #14
0
 public whileStatementAST(conditionAST c, statementAST s)
 {
     condition = c;
     statement = s;
 }