on master help sign in
Accepting hyphens in libs declaration in ipkg format.
78cdbb9Guillaume Yziquel
src/Idris/Package/Parser.hs+9−4
@@ -13,9 +13,10 @@ import Idris.Imports
13import Idris.Options (Opt)
13import Idris.Options (Opt)
14import Idris.Package.Common
14import Idris.Package.Common
15import Idris.Parser (moduleName)
15import Idris.Parser (moduleName)
16−import Idris.Parser.Helpers (Parser, Parsing, eol, iName, identifier, isEol,
16+import Idris.Parser.Helpers (Parser, Parsing, eol, iName, identifier,
17+ identifierWithExtraChars, isEol, lchar,
17− lchar, packageName, parseErrorDoc, reserved,
18+ packageName, parseErrorDoc, reserved, runparser,
18− runparser, someSpace, stringLiteral)
19+ someSpace, stringLiteral)
19
20
20import Control.Applicative
21import Control.Applicative
21import Control.Monad.State.Strict
22import Control.Monad.State.Strict
@@ -119,6 +120,9 @@ pOptions = do
119 Opts.Failure e -> fail $ fst $ Opts.renderFailure e ""
120 Opts.Failure e -> fail $ fst $ Opts.renderFailure e ""
120 _ -> fail "Unexpected error"
121 _ -> fail "Unexpected error"
121
122
123+libIdentifier :: Parsing m => m String
124+libIdentifier = identifierWithExtraChars "_'-."
125+
122pClause :: PParser ()
126pClause :: PParser ()
123pClause = clause "executable" filename (\st v -> st { execout = Just v })
127pClause = clause "executable" filename (\st v -> st { execout = Just v })
124 <|> clause "main" (iName []) (\st v -> st { idris_main = Just v })
128 <|> clause "main" (iName []) (\st v -> st { idris_main = Just v })
@@ -129,7 +133,7 @@ pClause = clause "executable" filename (\st v -> st { execout = Just v })
129 in st { pkgdeps = ps `union` pkgdeps st
133 in st { pkgdeps = ps `union` pkgdeps st
130 , idris_opts = pkgs ++ idris_opts st })
134 , idris_opts = pkgs ++ idris_opts st })
131 <|> clause "modules" (commaSep moduleName) (\st v -> st { modules = modules st ++ v })
135 <|> clause "modules" (commaSep moduleName) (\st v -> st { modules = modules st ++ v })
132− <|> clause "libs" (commaSep identifier) (\st v -> st { libdeps = libdeps st ++ v })
136+ <|> clause "libs" (commaSep libIdentifier) (\st v -> st { libdeps = libdeps st ++ v })
133 <|> clause "objs" (commaSep identifier) (\st v -> st { objs = objs st ++ v })
137 <|> clause "objs" (commaSep identifier) (\st v -> st { objs = objs st ++ v })
134 <|> clause "makefile" (iName []) (\st v -> st { makefile = Just (show v) })
138 <|> clause "makefile" (iName []) (\st v -> st { makefile = Just (show v) })
135 <|> clause "tests" (commaSep (iName [])) (\st v -> st { idris_tests = idris_tests st ++ v })
139 <|> clause "tests" (commaSep (iName [])) (\st v -> st { idris_tests = idris_tests st ++ v })
@@ -142,3 +146,4 @@ pClause = clause "executable" filename (\st v -> st { execout = Just v })
142 <|> clause "brief" stringLiteral (\st v -> st { pkgbrief = Just v })
146 <|> clause "brief" stringLiteral (\st v -> st { pkgbrief = Just v })
143 <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v })
147 <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v })
144 <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })
148 <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })
149+
src/Idris/Parser/Helpers.hs+10−6
@@ -36,6 +36,7 @@ module Idris.Parser.Helpers
36 , iName
36 , iName
37 , name
37 , name
38 , identifier
38 , identifier
39+ , identifierWithExtraChars
39 , packageName
40 , packageName
40 -- * Access
41 -- * Access
41 , accessibility
42 , accessibility
@@ -269,10 +270,10 @@ reservedIdentifiers = HS.fromList
269 , "rewrite", "syntax", "then", "total", "using", "where", "with"
270 , "rewrite", "syntax", "then", "total", "using", "where", "with"
270 ]
271 ]
271
272
272−identifierOrReserved :: Parsing m => m String
273+identifierOrReservedWithExtraChars :: Parsing m => String -> m String
273−identifierOrReserved = token $ P.try $ do
274+identifierOrReservedWithExtraChars extraChars = token $ P.try $ do
274 c <- P.satisfy isAlpha <|> P.oneOf "_"
275 c <- P.satisfy isAlpha <|> P.oneOf "_"
275− cs <- P.many (P.satisfy isAlphaNum <|> P.oneOf "_'.")
276+ cs <- P.many (P.satisfy isAlphaNum <|> P.oneOf extraChars)
276 return $ c : cs
277 return $ c : cs
277
278
278char :: Parsing m => Char -> m Char
279char :: Parsing m => Char -> m Char
@@ -295,13 +296,16 @@ reserved name = token $ P.try $ do
295 P.notFollowedBy (P.satisfy isAlphaNum <|> P.oneOf "_'.") <?> "end of " ++ name
296 P.notFollowedBy (P.satisfy isAlphaNum <|> P.oneOf "_'.") <?> "end of " ++ name
296
297
297-- | Parses an identifier as a token
298-- | Parses an identifier as a token
298−identifier :: Parsing m => m String
299+identifierWithExtraChars :: Parsing m => String -> m String
299−identifier = P.try $ do
300+identifierWithExtraChars extraChars = P.try $ do
300− ident <- identifierOrReserved
301+ ident <- identifierOrReservedWithExtraChars extraChars
301 when (ident `HS.member` reservedIdentifiers) $ P.unexpected . P.Label . NonEmpty.fromList $ "reserved " ++ ident
302 when (ident `HS.member` reservedIdentifiers) $ P.unexpected . P.Label . NonEmpty.fromList $ "reserved " ++ ident
302 when (ident == "_") $ P.unexpected . P.Label . NonEmpty.fromList $ "wildcard"
303 when (ident == "_") $ P.unexpected . P.Label . NonEmpty.fromList $ "wildcard"
303 return ident
304 return ident
304
305
306+identifier :: Parsing m => m String
307+identifier = identifierWithExtraChars "_'."
308+
305-- | Parses an identifier with possible namespace as a name
309-- | Parses an identifier with possible namespace as a name
306iName :: Parsing m => [String] -> m Name
310iName :: Parsing m => [String] -> m Name
307iName bad = maybeWithNS identifier bad <?> "name"
311iName bad = maybeWithNS identifier bad <?> "name"