git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Include file path in syntax errors
commit6019f26a5529064dbc5165a7e7702bb3e3587da1 authorGary Burgess <garyb@users.noreply.github.com> dateWed 5 Feb 2014, 20:05 (13 years ago) parent4cbe6e3
4 files changed+7−7
psc/Main.hs+2−2 psci/Main.hs+2−2 src/Language/PureScript/Parser/Common.hs+2−2 tests/Main.hs+1−1
psc/Main.hs+2−2
@@ -28,10 +28,10 @@ preludeFilename :: IO FilePath
2828preludeFilename = Paths.getDataFileName "libraries/prelude/prelude.purs"
2929
3030readInput :: Maybe [FilePath] -> IO (Either ParseError [P.Module])
31−readInput Nothing = getContents >>= return . P.runIndentParser P.parseModules
31+readInput Nothing = getContents >>= return . P.runIndentParser "" P.parseModules
3232readInput (Just input) = fmap (fmap concat . sequence) $ forM input $ \inputFile -> do
3333 text <- U.readFile inputFile
34− return $ P.runIndentParser P.parseModules text
34+ return $ P.runIndentParser inputFile P.parseModules text
3535
3636compile :: P.Options -> Maybe [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
3737compile opts input output externs = do
psci/Main.hs+2−2
@@ -106,7 +106,7 @@ loadModule :: FilePath -> IO (Either String [P.Module])
106106loadModule moduleFile = do
107107 print moduleFile
108108 moduleText <- U.readFile moduleFile
109− return . either (Left . show) Right $ P.runIndentParser P.parseModules moduleText
109+ return . either (Left . show) Right $ P.runIndentParser "" P.parseModules moduleText
110110
111111main :: IO ()
112112main = do
@@ -128,7 +128,7 @@ main = do
128128 case cmd of
129129 Empty -> go imports loadedModules
130130 Expression ls -> do
131− case P.runIndentParser (P.whiteSpace *> P.parseValue <* Parsec.eof) (unlines ls) of
131+ case P.runIndentParser "" (P.whiteSpace *> P.parseValue <* Parsec.eof) (unlines ls) of
132132 Left err -> outputStrLn (show err)
133133 Right decl -> handleDeclaration loadedModules imports decl
134134 go imports loadedModules
src/Language/PureScript/Parser/Common.hs+2−2
@@ -399,5 +399,5 @@ same = checkIndentation (==) P.<?> "no indentation"
399399-- |
400400-- Run a parser which supports indentation
401401--
402−runIndentParser :: P.Parsec String ParseState a -> String -> Either P.ParseError a
403−runIndentParser p = P.runParser p (ParseState 0) ""
402+runIndentParser :: FilePath -> P.Parsec String ParseState a -> String -> Either P.ParseError a
403+runIndentParser filePath p = P.runParser p (ParseState 0) filePath
tests/Main.hs+1−1
@@ -39,7 +39,7 @@ preludeFilename = Paths.getDataFileName "libraries/prelude/prelude.purs"
3939readInput :: [FilePath] -> IO (Either ParseError [P.Module])
4040readInput inputFiles = fmap (fmap concat . sequence) $ forM inputFiles $ \inputFile -> do
4141 text <- U.readFile inputFile
42− return $ P.runIndentParser P.parseModules text
42+ return $ P.runIndentParser inputFile P.parseModules text
4343
4444compile :: P.Options -> [FilePath] -> IO (Either String String)
4545compile opts inputFiles = do