Exemple #1
0
        public Access Accesories(Access List)
        {
            try
            {
                if (currentToken.Tipo == Lexico.TipoToken.TK_PUNTO)
                {
                    currentToken = lex.NextToken();
                    if (currentToken.Tipo != Lexico.TipoToken.TK_ID)
                        throw new Exception("Error Sintactico  -- Se esperaba un ID");
                    Lexico.Token tmp = currentToken;
                    currentToken = lex.NextToken();
                    if (currentToken.Tipo == Lexico.TipoToken.TK_OPENCOR)
                    {
                        AccessArreglo accAr = new AccessArreglo();
                        accAr.Cont = ArrayDim(accAr.Cont);
                        accAr.nombre = tmp.Lexema;
                        List = accAr;
                        List.Next = Accesories(List.Next);
                    }
                    else
                    {

                        AccessMiembro accM = new AccessMiembro();
                        accM.Id = tmp.Lexema;
                        List = accM;
                        //currentToken = lex.NextToken();
                        List.Next = Accesories(List.Next);
                    }
                }
                else if (currentToken.Tipo == Lexico.TipoToken.TK_OPENCOR)
                {
                    AccessArreglo accAr = new AccessArreglo();
                    accAr.Cont = ArrayDim(accAr.Cont);
                    List = accAr;
                    List.Next = Accesories(List.Next);
                }
                else if (currentToken.Tipo == Lexico.TipoToken.TK_OPENPAR)
                {
                    currentToken = lex.NextToken();
                    AccessFunc accFun = new AccessFunc();
                    ListaExpre listaExpre = new ListaExpre();
                    Expresiones e = Expression();
                    if (e != null)
                        listaExpre.Ex.Add(e);
                    if (listaExpre.Ex.Count > 0)
                        accFun.Variables = ExpreList(listaExpre);
                    List = accFun;
                    if (currentToken.Tipo != Lexico.TipoToken.TK_CLOSEPAR)
                        throw new Exception("Error Sintactico -- Se esperaba simbolo )");
                    currentToken = lex.NextToken();
                    return List;
                }
                return List;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        Access AccessList(string par)
        {
            switch (currentToken.Tipo)
            {
                case TipoToken.TK_PUNTO:
                    {
                        currentToken = lex.NextToken();
                        if (currentToken.Tipo != TipoToken.TK_ID)
                            throw new Exception("Se esperaba identificador.");
                        else
                        {
                            string tmp = currentToken.Lexema;
                            currentToken = lex.NextToken();
                            if (currentToken.Tipo == TipoToken.TK_OPENCOR)
                            {
                                Access ret;
                                try
                                {
                                    ret = AccessList(tmp);
                                    ret.Next = AccessList(null);
                                }
                                catch (Exception ex) { throw ex; }
                                return ret;
                            }
                            else
                            {
                                AccessMiembro ret = new AccessMiembro();
                                ret.Id = tmp;
                                try { ret.Next = AccessList(null); }
                                catch (Exception ex) { throw ex; }
                                return ret;
                            }
                        }
                    }

                case TipoToken.TK_OPENCOR:
                    {
                        if (par == null)
                            throw new Exception("Se esperaba otro accesor.");
                        currentToken = lex.NextToken();
                        AccessArreglo ret = new AccessArreglo();
                        ret.nombre = par;
                        try { ret.Cont = ExprList(); }
                        catch (Exception ex) { throw ex; }
                        if (currentToken.Tipo != TipoToken.TK_CLOSECOR)
                            throw new Exception("Se esperaba ].");
                        else
                        {
                            currentToken = lex.NextToken();
                            try { ret.Next = AccessList(null); }
                            catch (Exception ex) { throw ex; }
                            return ret;
                        }
                    }

                default: return null;
            }
        }
Exemple #3
0
        public Access Accesories(Access List)
        {
            try
            {
                if (currentToken.Tipo == TipoToken.TK_PUNTO)
                {
                    currentToken = lex.NextToken();
                    if (currentToken.Tipo != TipoToken.TK_ID)
                        throw new Exception("Error Sintactico - Se Esperaba un ID");
                    AccessMiembro accM = new AccessMiembro();
                    accM.Id = currentToken.Lexema;
                    List = accM;
                    currentToken = lex.NextToken();
                    List.Next = Accesories(List.Next);
                    Access a = Accesories(List.Next);

                }
                else if (currentToken.Tipo == TipoToken.TK_OPENCOR)
                {
                    AccessArreglo accAr = new AccessArreglo();
                    accAr.Cont = ArrayDim(accAr.Cont);
                    List = accAr;
                    List.Next = Accesories(List.Next);
                }
                else if (currentToken.Tipo == TipoToken.TK_OPENPAR)
                {
                    currentToken = lex.NextToken();
                    AccessFunc accFun = new AccessFunc();
                    ListaExpre listaExpre = new ListaExpre();
                    Expresiones e = Expr();
                    if (e != null)
                        listaExpre.Ex.Add(e);
                    //if (listaExpre.Ex.Count > 0)
                    //{
                    accFun.Variables = ExprList(listaExpre);
                    List = accFun;
                    if (currentToken.Tipo != TipoToken.TK_CLOSEPAR)
                        throw new Exception("Error Sintactico - Se Esperaba un )");
                    currentToken = lex.NextToken();
                    return List;
                    /*}
                    else
                    {
                        if (currentToken.Tipo != TipoToken.TK_CLOSEPAR)
                            throw new Exception("Error Sintactico - Se Esperaba un )");
                        currentToken = lex.NextToken();
                        return null;
                    }*/
                }
                return List;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }