Exemplo n.º 1
0
 def p_declaracion(p):
     ''' declaracion : TkDeclare declist '''
     if post_program:
         linea = p.lineno(1)-first_line+2+comm
     else:
         linea = comm+1
     p[0] = declare(p[2],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
Exemplo n.º 2
0
    def p_exp(p):
        ''' exp : term
                | exp_un
                | TkParAbre exp TkParCierra
                | TkCorcheteAbre exp TkCorcheteCierra
                | TkLlaveAbre exp TkLlaveCierra 
                | exp TkMas exp 
                | exp TkMult exp
                | exp TkMod exp
                | exp TkDiv exp
                | exp TkResta exp
                | exp TkIgual exp
                | exp TkDesigual exp
                | exp TkMenor exp
                | exp TkMayor exp
                | exp TkMenorIgual exp
                | exp TkMayorIgual exp
                | exp TkDisyuncion exp
                | exp TkConjuncion exp 
                | exp TkConcat exp '''

        if len(p) == 2:
            p[0] = p[1]
        elif len(p) == 4 and p[1] != '(' and p[1] != '[' and p[1] != '{':
            p[0] = op_bin(p[1], p[3], p[2])
        elif len(p) == 4 and p[1] == '[':
            p[0] = tape(p[2], p.lineno(1),
                        funciones.find_column_parser(codigo, p.lexpos(1)))
        else:
            p[0] = p[2]
Exemplo n.º 3
0
    def p_exp(p): 
        ''' exp : term
                | exp_un
                | TkParAbre exp TkParCierra
                | TkCorcheteAbre exp TkCorcheteCierra
                | TkLlaveAbre exp TkLlaveCierra 
                | exp TkMas exp 
                | exp TkMult exp
                | exp TkMod exp
                | exp TkDiv exp
                | exp TkResta exp
                | exp TkIgual exp
                | exp TkDesigual exp
                | exp TkMenor exp
                | exp TkMayor exp
                | exp TkMenorIgual exp
                | exp TkMayorIgual exp
                | exp TkDisyuncion exp
                | exp TkConjuncion exp 
                | exp TkConcat exp '''

        if len(p) == 2:
            p[0] = p[1]
        elif len(p) == 4 and p[1] != '(' and p[1] != '[' and p[1] != '{':
            p[0] = op_bin(p[1],p[3],p[2])
        elif len(p) == 4 and p[1] == '[':
			p[0] = tape(p[2],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
        else:
            p[0] = p[2]
Exemplo n.º 4
0
 def p_instruccion_read(p):
     ''' instruccion : TkRead exp '''
     if post_program:
         linea = p.lineno(2)-first_line+2+comm
     else:
         linea = comm+1
     p[0] = inst_read(p[2],p.lineno(2),funciones.find_column_parser(codigo,p.lexpos(1)))
     p[0].checktype()
Exemplo n.º 5
0
 def p_instruccion_asignacion(p):
     ''' instruccion : TkIdent TkAsignacion exp '''
     if post_program:
         linea = p.lineno(1)-first_line+2+comm
     else:
         linea = comm+1
     p[0] = inst_asig(p[1],p[3],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
     p[0].checktype()
Exemplo n.º 6
0
 def p_term_bool(p):
     ''' term : TkTrue
             | TkFalse '''
     if post_program:
         linea = p.lineno(1)-first_line+2+comm
     else:
         linea = comm+1
     p[0] = booleano(p[1],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
Exemplo n.º 7
0
 def p_term_ident(p):
     ''' term : TkIdent '''
     if post_program:
         linea = p.lineno(1)-first_line+2+comm
     else:
         linea = comm+1
     p[0] = ident(p[1],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
     str_ = ""
     tabs = (contador+1)*"  "
Exemplo n.º 8
0
 def p_declaracion(p):
     ''' declaracion : TkDeclare declist '''
     p[0] = declare(p[2],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
Exemplo n.º 9
0
 def p_instruccion_read(p):
     ''' instruccion : TkRead exp '''
     p[0] = inst_read(p[2],p.lineno(2),funciones.find_column_parser(codigo,p.lexpos(1)))
     p[0].checktype()
Exemplo n.º 10
0
 def p_instruccion_asignacion(p):
     ''' instruccion : TkIdent TkAsignacion exp '''
     p[0] = inst_asig(p[1],p[3],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
     p[0].checktype()
Exemplo n.º 11
0
 def p_exp_un(p):
     ''' exp_un : TkResta exp %prec uminus 
                   | TkNegacion exp %prec unot
                   | TkInspeccion exp %prec uinspeccion '''
     p[0] = op_un(p[1],p[2],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
Exemplo n.º 12
0
 def p_term_ident(p):
     ''' term : TkIdent '''
     p[0] = ident(p[1],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
     str_ = ""
     tabs = (contador+1)*"  "
Exemplo n.º 13
0
 def p_term_bool(p):
     ''' term : TkTrue
             | TkFalse '''
     p[0] = booleano(p[1],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
Exemplo n.º 14
0
 def p_term_num(p):
     ''' term : TkNum '''
     p[0] = numero(p[1],p.lineno(1),funciones.find_column_parser(codigo,p.lexpos(1)))
     str_ = ""
     tabs = (contador+1)*"  "