Package Dependencies.PR1.Symbols

Examples of Dependencies.PR1.Symbols.VT


        }
        return toReturn;
    }

    private boolean esTerminal(String simb, Collection<VN> listaVN, Collection<VT> listaVT) {
        VT v = new VT(simb);
        return listaVT.contains(v);//!(Character.isUpperCase(simb));
    }
View Full Code Here


            aux = br.readLine(); //Línea de VT.
            String linea_VT = aux.substring(6, aux.length() - 1);
            split = linea_VT.split(", ");
            for (String s : split) {
                listaVT.add(new VT(s));
            }

            //Tratamos P.

            aux = br.readLine(); //Línea de P.
View Full Code Here

        //Consecuente = lambda
    }

    void PASO() {
        if (esCasa()) {
            Match(new VT("TK_CASA"));
            t.home();
            return;
        }
        if (esGiro()) {
            Match(new VT("TK_GIRO"));
            double d = E();
            t.turn(d);
            return;
        }
        if (esAvanza()) {
            Match(new VT("TK_AVANZA"));
            double d = E();
            t.penUp();
            t.move(d);
            t.penDown();
            return;
        }
        if (esPinta()) {
            Match(new VT("TK_PINTA"));
            double d = E();
            t.forward(d);
            return;
        }
        if (esID()) {
            String nombreID = (String) tokenActual.getContenido();
            Match(new VT("TK_ID"));
            Match(new VT("TK_ASIGN"));
            double d = E();
            tablaIdentificadores.put(nombreID, d);
            return;
        }
        if (esColor()) {
            Match(new VT("TK_COLOR"));
            Match(new VT("TK_ASIGN"));
            Color c = COLOR();
            t.setColor(c);
            return;
        }
        if (esCondicional()) {
            Match(new VT("TK_SI"));
            boolean resultado = CONDICIONAL();
            if (resultado) {
                Match(new VT("TK_ENTONCES"));
                PASO();
                nLlamadasRecursivas--;
            }
            else {
                irSiguienteLinea();
            }
            return;
        }
        if (esSalto()) {
            Match(new VT("TK_IR_A"));
            int valor = (int) E();
            saltar(valor);
            return;
        }
        throw new SyntaxException("Esperaba pinta, casa, avanza, giro, identificador, color, condicional (SI) o salto (ir_a).");
View Full Code Here

    }

    boolean COND_PAR() {
        boolean salida = true;
        if (esParentesisAbierto()) {
            Match(new VT("TK_PAR_ABR"));
            salida = CONDICIONAL();
            Match(new VT("TK_PAR_CER"));
            if (esAndOr()) {
                salida = AndOr(salida);
            }
        }
        return salida;
View Full Code Here

        return salida;
    }

    boolean NOT(boolean not) {
        if (esNot()) {
            Match(new VT("TK_NOT"));
            not = !NOT(not);
        }
        return not;
    }
View Full Code Here

        return not;
    }

    boolean AndOr(boolean r) {
        if (esAnd()) {
            Match(new VT("TK_AND"));
            boolean r2 = CONDICIONAL();
            return r && r2;
        }
        if (esOr()) {
            Match(new VT("TK_OR"));
            boolean r2 = CONDICIONAL();
            return r || r2;
        }
        throw new OperatorException("Esperaba AND o OR.");
    }
View Full Code Here

    boolean COMP() {
        double valor1 = E();
        if (esComparador()) {
            if (esMayor()) {
                Match(new VT("TK_MAYOR"));
                double valor2 = E();
                return valor1 > valor2;
            }
            else if (esMenor()) {
                Match(new VT("TK_MENOR"));
                double valor2 = E();
                return valor1 < valor2;
            }
            else if (esDistinto()) {
                Match(new VT("TK_DISTINTO"));
                double valor2 = E();
                return valor1 != valor2;
            }
            else if (esComparacion()) {
                Match(new VT("TK_IGUALDAD"));
                double valor2 = E();
                return valor1 == valor2;
            }
            else if (esMayorIgual()) {
                Match(new VT("TK_MAYOR_IGUAL"));
                double valor2 = E();
                return valor1 >= valor2;
            }
            else if (esMenorIgual()) {
                Match(new VT("TK_MENOR_IGUAL"));
                double valor2 = E();
                return valor1 <= valor2;
            }
        }
        throw new OperatorException("Esperaba comparador.");
View Full Code Here

        throw new OperatorException("Esperaba comparador.");
    }

    Color COLOR() {
        if (esNegro()) {
            Match(new VT("TK_NEGRO"));
            return Color.black;
        }
        if (esVerde()) {
            Match(new VT("TK_VERDE"));
            return Color.green;
        }
        if (esNaranja()) {
            Match(new VT("TK_NARANJA"));
            return Color.orange;
        }
        if (esRosa()) {
            Match(new VT("TK_ROSA"));
            return Color.pink;
        }
        if (esRojo()) {
            Match(new VT("TK_ROJO"));
            return Color.red;
        }
        if (esBlanco()) {
            Match(new VT("TK_BLANCO"));
            return Color.white;
        }
        if (esAmarillo()) {
            Match(new VT("TK_AMARILLO"));
            return Color.yellow;
        }
        if (esMagenta()) {
            Match(new VT("TK_MAGENTA"));
            return Color.magenta;
        }
        throw new ColorException("Esperaba color.");
    }
View Full Code Here

        return valor;
    }

    double E_PRIMA(double valor) {
        if (esSuma()) {
            Match(new VT("TK_MAS"));
            double valor2 = T();
            valor += valor2;
            if (esSumaResta()) {
                valor = E_PRIMA(valor);
            }
            return valor;
        }
        if (esResta()) {
            Match(new VT("TK_MENOS"));
            double valor2 = T();
            valor -= valor2;
            if (esSumaResta()) {
                valor = E_PRIMA(valor);
            }
View Full Code Here

        return valor;
    }

    double T_PRIMA(double valor) {
        if (esMultiplicacion()) {
            Match(new VT("TK_PROD"));
            double valor2 = F();
            valor *= valor2;
            if (esMultiplicacionDivision()) {
                valor = T_PRIMA(valor);
            }
            return valor;
        }
        if (esDivision()) {
            Match(new VT("TK_DIV"));
            double valor2 = F();
            if (valor2 == 0) {
                throw new InterpreterException("División entre 0.");
            }
            valor /= valor2;
View Full Code Here

TOP

Related Classes of Dependencies.PR1.Symbols.VT

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.