on master help sign in
Remove unused parsing typeclasses
6cb8f74Jason Felice
src/Idris/Package/Parser.hs+4−8
@@ -11,10 +11,9 @@ module Idris.Package.Parser where
11import Idris.CmdOptions
11import Idris.CmdOptions
12import Idris.Imports
12import Idris.Imports
13import Idris.Package.Common
13import Idris.Package.Common
14−import Idris.Parser.Helpers (HasLastTokenSpan, IdrisInnerParser, MonadicParsing,
14+import Idris.Parser.Helpers (IdrisInnerParser, MonadicParsing, eol, iName,
15− eol, getLastTokenSpan, iName, identifier, isEol,
16− lchar, multiLineComment, packageName,
15+ identifier, isEol, lchar, multiLineComment,
17− parseErrorDoc, reserved, runparser,
16+ packageName, parseErrorDoc, reserved, runparser,
18 simpleWhiteSpace, singleLineComment)
17 simpleWhiteSpace, singleLineComment)
19
18
20import Control.Applicative
19import Control.Applicative
@@ -29,9 +28,6 @@ import qualified Text.Trifecta as P
29
28
30type PParser = StateT PkgDesc IdrisInnerParser
29type PParser = StateT PkgDesc IdrisInnerParser
31
30
32−instance HasLastTokenSpan PParser where
33− getLastTokenSpan = return Nothing
34−
35#if MIN_VERSION_base(4,9,0)
31#if MIN_VERSION_base(4,9,0)
36instance {-# OVERLAPPING #-} P.DeltaParsing PParser where
32instance {-# OVERLAPPING #-} P.DeltaParsing PParser where
37 line = lift P.line
33 line = lift P.line
@@ -83,7 +79,7 @@ pPkgName = (either fail pure . pkgName =<< packageName) <?> "PkgName"
83-- | Parses a filename.
79-- | Parses a filename.
84-- |
80-- |
85-- | Treated for now as an identifier or a double-quoted string.
81-- | Treated for now as an identifier or a double-quoted string.
86−filename :: (MonadicParsing m, HasLastTokenSpan m) => m String
82+filename :: (MonadicParsing m) => m String
87filename = (do
83filename = (do
88 filename <- P.token $
84 filename <- P.token $
89 -- Treat a double-quoted string as a filename to support spaces.
85 -- Treat a double-quoted string as a filename to support spaces.
src/Idris/Parser/Helpers.hs+5−7
@@ -59,7 +59,6 @@ instance {-# OVERLAPPING #-} P.DeltaParsing IdrisParser where
59 {-# INLINE rend #-}
59 {-# INLINE rend #-}
60 restOfLine = lift P.restOfLine
60 restOfLine = lift P.restOfLine
61 {-# INLINE restOfLine #-}
61 {-# INLINE restOfLine #-}
62−
63#endif
62#endif
64
63
65instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
64instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
@@ -72,8 +71,9 @@ instance {-# OVERLAPPING #-} P.TokenParsing IdrisParser where
72 whiteSpace
71 whiteSpace
73 put (s { lastTokenSpan = Just (FC fn (sl, sc) (el, ec)) })
72 put (s { lastTokenSpan = Just (FC fn (sl, sc) (el, ec)) })
74 return r
73 return r
74+
75-- | Generalized monadic parsing constraint type
75-- | Generalized monadic parsing constraint type
76−type MonadicParsing m = (P.DeltaParsing m, LookAheadParsing m, P.TokenParsing m, Monad m)
76+type MonadicParsing m = (P.DeltaParsing m, LookAheadParsing m, Monad m)
77
77
78class HasLastTokenSpan m where
78class HasLastTokenSpan m where
79 getLastTokenSpan :: m (Maybe FC)
79 getLastTokenSpan :: m (Maybe FC)
@@ -335,13 +335,11 @@ identifier = P.try $ do
335 return (ident, FC f (l, c) (l, c + length ident))
335 return (ident, FC f (l, c) (l, c + length ident))
336
336
337-- | Parses an identifier with possible namespace as a name
337-- | Parses an identifier with possible namespace as a name
338−iName :: (MonadicParsing m, HasLastTokenSpan m) => [String] -> m (Name, FC)
338+iName :: (MonadicParsing m) => [String] -> m (Name, FC)
339−iName bad = do (n, fc) <- maybeWithNS identifier False bad
339+iName bad = maybeWithNS identifier False bad <?> "name"
340− return (n, fc)
341− <?> "name"
342
340
343-- | Parses an string possibly prefixed by a namespace
341-- | Parses an string possibly prefixed by a namespace
344−maybeWithNS :: (MonadicParsing m, HasLastTokenSpan m) => m (String, FC) -> Bool -> [String] -> m (Name, FC)
342+maybeWithNS :: (MonadicParsing m) => m (String, FC) -> Bool -> [String] -> m (Name, FC)
345maybeWithNS parser ascend bad = do
343maybeWithNS parser ascend bad = do
346 fc <- getFC
344 fc <- getFC
347 i <- P.option "" (lookAhead (fst <$> identifier))
345 i <- P.option "" (lookAhead (fst <$> identifier))