def p_etiqueta(p): 'etiqueta : ID DOSPUNTOS sentencias' nodo = NodoG(getIndex(), "etiqueta", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), ":", None)) nodo.add(p[3]) p[0] = nodo
def p_dimensionesP(p): 'dimensionesP : dimension dimensionesP ' nodo = NodoG(getIndex(), "dimensionesP", []) nodo2 = NodoG(getIndex(), "dimension", []) nodo2.add(p[1]) nodo.add(nodo2) nodo.add(p[2]) p[0] = nodo
def p_instrucciones(p): 'instrucciones : instruccion instruccionesP' nodo = NodoG(getIndex(), "instruciones", []) nodo2 = NodoG(getIndex(), "instruccion", []) nodo2.add(p[1]) nodo.add(nodo2) nodo.add(p[2]) p[0] = nodo
def p_main(p): 'main : MAIN DOSPUNTOS sentencias' nodo = NodoG(getIndex(), "main", []) nodo.add(NodoG(getIndex(), "main", None)) nodo.add(NodoG(getIndex(), ":", None)) nodo.add(p[3]) p[0] = nodo
def p_operacion2(p): '''operacion : valor operacionP ''' nodo = NodoG(getIndex(), "operacion", []) nodo.add(p[1]) nodo.add(p[2]) p[0] = nodo
def p_sentencias(p): 'sentencias : sentencia sentenciasP' nodo = NodoG(getIndex(), "sentencias", []) nodo2 = NodoG(getIndex(), "sentencia", []) nodo2.add(p[1]) nodo.add(nodo2) nodo.add(p[2]) p[0] = nodo
def p_operacionP(p): '''operacionP : MAS valor | MENOS valor | MULTIPLICACION valor | DIVISION valor | MODULAR valor | AND valor | OR valor | XOR valor | IGUALIGUAL valor | DIFERENTE valor | MAYOR valor | MENOR valor | MAYORIGUAL valor | MENORIGUAL valor | ANDBIT valor | ORBIT valor | XORBIT valor | SHIFTIZQ valor | SHIFTDER valor ''' nodo = NodoG(getIndex(), "operacionP", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(p[2]) p[0] = nodo
def p_valor(p): '''valor : ENTERO | DECIMAL | CADENA | CADENA2 | VARIABLE ''' p[0] = NodoG(getIndex(), str(p[1]), None)
def p_operacion(p): '''operacion : NOT valor | NOTBIT valor | MENOS valor ''' nodo = NodoG(getIndex(), "operacion", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(p[2]) p[0] = nodo
def p_operaciones6(p): 'operacion : ABS PARIZQ MENOS valor PARDER' nodo = NodoG(getIndex(), "operacion", []) nodo.add(NodoG(getIndex(), "abs", None)) nodo.add(NodoG(getIndex(), "(", None)) nodo.add(NodoG(getIndex(), "-", None)) nodo.add(p[4]) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_pread(p): 'pread : VARIABLE IGUAL READ PARIZQ PARDER PYCOMA' nodo = NodoG(getIndex(), "pread", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), "=", None)) nodo.add(NodoG(getIndex(), "read", None)) nodo.add(NodoG(getIndex(), "(", None)) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_pprint(p): '''pprint : PRINT PARIZQ valor PARDER PYCOMA ''' nodo = NodoG(getIndex(), "pprint", []) nodo.add(NodoG(getIndex(), "print", None)) nodo.add(NodoG(getIndex(), "(", None)) nodo.add(p[3]) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_pprint3(p): 'pprint : PRINT PARIZQ VARIABLE dimensiones PARDER PYCOMA' nodo = NodoG(getIndex(), "pprint", []) nodo.add(NodoG(getIndex(), "print", None)) nodo.add(NodoG(getIndex(), "(", None)) nodo2 = NodoG(getIndex(), "operacion", []) nodo2.add(NodoG(getIndex(), p[3], None)) nodo2.add(p[4]) nodo.add(nodo2) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_instruccionesP2(p): 'instruccionesP :' p[0] = NodoG(getIndex(), "epsilon", None)
def p_array(p): 'parray : VARIABLE IGUAL ARRAY PARIZQ PARDER PYCOMA' nodo = NodoG(getIndex(), "parray", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), "=", None)) nodo.add(NodoG(getIndex(), "array()", None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_main2(p): '''main : MAIN DOSPUNTOS ''' nodo = NodoG(getIndex(), "main", []) nodo.add(NodoG(getIndex(), "main", None)) nodo.add(NodoG(getIndex(), ":", None)) nodo.add(NodoG(getIndex(), "epsilon", None)) p[0] = nodo
def p_psalir(p): 'pexit : EXIT PYCOMA' nodo = NodoG(getIndex(), "pexit", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_dimensionesP2(p): 'dimensionesP : ' p[0] = NodoG(getIndex(), "epsilon", None)
def p_operacionP2(p): 'operacionP : ' p[0] = NodoG(getIndex(), "epsilon", None)
def p_etiqueta2(p): 'etiqueta : ID DOSPUNTOS ' nodo = NodoG(getIndex(), "etiqueta", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), ":", None)) nodo.add(NodoG(getIndex(), "epsilon", None)) p[0] = nodo
def p_arreglo(p): 'parreglo : VARIABLE dimensiones IGUAL operacion PYCOMA' nodo = NodoG(getIndex(), "pvariable", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(p[2]) nodo.add(NodoG(getIndex(), "=", None)) nodo.add(p[4]) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_pvariable(p): 'pvariable : VARIABLE IGUAL operacion PYCOMA' nodo = NodoG(getIndex(), "pvariable", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), "=", None)) nodo.add(p[3]) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_operacion7(p): 'operacion : VARIABLE dimensiones' nodo = NodoG(getIndex(), "operacion", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(p[2]) p[0] = nodo
def p_punset(p): 'punset : UNSET PARIZQ VARIABLE PARDER PYCOMA' nodo = NodoG(getIndex(), "punset", []) nodo.add(NodoG(getIndex(), "unset", None)) nodo.add(NodoG(getIndex(), "(", None)) nodo.add(NodoG(getIndex(), p[3], None)) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_operacion8(p): '''operacion : PARIZQ INTEGER PARDER valor | PARIZQ FLOAT PARDER valor | PARIZQ CHAR PARDER valor ''' nodo = NodoG(getIndex(), "operacion", []) nodo.add(NodoG(getIndex(), "(", None)) nodo.add(NodoG(getIndex(), p[2], None)) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(p[4]) p[0] = nodo
def p_pif(p): 'pif : IF PARIZQ operacion PARDER GOTO ID PYCOMA ' nodo = NodoG(getIndex(), "pif", []) nodo.add(NodoG(getIndex(), "if", None)) nodo.add(NodoG(getIndex(), "(", None)) nodo.add(p[3]) nodo.add(NodoG(getIndex(), ")", None)) nodo.add(NodoG(getIndex(), "got", None)) nodo.add(NodoG(getIndex(), p[6], None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_prefencia(p): 'preferencia : VARIABLE IGUAL ANDBIT VARIABLE PYCOMA ' nodo = NodoG(getIndex(), "preferencia", []) nodo.add(NodoG(getIndex(), p[1], None)) nodo.add(NodoG(getIndex(), "=", None)) nodo.add(NodoG(getIndex(), "&", None)) nodo.add(NodoG(getIndex(), p[4], None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_sentenciasP(p): '''sentenciasP : ''' p[0] = NodoG(getIndex(), "epsilon", None)
def p_pgoto(p): 'pgoto : GOTO ID PYCOMA' nodo = NodoG(getIndex(), "pgoto", []) nodo.add(NodoG(getIndex(), "goto", None)) nodo.add(NodoG(getIndex(), p[2], None)) nodo.add(NodoG(getIndex(), ";", None)) p[0] = nodo
def p_init(p): 'init : instrucciones' p[0] = NodoG(getIndex(), "init", [p[1]])