From c23b7cd159af38f588ce4214d6ad37ceadf3c1a6 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 27 Jul 2017 23:32:59 +0200 Subject: Centralise errors (needed for positional errors #5) --- Sil/Error.icl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Sil/Error.icl (limited to 'Sil/Error.icl') diff --git a/Sil/Error.icl b/Sil/Error.icl new file mode 100644 index 0000000..b5d5941 --- /dev/null +++ b/Sil/Error.icl @@ -0,0 +1,25 @@ +implementation module Sil.Error + +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) = "Type mismatch: expected " <+ t <+ " for '" <+ e <+ "'." + toString (C_BasicInitWithoutValue n) = "Basic value '" <+ n <+ "' must have an initial value." + toString (UnknownError e) = "Unknown error: " <+ e <+ "." -- cgit v1.2.3