implementation module Sil.Error import StdFile import StdString import Text import Sil.Syntax import Sil.Types instance toString Error where toString (P_Invalid loc sym) = "Invalid token '" <+ sym <+ "' while parsing a " <+ loc <+ "." toString (P_Expected s) = "Expected " <+ s <+ "." toString (T_IllegalApplication ft et) = "Cannot apply a " <+ et <+ " to a " <+ ft <+ "." toString (T_IllegalField f t) = "Illegal field '" <+ f <+ "' on type " <+ t <+ "." toString (T_TooHighTupleArity i) = "Too high tuple arity " <+ i <+ " (maximum is 32)." toString (C_UndefinedName n) = "Undefined name '" <+ n <+ "'." toString (C_UndefinedField f) = "Undefined field '" <+ f <+ "'." toString C_VariableLabel = "Variable stored at label." toString C_FunctionOnStack = "Function stored on the stack." toString (C_TypeError err e) = "Type error in '" <+ e <+ "': " <+ err toString (C_CouldNotDeduceType e) = "Could not deduce type of '" <+ e <+ "'." toString (C_TypeMisMatch t e t`) = "Type mismatch: expected " <+ t <+ " for '" <+ e <+ "'; had " <+ t` <+ "." toString (C_BasicInitWithoutValue n) = "Basic value '" <+ n <+ "' must have an initial value." toString (UnknownError e) = "Unknown error: " <+ e <+ "." instance <<< Error where <<< f e = f <<< toString e <<< "\r\n"