PParser.hs: Add |filename| parser

As it stands, it reads in either a (possibly namespaced) identifier,
which was the old behavior, or a double-quoted string, which is the new
behavior.

This could be improved by actually testing that it's returning a filename,
but I'm clumsy with the parser abstraction, and it wasn't clear to me
from the Trifecta docs I looked through how to pass it through
System.FilePath.takeFileName and then enforce that it was a non-empty string.
This commit is contained in:
Jeremy W. Sherman 2015-10-11 23:51:49 -04:00
parent 2cda43e36c
commit c772bf53c4

View File

@ -62,6 +62,14 @@ pPkg = do
eof
return st
-- | Parses a filename.
-- |
-- | Treated for now as an identifier or a double-quoted string.
filename :: (MonadicParsing m, HasLastTokenSpan m) => m String
filename = try $ (token $ stringLiteral <|> (fst <$> identifier)) <?> "filename"
pClause :: PParser ()
pClause = do reserved "executable"; lchar '=';
exec <- fst <$> iName []