// Identifier i; // Exp e1,e2; public Object visit(ArrayAssign n) { // Implementado n.i.accept(this); String tipo = typeOf(n.i.s, n.getLine_number()); Object exp1 = n.e1.accept(this); Object exp2 = n.e2.accept(this); if ((exp1 instanceof String) && (exp2 instanceof String) && (tipo != null)) { String ep1 = (String) exp1; String ep2 = (String) exp2; boolean valida = ep1.equalsIgnoreCase("IntegerType") && tipo.equalsIgnoreCase("IntArrayType") && ep2.equalsIgnoreCase("IntegerType"); if (valida) return "IntegerType"; else { error.add("Atribuicao invalida! Tipos incompativeis! Linha: " + n.getLine_number()); } } return null; }
@Override public void visit(ArrayAssign arrayAssignStm) { if (arrayAssignStm.getId() != null) arrayAssignStm.getId().accept(this); System.out.print("["); if (arrayAssignStm.getIndex() != null) arrayAssignStm.getIndex().accept(this); System.out.print("] = "); if (arrayAssignStm.getValue() != null) arrayAssignStm.getValue().accept(this); System.out.print(";"); }