Example #1
0
def p_incremento3(p):
    'incremento :   ID tipo_asignacion '
    if p[2].childs:
        p[0] = NodoG(p[2].index, p[2].nombre,
                     [NodoG(getIndex(), p[1], None), p[2].childs[0]])
    else:
        p[0] = NodoG(p[2].index, p[2].nombre, [NodoG(getIndex(), p[1], None)])
Example #2
0
def p_operaciones_unarias(p):
    '''operacion    :   MENOS   operacion   %prec UMENOS
                    |   NOT     operacion   %prec UMENOS
                    |   NOTBIT  operacion   %prec UMENOS
                    |   ANDBIT  operacion   %prec UMENOS
    '''
    p[0] = NodoG(getIndex(), "unaria", [NodoG(getIndex(), p[1], None), p[2]])
Example #3
0
def p_if_elseif_else(p):
    'if :   IF PARIZQ operacion PARDER LLAVEIZQ sentencias LLAVEDER else_if ELSE LLAVEIZQ sentencias LLAVEDER'
    nodo_if = NodoG(getIndex(), "if", [p[3], p[6]])
    nodo_elif = NodoG(
        getIndex(), "sentencia",
        [nodo_if, p[8], NodoG(getIndex(), "else", [p[11]])])
    p[0] = nodo_elif
Example #4
0
def p_asignacion2(p):
    'asignacion     :   ID tipo_asignacion PYCOMA'
    if p[2].childs:
        p[0] = NodoG(p[2].index, p[2].nombre,
                     [NodoG(getIndex(), p[1], None), p[2].childs[0]])
    else:
        p[0] = NodoG(p[2].index, p[2].nombre, [NodoG(getIndex(), p[1], None)])
Example #5
0
def p_primitivo(p):
    '''primitivo    :   INTEGER
                    |   FLOAT
                    |   DOUBLE
                    |   CHAR
    '''
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #6
0
def p_operaciones_numerica(p):
    '''operacion    :   operacion   MAS             operacion
                    |   operacion   MENOS           operacion
                    |   operacion   MULTIPLICACION  operacion
                    |   operacion   DIVISION        operacion
                    |   operacion   MODULAR         operacion
    '''
    p[0] = NodoG(getIndex(), p[2], [p[1], p[3]])
Example #7
0
def p_tipo(p):
    '''tipo         :   INTEGER
                    |   FLOAT
                    |   DOUBLE
                    |   CHAR
                    |   ID
    '''
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #8
0
def p_operaciones_bit(p):
    '''operacion    :   operacion   ANDBIT          operacion
                    |   operacion   ORBIT           operacion 
                    |   operacion   XORBIT          operacion
                    |   operacion   SHIFTIZQ        operacion
                    |   operacion   SHIFTDER        operacion
    '''
    p[0] = NodoG(getIndex(), p[2], [p[1], p[3]])
Example #9
0
def p_operaciones_relacionales(p):
    '''operacion    :   operacion   IGUALIGUAL      operacion
                    |   operacion   DIFERENTE       operacion 
                    |   operacion   MAYOR           operacion
                    |   operacion   MENOR           operacion
                    |   operacion   MAYORIGUAL      operacion
                    |   operacion   MENORIGUAL      operacion
    '''
    p[0] = NodoG(getIndex(), p[2], [p[1], p[3]])
Example #10
0
def p_tipo_asignacion(p):
    '''tipo_asignacion  :      MASIGUAL        operacion
                        |      MENOSIGUAL      operacion
                        |      ASTERISCOIGUAL  operacion
                        |      BARRAIGUAL      operacion
                        |      MODULARIGUAL    operacion
                        |      SHIFTDERIGUAL   operacion
                        |      SHIFTIZQIGUAL   operacion
                        |      ANDIGUAL        operacion
                        |      ORIGUAL         operacion
                        |      XORIGUAL        operacion
    '''
    p[0] = NodoG(getIndex(), p[1], [p[2]])
Example #11
0
def p_operacion_arreglo(p):
    'operacion  :   ID corchetes'
    p[0] = NodoG(getIndex(), "arreglo", [NodoG(getIndex(), p[1], None), p[2]])
Example #12
0
def p_operacion_scan(p):
    'operacion  :   SCAN PARIZQ PARDER'
    p[0] = NodoG(getIndex(), "scanf", None)
Example #13
0
def p_operacion_struct(p):
    'operacion  : ID PUNTO atributos'
    p[0] = NodoG(getIndex(), ".", [NodoG(getIndex, p[1], None), p[3]])
Example #14
0
def p_casos(p):
    'casos  :   casos caso'
    p[0] = NodoG(getIndex(), "casos", [p[1], p[2]])
Example #15
0
def p_valor_char(p):
    'valor          : CARACTER'
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #16
0
def p_valor_identificador(p):
    'valor          : ID'
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #17
0
def p_operaciones_logicas(p):
    '''operacion    :   operacion   AND             operacion
                    |   operacion   OR              operacion 
    '''
    p[0] = NodoG(getIndex(), p[2], [p[1], p[3]])
Example #18
0
def p_return(p):
    'return :   RETURN operacion PYCOMA'
    p[0] = NodoG(getIndex(), "return", [p[2]])
Example #19
0
def p_break(p):
    'break  :   BREAK PYCOMA'
    p[0] = NodoG(getIndex(), "break", None)
Example #20
0
def p_caso2(p):
    'caso   :   DEFAULT DOSPUNTOS sentencias'
    p[0] = NodoG(getIndex(), ":", [NodoG(getIndex(), p[1], None), p[3]])
Example #21
0
def p_caso(p):
    'caso   :   CASE operacion DOSPUNTOS sentencias'
    p[0] = NodoG(getIndex(), ":", [p[2], p[4]])
Example #22
0
def p_operacion_arreglo_struct(p):
    'operacion  :   ID corchetes PUNTO atributos'
    arreglo = NodoG(getIndex(), "arreglo",
                    [NodoG(getIndex(), p[1], None), p[2]])
    p[0] = NodoG(getIndex(), ".", [arreglo, p[4]])
Example #23
0
def p_print2(p):
    'print  :   PRINT PARIZQ CADENA PARDER PYCOMA'
    p[0] = NodoG(getIndex(), "print", [NodoG(getIndex(), p[3], None)])
Example #24
0
def p_valores(p):
    'valores    :   valores COMA operacion'
    p[0] = NodoG(getIndex(), "valores", [p[1], p[3]])
Example #25
0
def p_valor_integer(p):
    'valor          : ENTERO'
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #26
0
def p_operaciones_funcion(p):
    'operacion :   ID PARIZQ PARDER'
    p[0] = NodoG(getIndex(), p[1], None)
Example #27
0
def p_valor_double(p):
    'valor          : DECIMAL'
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #28
0
def p_operaciones_funcion2(p):
    'operacion :   ID PARIZQ valores PARDER'
    p[0] = NodoG(getIndex(), "call", [NodoG(getIndex(), p[1], None), p[3]])
Example #29
0
def p_valor_cadena(p):
    'valor          : CADENA'
    p[0] = NodoG(getIndex(), str(p[1]), None)
Example #30
0
def p_switch(p):
    'switch :   SWITCH PARIZQ operacion PARDER LLAVEIZQ casos LLAVEDER'
    p[0] = NodoG(getIndex(), "switch", [p[3], p[6]])