aboutsummaryrefslogtreecommitdiffstats
path: root/src/Tokenizer.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-09-27 15:45:38 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:53 +0200
commit3b1144988c49c1221b1c5f6b8f7544f1dea7cb44 (patch)
tree1dbba923dbe11ada9e7138ad64e7272fe35553ab /src/Tokenizer.hs
parent0a56af62ffa95360587728b82c947a2936743a4c (diff)
Show position info in error messages
Diffstat (limited to 'src/Tokenizer.hs')
-rw-r--r--src/Tokenizer.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Tokenizer.hs b/src/Tokenizer.hs
index 64ba638..565caa5 100644
--- a/src/Tokenizer.hs
+++ b/src/Tokenizer.hs
@@ -12,6 +12,9 @@ data TChar = TChar {
tColumn :: Int
}
+posTChar :: String -> TChar -> String
+posTChar fileName TChar { tRow = r, tColumn = c } = fileName ++ ":" ++ show r ++ ":" ++ show c
+
_tokenize :: String -> [Token] -> [TChar] -> [TChar] -> LContext [Token]
_tokenize fileName acc current [] =
let cur = reverse current
@@ -51,7 +54,7 @@ _tokenize fileName acc current (x:xs)
tokenColumn = tColumn $ x,
tokenFileName = fileName }
in do
- when (stringLength == -1) $ throwL "unbalanced string literal"
+ when (stringLength == -1) $ throwL (posTChar fileName x) $ "unbalanced string literal"
_tokenize fileName (token : acc) [] stringDropped
| tChar x `elem` [' ', '\n', '\t', '\r'] =
let cur = reverse current