aboutsummaryrefslogtreecommitdiffstats
path: root/src/Tokenizer.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-09-27 15:57:23 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:53 +0200
commit2d9588f5b309aa6b5114d8719bfe3d0b17abbcff (patch)
tree88bb881399b1382b5a90b63a5be06d712d5e051c /src/Tokenizer.hs
parent3b1144988c49c1221b1c5f6b8f7544f1dea7cb44 (diff)
Fix position math
Diffstat (limited to 'src/Tokenizer.hs')
-rw-r--r--src/Tokenizer.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Tokenizer.hs b/src/Tokenizer.hs
index 565caa5..6a5cc5c 100644
--- a/src/Tokenizer.hs
+++ b/src/Tokenizer.hs
@@ -83,7 +83,7 @@ _tokenize fileName acc current (x:xs)
tokenize :: String -> String -> LContext [Token]
tokenize fileName src = do
- let tChars = augment 0 0 src
+ let tChars = augment 1 1 src
tokens <- _tokenize fileName [] [] tChars
return $ tokens
$> reverse
@@ -91,9 +91,9 @@ tokenize fileName src = do
where
augment row col ('\r':'\n':rest) =
- TChar '\n' row col : augment 0 (col + 1) rest
+ TChar '\n' row col : augment (row + 1) 1 rest
augment row col ('\n':rest) =
- TChar '\n' row col : augment 0 (col + 1) rest
+ TChar '\n' row col : augment (row + 1) 1 rest
augment row col (c:rest) =
- TChar c (row + 1) col : augment 0 (col + 1) rest
+ TChar c row col : augment row (col + 1) rest
augment _ _ [] = []