Ejemplo n.º 1
0
 /**
  * Accept a visitor
  *
  * @param v a visitor
  * @return the return type of the binary list function
  */
 @Override
 public Type accept(Visitor v) {
   Type arg_type = (Type) v.visit(arg);
   Type list_type = (Type) v.visit(list_argument);
   switch (binary_op) {
     case APPEND:
     case PREPEND:
       if (!list_type.is_list || !arg_type.flat_type.equals(list_type.flat_type)) {
         List<Type> list_types = new ArrayList<>();
         list_types.add(list_type);
         List<Type> arg_types = new ArrayList<>();
         arg_types.add(new Type(list_type.flat_type));
         TypeErrorReporter.mismatchErrorBinaryList(
             arg, arg_type, list_argument, list_type, binary_op.toString(), arg_types, list_types);
       }
       return list_type;
     default:
       System.err.println("Invalid Native List Binary Operation!");
       return null;
   }
 }
Ejemplo n.º 2
0
 /** @return string representation of a list binary op */
 @Override
 public String toString() {
   return binary_op.toString() + "(" + arg.toString() + ", " + list_argument.toString() + ")";
 }