aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parent3b1144988c49c1221b1c5f6b8f7544f1dea7cb44 (diff)
Fix position math
Diffstat (limited to 'src')
-rw-r--r--src/Evaluator.hs2
-rw-r--r--src/Parser.hs2
-rw-r--r--src/Tokenizer.hs8
3 files changed, 6 insertions, 6 deletions
diff --git a/src/Evaluator.hs b/src/Evaluator.hs
index 4f40706..2797fcd 100644
--- a/src/Evaluator.hs
+++ b/src/Evaluator.hs
@@ -106,7 +106,7 @@ evaluateFunctionDef env asts = do
params <- mapM assertIsASTSymbol params'
let letExprs = take (length exprs - 1) exprs
- let nonLetExprM = L.find isLetAST letExprs
+ let nonLetExprM = L.find (not . isLetAST) letExprs
case nonLetExprM of
Just nonLetExpr -> throwL (astPos nonLetExpr)
$ "non-let expression in function definition before body: " ++ show nonLetExpr
diff --git a/src/Parser.hs b/src/Parser.hs
index e46d80c..5089cb4 100644
--- a/src/Parser.hs
+++ b/src/Parser.hs
@@ -40,7 +40,7 @@ parseToken (Token token tr tc tf)
isString t = "\"" `L.isPrefixOf` t
removeQuotes s = drop 1 s $> take (length s - 2)
isBoolean t = t `elem` ["true", "false"]
- asBoolean t = if t == "true" then True else False
+ asBoolean t = t == "true"
ast astNode = AST { astNode = astNode, astRow = tr, astColumn = tc, astFileName = tf }
_parse :: [AST] -> [Token] -> LContext [AST]
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 _ _ [] = []