on master help sign in
Implement our own someSpace
commitc0ff21adab6b05ec2607f5e449287d30b8bead67 authorJason Felice <jason.m.felice@gmail.com> dateSun 29 Oct 2017, 19:56 (9 years ago) parent6cb8f74
2 files changed+13−11
src/Idris/Package/Parser.hs+7−8 src/Idris/Parser/Helpers.hs+6−3
src/Idris/Package/Parser.hs+7−8
@@ -12,9 +12,8 @@ import Idris.CmdOptions
1212import Idris.Imports
1313import Idris.Package.Common
1414import Idris.Parser.Helpers (IdrisInnerParser, MonadicParsing, eol, iName,
15− identifier, isEol, lchar, multiLineComment,
16− packageName, parseErrorDoc, reserved, runparser,
17− simpleWhiteSpace, singleLineComment)
15+ identifier, isEol, lchar, packageName,
16+ parseErrorDoc, reserved, runparser, someSpace')
1817
1918import Control.Applicative
2019import Control.Monad.State.Strict
@@ -43,7 +42,7 @@ instance {-# OVERLAPPING #-} P.DeltaParsing PParser where
4342#endif
4443
4544instance {-# OVERLAPPING #-} P.TokenParsing PParser where
46− someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
45+ someSpace = someSpace'
4746
4847
4948parseDesc :: FilePath -> IO PkgDesc
@@ -66,7 +65,7 @@ pPkg :: PParser PkgDesc
6665pPkg = do
6766 reserved "package"
6867 p <- pPkgName
69− P.someSpace
68+ someSpace'
7069 modify $ \st -> st { pkgname = p }
7170 some pClause
7271 st <- get
@@ -119,10 +118,10 @@ filename = (do
119118 "filename must contain no directory component"
120119
121120textUntilEol :: MonadicParsing m => m String
122−textUntilEol = many (P.satisfy (not . isEol)) <* eol <* P.someSpace
121+textUntilEol = many (P.satisfy (not . isEol)) <* eol <* someSpace'
123122
124123clause :: String -> PParser a -> (PkgDesc -> a -> PkgDesc) -> PParser ()
125−clause name p f = do value <- reserved name *> lchar '=' *> p <* P.someSpace
124+clause name p f = do value <- reserved name *> lchar '=' *> p <* someSpace'
126125 modify $ \st -> f st value
127126
128127commaSep :: MonadicParsing m => m a -> m [a]
@@ -133,7 +132,7 @@ pClause = clause "executable" filename (\st v -> st { execout = Just v })
133132 <|> clause "main" (fst <$> iName []) (\st v -> st { idris_main = Just v })
134133 <|> clause "sourcedir" (fst <$> identifier) (\st v -> st { sourcedir = v })
135134 <|> clause "opts" (pureArgParser . words <$> P.stringLiteral) (\st v -> st { idris_opts = v ++ idris_opts st })
136− <|> clause "pkgs" (commaSep (pPkgName <* P.someSpace)) (\st ps ->
135+ <|> clause "pkgs" (commaSep (pPkgName <* someSpace')) (\st ps ->
137136 let pkgs = pureArgParser $ concatMap (\x -> ["-p", show x]) ps
138137 in st { pkgdeps = ps `union` pkgdeps st
139138 , idris_opts = pkgs ++ idris_opts st })
src/Idris/Parser/Helpers.hs+6−3
@@ -61,8 +61,11 @@ instance {-# OVERLAPPING #-} P.DeltaParsing IdrisParser where
6161 {-# INLINE restOfLine #-}
6262#endif
6363
64+someSpace' :: MonadicParsing m => m ()
65+someSpace' = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
66+
6467instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
65− someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
68+ someSpace = someSpace'
6669 token p = do s <- get
6770 (FC fn (sl, sc) _) <- getFC --TODO: Update after fixing getFC
6871 -- See Issue #1594
@@ -206,7 +209,7 @@ docComment = do dc <- pushIndent *> docCommentLine
206209 contents <- P.option "" (do first <- P.satisfy (\c -> not (isEol c || c == '@'))
207210 res <- many (P.satisfy (not . isEol))
208211 return $ first:res)
209− eol ; P.someSpace
212+ eol ; someSpace'
210213 return contents)
211214 <?> ""
212215
@@ -217,7 +220,7 @@ docComment = do dc <- pushIndent *> docCommentLine
217220 n <- fst <$> name
218221 many (P.satisfy isSpace)
219222 docs <- many (P.satisfy (not . isEol))
220− eol ; P.someSpace
223+ eol ; someSpace'
221224 return (n, docs)
222225
223226-- | Parses some white space