Пример #1
0
 public Expresiones Relexp_prime(Expresiones E)
 {
     try
     {
         if (currentToken.Tipo == Lexico.TipoToken.TK_IGUALDAD)
         {
             currentToken = lex.NextToken();
             Equal equal = new Equal(E, Addexp());
             return equal;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_DISTINTO)
         {
             currentToken = lex.NextToken();
             Distinto dist = new Distinto(E, Addexp());
             return dist;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_MAYORQUE)
         {
             currentToken = lex.NextToken();
             Expresiones x = Addexp();
             MayorQue mayorQ = new MayorQue(E, x);
             return mayorQ; ;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_MAYORIGUAL)
         {
             currentToken = lex.NextToken();
             MayorIgual mayorI = new MayorIgual(E, Addexp());
             return mayorI;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_MENORQUE)
         {
             currentToken = lex.NextToken();
             MenorQue menorQ = new MenorQue(E, Addexp());
             return menorQ;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_MENORIGUAL)
         {
             currentToken = lex.NextToken();
             MenorIgual menorI = new MenorIgual(E, Addexp());
             return menorI;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_MASMAS)
         {
             ExpMasMas mas = new ExpMasMas();
             if (E is Variable)
             {
                 Variable v = ((Variable)E);
                 mas.ID = v;
                 currentToken = lex.NextToken();
             }
             return mas;
         }
         else if (currentToken.Tipo == Lexico.TipoToken.TK_MENOSMENOS)
         {
             ExpMenosMenos menos = new ExpMenosMenos();
             if (E is Variable)
             {
                 Variable v = ((Variable)E);
                 menos.ID = v;
                 currentToken = lex.NextToken();
             }
             return menos;
         }
         return E;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        public Expresiones RelExprP(Expresiones E)
        {
            try
            {
                if (currentToken.Tipo == TipoToken.TK_IGUALDAD)
                {
                    currentToken = lex.NextToken();
                    Equal eEqual = new Equal(E, AddExpr());
                    return eEqual;
                }
                else if (currentToken.Tipo == TipoToken.TK_DISTINTO)
                {
                    currentToken = lex.NextToken();
                    Distinto eDist = new Distinto(E, AddExpr());

                    return eDist;
                }
                else if (currentToken.Tipo == TipoToken.TK_MAYORQUE)
                {
                    currentToken = lex.NextToken();
                    MayorQue eMayQ = new MayorQue(E, AddExpr());

                    return eMayQ;
                }
                else if (currentToken.Tipo == TipoToken.TK_MENORQUE)
                {
                    currentToken = lex.NextToken();
                    MenorQue eMenQ = new MenorQue(E, AddExpr());

                    return eMenQ;
                }
                else if (currentToken.Tipo == TipoToken.TK_MENORIGUAL)
                {
                    currentToken = lex.NextToken();
                    MenorIgual eMenI = new MenorIgual(E, AddExpr());

                    return eMenI;
                }
                else if (currentToken.Tipo == TipoToken.TK_MAYORIGUAL)
                {
                    currentToken = lex.NextToken();
                    MayorIgual eMayI = new MayorIgual(E, AddExpr());

                    return eMayI;
                }
                else if (currentToken.Tipo == TipoToken.TK_MASMAS)
                {
                    ExpMasMas mas = new ExpMasMas();
                    if (E is Variable)
                    {
                        Variable v = ((Variable)E);
                        mas.ID = v;
                        currentToken = lex.NextToken();
                    }
                    return mas;
                }
                else if (currentToken.Tipo == TipoToken.TK_MENOSMENOS)
                {
                    ExpMenosMenos menos = new ExpMenosMenos();
                    if (E is Variable)
                    {
                        Variable v = ((Variable)E);
                        menos.ID = v;
                        currentToken = lex.NextToken();
                    }
                    return menos;
                }
                else
                {
                    return E;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }