Improved error reporting with positions
[cc1516.git] / src / yard.icl
index 278bac8..932999a 100644 (file)
@@ -4,6 +4,9 @@ import StdTuple
 import StdClass
 import StdString
 import StdList
+import StdInt
+from Data.List import intersperse
+from Text import instance Text String, class Text(concat)
 import Data.Functor
 import Data.Either
 import Control.Monad
@@ -13,6 +16,8 @@ from Data.Func import $
 instance toString Error where
        toString ParseError = "General parse error"
        toString (LexError e) = "Lexer error: " +++ e
+    toString (Expected ts pos) = "Expected " +++ (concat $ intersperse ", " ts) 
+                                             +++ " at position " +++ (toString pos)
 
 instance + Error where
     (+) (Expected as _) (Expected bs p) = Expected (as++bs) p