예제 #1
0
 public Object visit(ArrayLocation location) {
   Expression e1 = location.getIndex();
   Expression e2 = location.getArray();
   e1.accept(this);
   e2.accept(this);
   if (Type.isInt(e1)) {
     if (e2.getSemanticType() instanceof ArrayType) {
       ArrayType e3 = (ArrayType) e2.getSemanticType();
       location.setSemanticType(e3.getElemType());
       return null;
     } else {
       return location;
     }
   }
   return location;
 }
예제 #2
0
 @Override
 public Object visit(ArrayLocation location) throws SemanticError {
   location.getArray().accept(this);
   location.getIndex().accept(this);
   return null;
 }