Exemple #1
0
def p_expresion_cadena(t):
    'valor    : CADENA'
    t[0] = ABCInstruccion.Valor(t[1], 2)
    t[0] = ABCInstruccion.ExpresionSimple(t[0])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[1]))
    Ts.rp_nuevo_nodo('valor    : CADENA', "t[0] = ABCInstruccion.Valor(t[1], 2)")
Exemple #2
0
def p_expresion_entero(t):
    'valor    : ENTERO'
    t[0] = ABCInstruccion.Valor(t[1], 0)
    t[0] = ABCInstruccion.ExpresionSimple(t[0])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[1]))
    Ts.rp_nuevo_nodo('valor    : ENTERO', "t[0] = ABCInstruccion.Valor(t[1], 0)")
Exemple #3
0
def p_expresion_decimal(t):
    'valor    : DECIMAL'
    t[0] = ABCInstruccion.Valor(t[1], 1)
    t[0] = ABCInstruccion.ExpresionSimple(t[0])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[1]))
    Ts.rp_nuevo_nodo('valor    : DECIMAL', "t[0] = ABCInstruccion.Valor(t[1], 1)")
Exemple #4
0
def p_instrucciones_imprimir(t):
    'instruccion :  IMPRIMIR  PARA expresion PARC PUNTOCOMA'
    t[0] = ABCInstruccion.Imprimir(t[3])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[1]))
    Ts.rp_nuevo_nodo('instruccion :  IMPRIMIR  PARA expresion PARC PUNTOCOMA', "t[0] = ABCInstruccion.Imprimir(t[3])")
Exemple #5
0
def p_expresion_binaria(t):
    '''expresion : valor MAS valor
                  | valor MENOS valor
                  | valor POR valor
                  | valor DIVIDIDO valor
                  | valor MOD valor
                  | valor ANDB valor
                  | valor ORB valor
                  | valor XORB valor
                  | valor SHIFTD valor
                  | valor SHIFTI valor




                  | valor AND valor
                  | valor OR valor
                  | valor XOR valor


                  | valor DIFERENTE valor
                  | valor IGUALDOBLE valor
                  | valor MAYOR valor
                  | valor MAYORIGUAL valor
                  | valor MENORIGUAL valor
                  | valor MENOR valor'''

    t[0] = ABCInstruccion.ExpresionDoble(t[1], t[2], t[3])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[2]))
    Ts.rp_nuevo_nodo('expresion : valor '+str(t[2])+ ' valor', "t[0] = ABCInstruccion.ExpresionDoble(t[1], t[2], t[3])")
Exemple #6
0
def p_etiqeutas_sin_recursividad_epsilon(t):
    'etiquetasp : '
    t[0] = ABCInstruccion.ListaEtiqueta([t[-1]])

    global Ts
    Ts.rp_nuevo_nodo('etiquetasp : ',
                     "t[0] = ABCInstruccion.ListaEtiqueta([t[-1]])")
Exemple #7
0
def p_instrucciones_lista_sin_recursividad_epsilon(t):
    'instruccionesp : '
    t[0] = ABCInstruccion.ListaInstruccion([])

    global Ts
    Ts.rp_nuevo_nodo('instruccionesp : ',
                     "t[0] = ABCInstruccion.ListaInstruccion([])")
Exemple #8
0
def p_expresion_agrupacion(t):
    '''expresion : PARA INT PARC valor
                | PARA FLOAT PARC valor
                | PARA CHAR PARC valor'''

    t[0] = ABCInstruccion.ExpresionSimpleOperacion(t[4], t[2])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[1]))
    Ts.rp_nuevo_nodo('expresion : PARA' + str(t[2]) + 'PARC valor', "t[0] = ABCInstruccion.ExpresionSimpleOperacion(t[4], t[2])")
Exemple #9
0
def p_expresion_unaria(t):
    '''expresion : MENOS valor
                | ABS PARA valor PARC
                | NOTB valor
                | NOT valor
                | MAS valor
                | ANDB DOLAR IDENTIFICADOR arra
                | READ PARA  PARC
                | ARRAY PARA  PARC '''

    if t[2] == "(":
        t[0] = ABCInstruccion.ExpresionSimpleOperacion(t[3], t[1])
    elif t[1] == "&":
        t[0] = Referencia(t[3], t[4])

    else:
        t[0] = ABCInstruccion.ExpresionSimpleOperacion(t[2], t[1])

    global Ts
    t[0].n_t(find_column(Ts.texto_analisis, t.slice[1]))
    Ts.rp_nuevo_nodo('expresion : '+str(t[1])+'valor', "t[0] = ABCInstruccion.ExpresionSimpleOperacion(t[3], t[1])")
Exemple #10
0
def p_instrucciones_lista_inicio(t):
    'instrucciones :  '
    t[0] = ABCInstruccion.ListaInstruccion([])
    global Ts
    Ts.rp_nuevo_nodo('instrucciones :  ', "t[0] = ABCInstruccion.ListaInstruccion([])")
Exemple #11
0
def p_etiquetas_lista_inicio(t):
    'etiquetas : etiqueta'
    t[0] = ABCInstruccion.ListaEtiqueta([t[1]])

    global Ts
    Ts.rp_nuevo_nodo('etiquetas : etiqueta', "t[0] = ABCInstruccion.ListaEtiqueta([t[1]])")