@@ -13,9 +13,10 @@ import Idris.Imports
1313import Idris.Options (Opt)
1414import Idris.Package.Common
1515import Idris.Parser (moduleName)
16−import Idris.Parser.Helpers (Parser, Parsing, eol, iName, identifier, isEol,
17− lchar, packageName, parseErrorDoc, reserved,
18− runparser, someSpace, stringLiteral)
16+import Idris.Parser.Helpers (Parser, Parsing, eol, iName, identifier,
17+ identifierWithExtraChars, isEol, lchar,
18+ packageName, parseErrorDoc, reserved, runparser,
19+ someSpace, stringLiteral)
1920
2021import Control.Applicative
2122import Control.Monad.State.Strict
@@ -26,14 +27,13 @@ import System.Exit
2627import System.FilePath (isValid, takeExtension, takeFileName)
2728import Text.Megaparsec ((<?>))
2829import qualified Text.Megaparsec as P
29−import qualified Text.Megaparsec.Char as P
3030import qualified Text.PrettyPrint.ANSI.Leijen as PP
3131
3232type PParser = Parser PkgDesc
3333
3434parseDesc :: FilePath -> IO PkgDesc
3535parseDesc fp = do
36− when (not $ takeExtension fp == ".ipkg") $ do
36+ unless (takeExtension fp == ".ipkg") $ do
3737 putStrLn $ unwords ["The presented iPKG file does not have a '.ipkg' extension:", show fp]
3838 exitWith (ExitFailure 1)
3939 res <- doesFileExist fp
@@ -119,17 +119,20 @@ pOptions = do
119119 Opts.Failure e -> fail $ fst $ Opts.renderFailure e ""
120120 _ -> fail "Unexpected error"
121121
122+libIdentifier :: Parsing m => m String
123+libIdentifier = identifierWithExtraChars "_'-."
124+
122125pClause :: PParser ()
123126pClause = clause "executable" filename (\st v -> st { execout = Just v })
124127 <|> clause "main" (iName []) (\st v -> st { idris_main = Just v })
125− <|> clause "sourcedir" identifier (\st v -> st { sourcedir = v })
128+ <|> clause "sourcedir" (identifier <|> stringLiteral) (\st v -> st { sourcedir = v })
126129 <|> clause "opts" pOptions (\st v -> st { idris_opts = v ++ idris_opts st })
127130 <|> clause "pkgs" (commaSep (pPkgName <* someSpace)) (\st ps ->
128131 let pkgs = pureArgParser $ concatMap (\x -> ["-p", show x]) ps
129132 in st { pkgdeps = ps `union` pkgdeps st
130133 , idris_opts = pkgs ++ idris_opts st })
131134 <|> clause "modules" (commaSep moduleName) (\st v -> st { modules = modules st ++ v })
132− <|> clause "libs" (commaSep identifier) (\st v -> st { libdeps = libdeps st ++ v })
135+ <|> clause "libs" (commaSep libIdentifier) (\st v -> st { libdeps = libdeps st ++ v })
133136 <|> clause "objs" (commaSep identifier) (\st v -> st { objs = objs st ++ v })
134137 <|> clause "makefile" (iName []) (\st v -> st { makefile = Just (show v) })
135138 <|> clause "tests" (commaSep (iName [])) (\st v -> st { idris_tests = idris_tests st ++ v })
@@ -142,3 +145,4 @@ pClause = clause "executable" filename (\st v -> st { execout = Just v })
142145 <|> clause "brief" stringLiteral (\st v -> st { pkgbrief = Just v })
143146 <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v })
144147 <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })
148+