From e28410ceeb875c8a03a5d359021f6026185d8424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Przemys=C5=82aw=20Pluta?= Date: Thu, 4 Nov 2021 11:45:54 +0100 Subject: [PATCH] Enable parser error handler displays tokens instead of line numbers --- app/Assembler.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Assembler.hs b/app/Assembler.hs index 7b31b93..99cef49 100644 --- a/app/Assembler.hs +++ b/app/Assembler.hs @@ -288,8 +288,8 @@ parse :: [Token] -> Either String AST parse tokens = do let lines = U.explode (==NewLine) tokens let results = map (assertConsumed parseLine) lines - let errors = filter ((==Nothing) . snd) (zipWith (,) [1..] $ results) - let errorMsg = "Parse error in line(s): " ++ (List.intercalate ", " $ map (show. fst) errors) + let errors = filter ((==Nothing) . snd) $ zipWith (,) lines $ results + let errorMsg = "Parse error(s):\n" ++ (List.intercalate "\n" $ map (show . fst) errors) case sequenceA results of (Just r) -> return $ ProgramNode $ map (\(ParseResult ast _) -> ast) r Nothing -> Left errorMsg