Gave Parsec errors proper positioning info

This commit is contained in:
Vidar Holen 2012-11-04 18:58:34 -08:00
commit 22ae83e372
3 changed files with 25 additions and 5 deletions

View file

@ -32,13 +32,17 @@ doFile path colorFunc = do
doInput filename contents colorFunc = do
let fileLines = lines contents
let lineCount = length fileLines
let comments = shpellCheck contents
let groups = groupWith shpellLine comments
if not $ null comments then do
mapM_ (\x -> do
let line = fileLines !! (shpellLine (head x) - 1)
let lineNum = shpellLine (head x)
let line = if lineNum < 1 || lineNum >= lineCount
then ""
else fileLines !! (lineNum - 1)
putStrLn ""
putStrLn $ colorFunc "message" ("In " ++ filename ++" line " ++ (show $ shpellLine (head x)) ++ ":")
putStrLn $ colorFunc "message" ("In " ++ filename ++" line " ++ (show $ lineNum) ++ ":")
putStrLn (colorFunc "source" line)
mapM (\c -> putStrLn (colorFunc (shpellSeverity c) $ cuteIndent c)) x
putStrLn ""