Commit 6399230b authored by md9ms's avatar md9ms
Browse files

New implementation of parseFilePath

Hashed out with SyntaxNinja, Lemmih and Igloo. Basically, a file path can
be either something "simple", defined by the regex [-+/_.a-zA-Z0-9]+ or
it can be a quoted Haskell string, with all the bells and whistles that
the Read instance allows. E.g., if you need commas or spaces or something
funky in your paths, use string syntax.

Oh, and you should only use '/' as directory separator, cabal should
convert it to a proper separator based on the platform it's running
on.
parent 704d3005
......@@ -272,15 +272,17 @@ splitStanzas = map merge . groupStanzas . filter validLine . lines
-- |parse a module name
moduleName = many (alphaNum <|> oneOf "_'.") <?> "moduleName"
-- |FIX: must learn to escape whitespace
parseFilePath :: GenParser Char st FilePath
parseFilePath = liftM concat (many1 (
do try word
<|> toStr digit
<|> toStr (oneOf "!@#$%^&*()?></\\|]}[{.")
))
parseFilePath = parseReadS <|> (many1 (alphaNum <|> oneOf "-+/_."))
<?> "parseFilePath"
parseReadS :: Read a => GenParser Char st a
parseReadS = do toks <- getInput
case reads toks of
[(str,toks')] -> do setInput toks'
return str
_ -> fail "Bad String"
parseDependency :: GenParser Char st Dependency
parseDependency = do name <- many1 (letter <|> digit <|> oneOf "-_")
skipMany parseWhite
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment