Exemplo n.º 1
0
        public designatorAST parseDesignator()
        {
            //Designator
            //Designator = ident { "." ident | "[" Expr "]" }
            listIdentExprAST temp = null;
             listIdentExprAST result=null;
             Symbol tempsimbol2=null;
            exprAST expr=null;
            Symbol tempsimbol=currentToken;
            accept(sym.ID, "ident");
            Boolean ind=false;
            Boolean ind2=false;
            while (currentToken.sym == sym.PUNTO || currentToken.sym == sym.C_ABI)
            {
                if (currentToken.sym == sym.PUNTO)
                {
                    if(ind==false){
                    acceptIt();
                    tempsimbol2=currentToken;
                    accept(sym.ID, "ident");
                    result= new unIdentExpreConIdentAST(tempsimbol2);
                    ind=true;

                     }
                    else
                    {
                    acceptIt();
                    tempsimbol2=currentToken;
                    accept(sym.ID, "ident");
                    temp= new unIdentExpreConIdentAST(tempsimbol2);
                    result = new varIdentExpreAST(result,temp);

                    }
                }
                else
                {

                    if(ind2==false)
                    {
                   acceptIt();
                   expr=parseExpr();
                   accept(sym.C_CER, "]");
                   result= new unIdentExpreConExprAST(expr);
                   ind2=true;
                    }
                    else
                    {
                    acceptIt();
                    expr=parseExpr();
                    accept(sym.C_CER, "]");
                    temp= new unIdentExpreConExprAST(expr);
                    result = new varIdentExpreAST(result,temp);

                        }
                    }

                    }

            if(tempsimbol2==null && result==null)
            {
                return new designatorSinIdentExprAST(tempsimbol);
            }
            else return new designatorConIdentExprAST(tempsimbol,result);
        }
Exemplo n.º 2
0
 Object VisitVarIdentExpreAST(varIdentExpreAST var, object arg)
 {
     int numaux = ((Integer)arg).intValue(); printtab(numaux); System.out.println(c.getClass().getName());  if(c.- !=null)  c.-.visit(this,new Integer(numaux+1)); else{printtab(numaux+1);  Console.WriteLine(“NULL”);} return null;
 }
Exemplo n.º 3
0
        public designatorAST parseDesignator()
        {//Designator
            //Designator = ident { "." ident | "[" Expr "]" }
            listIdentExprAST temp        = null;
            listIdentExprAST result      = null;
            Symbol           tempsimbol2 = null;
            exprAST          expr        = null;
            Symbol           tempsimbol  = currentToken;

            accept(sym.ID, "ident");
            Boolean ind  = false;
            Boolean ind2 = false;

            while (currentToken.sym == sym.PUNTO || currentToken.sym == sym.C_ABI)
            {
                if (currentToken.sym == sym.PUNTO)
                {
                    if (ind == false)
                    {
                        acceptIt();
                        tempsimbol2 = currentToken;
                        accept(sym.ID, "ident");
                        result = new unIdentExpreConIdentAST(tempsimbol2);
                        ind    = true;
                    }
                    else
                    {
                        acceptIt();
                        tempsimbol2 = currentToken;
                        accept(sym.ID, "ident");
                        temp   = new unIdentExpreConIdentAST(tempsimbol2);
                        result = new varIdentExpreAST(result, temp);
                    }
                }
                else
                {
                    if (ind2 == false)
                    {
                        acceptIt();
                        expr = parseExpr();
                        accept(sym.C_CER, "]");
                        result = new unIdentExpreConExprAST(expr);
                        ind2   = true;
                    }
                    else
                    {
                        acceptIt();
                        expr = parseExpr();
                        accept(sym.C_CER, "]");
                        temp   = new unIdentExpreConExprAST(expr);
                        result = new varIdentExpreAST(result, temp);
                    }
                }
            }

            if (tempsimbol2 == null && result == null)
            {
                return(new designatorSinIdentExprAST(tempsimbol));
            }
            else
            {
                return(new designatorConIdentExprAST(tempsimbol, result));
            }
        }