@@ -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)
20import Control.Applicative
21import Control.Applicative
21import Control.Monad.State.Strict
22import Control.Monad.State.Strict
@@ -26,14 +27,13 @@ import System.Exit
26import System.FilePath (isValid, takeExtension, takeFileName)
27import System.FilePath (isValid, takeExtension, takeFileName)
27import Text.Megaparsec ((<?>))
28import Text.Megaparsec ((<?>))
28import qualified Text.Megaparsec as P
29import qualified Text.Megaparsec as P
29−import qualified Text.Megaparsec.Char as P
30import qualified Text.PrettyPrint.ANSI.Leijen as PP
30import qualified Text.PrettyPrint.ANSI.Leijen as PP
32type PParser = Parser PkgDesc
32type PParser = Parser PkgDesc
34parseDesc :: FilePath -> IO PkgDesc
34parseDesc :: FilePath -> IO PkgDesc
35parseDesc fp = do
35parseDesc fp = do
36− when (not $ takeExtension fp == ".ipkg") $ do
36+ unless (takeExtension fp == ".ipkg") $ do
37 putStrLn $ unwords ["The presented iPKG file does not have a '.ipkg' extension:", show fp]
37 putStrLn $ unwords ["The presented iPKG file does not have a '.ipkg' extension:", show fp]
38 exitWith (ExitFailure 1)
38 exitWith (ExitFailure 1)
39 res <- doesFileExist fp
39 res <- doesFileExist fp
@@ -119,17 +119,20 @@ pOptions = do
119 Opts.Failure e -> fail $ fst $ Opts.renderFailure e ""
119 Opts.Failure e -> fail $ fst $ Opts.renderFailure e ""
120 _ -> fail "Unexpected error"
120 _ -> fail "Unexpected error"
122+libIdentifier :: Parsing m => m String
123+libIdentifier = identifierWithExtraChars "_'-."
122pClause :: PParser ()
125pClause :: PParser ()
123pClause = clause "executable" filename (\st v -> st { execout = Just v })
126pClause = clause "executable" filename (\st v -> st { execout = Just v })
124 <|> clause "main" (iName []) (\st v -> st { idris_main = Just v })
127 <|> 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 })
126 <|> clause "opts" pOptions (\st v -> st { idris_opts = v ++ idris_opts st })
129 <|> clause "opts" pOptions (\st v -> st { idris_opts = v ++ idris_opts st })
127 <|> clause "pkgs" (commaSep (pPkgName <* someSpace)) (\st ps ->
130 <|> clause "pkgs" (commaSep (pPkgName <* someSpace)) (\st ps ->
128 let pkgs = pureArgParser $ concatMap (\x -> ["-p", show x]) ps
131 let pkgs = pureArgParser $ concatMap (\x -> ["-p", show x]) ps
129 in st { pkgdeps = ps `union` pkgdeps st
132 in st { pkgdeps = ps `union` pkgdeps st
130 , idris_opts = pkgs ++ idris_opts st })
133 , idris_opts = pkgs ++ idris_opts st })
131 <|> clause "modules" (commaSep moduleName) (\st v -> st { modules = modules st ++ v })
134 <|> 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 })
133 <|> clause "objs" (commaSep identifier) (\st v -> st { objs = objs st ++ v })
136 <|> clause "objs" (commaSep identifier) (\st v -> st { objs = objs st ++ v })
134 <|> clause "makefile" (iName []) (\st v -> st { makefile = Just (show v) })
137 <|> clause "makefile" (iName []) (\st v -> st { makefile = Just (show v) })
135 <|> clause "tests" (commaSep (iName [])) (\st v -> st { idris_tests = idris_tests st ++ v })
138 <|> 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 })
142 <|> clause "brief" stringLiteral (\st v -> st { pkgbrief = Just v })
145 <|> clause "brief" stringLiteral (\st v -> st { pkgbrief = Just v })
143 <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v })
146 <|> clause "author" textUntilEol (\st v -> st { pkgauthor = Just v })
144 <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })
147 <|> clause "maintainer" textUntilEol (\st v -> st { pkgmaintainer = Just v })