ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Programación Python


Enviado por   •  13 de Enero de 2021  •  Prácticas o problemas  •  1.814 Palabras (8 Páginas)  •  68 Visitas

Página 1 de 8

INTERFAZ

from tkinter import *

from Funciones import abrirFichero,validacion

raiz = Tk()
raiz.title("Lenguajes y Compiladores")

cad=StringVar()

miFrame = Frame(raiz,width=1000, height = 600)
miFrame.pack()
#TITULO
Label(miFrame,text="RECONOCEDOR",font=("Algerian",25)).grid(row=0,column=1,padx=10,pady=20,sticky =W+E)

# ETIQUETA 1: CADENA FUENTE
Label(miFrame,text = "CADENA FUENTE",font=("Calibri",15,"bold")).grid(row = 1, column=0,padx=10,pady=10,sticky =W)


#CAJA DE TEXTO
areaTexto=Text(miFrame,width=45,height=30,font=(13))
areaTexto.grid(row=2,column=0,padx=10,pady=10,sticky =W)



#IMAGEN
miImagen=PhotoImage(file="flecha2.png")
miLabelImagen=Label(miFrame,image=miImagen)
miLabelImagen.grid(row=2,column=1)


btnArchivo = Button(miFrame,text="ABRIR ARCHIVO",font=("Calibri",15,"bold"),bd=5,width=25,command =
lambda : abrirFichero(areaTexto))
btnArchivo.grid(row=3,column=1,pady=15,sticky=E)

#BOTON
btnValidar = Button(miFrame,text="VALIDAR",font=("Calibri",15,"bold"),bd=5,width=25,command=validacion)
btnValidar.grid(row=2,column=3,pady=15,padx=15,sticky=E)


raiz.mainloop()

FUNCIONES

from tkinter import messagebox, filedialog, INSERT

lista_cad = []

tokens = []

def validacion():

    VACIO = 999

    QF = 100

    QE = -1

    q = 0

    iterador_token = generador_token()

    try:

        token = next(iterador_token)

    except IndexError:

        q=VACIO

    while (q != QF and q != QE and q != VACIO):

        if q == 0:

            if token == "TIPO":

                q = 1

            elif token == "ID":

                q = 6

            else:

                q = QE

        elif q == 1:

            if token == "ID":

                q = 2

            else:

                q = QE

        elif q == 2:

            if token == "FINSENTENCIA":

                q = 3

            elif token == "SEP":

                q = 1

            elif token == "ASIG":

                q = 4

            else:

                q = QE

        elif q == 3:

            if token == "$":

                q = QF

            elif token == "TIPO":

                q = 1

            elif token == "ID":

                q = 6

            else:

                q = QE

        elif q == 4:

            if token == "NUM":

                q = 5

            else:

                q = QE

        elif q == 5:

            if token == "FINSENTENCIA":

                q = 3

            elif token == "SEP":

                q = 1

            else:

                q = QE

        elif q == 6:

            if token == "ASIG":

                q = 7

            else:

                q = QE

        elif q == 7:

            if token == "ID" or token == "NUM":

                q = 8

            else:

                q = QE

...

Descargar como (para miembros actualizados)  txt (5.3 Kb)   pdf (63.7 Kb)   docx (8.8 Kb)  
Leer 7 páginas más »
Disponible sólo en Clubensayos.com