-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple Makefile parser -- -- This package provides a few Attoparser parsers and -- convenience functions for parsing Makefiles. The datatypes used for -- describing Makefiles are located in Data.Makefile. The parsers -- and parsing functions are located in Data.Makefile.Parse. To -- parse a Makefile in the current folder, simply run -- parseMakefile. To parse a Makefile located at path, -- run parseAsMakefile path. @package makefile @version 0.1.0.2 -- | This module defines the different types used when working with a -- Makefile. -- --
-- # File: Makefile -- -- hello = world -- -- foo: bar -- baz ---- --
-- Makefile {
-- entries =
-- [ Assignment "hello " " world"
-- , Rule (Target "foo") [Dependency "bar"] [Command "baz"] ]
-- })
--
module Data.Makefile
-- | A Makefile object, a list of makefile entries
data Makefile
Makefile :: [Entry] -> Makefile
[entries] :: Makefile -> [Entry]
-- | A makefile entry, either a rule (target: dep1 dep1; commands)
-- or a variable assignment (hello = world or hello :=
-- world)
data Entry
Rule :: Target -> [Dependency] -> [Command] -> Entry
Assignment :: ByteString -> ByteString -> Entry
-- | Makefile target (foo in the example above)
newtype Target
Target :: ByteString -> Target
-- | Target dependency (bar in the example above)
newtype Dependency
Dependency :: ByteString -> Dependency
-- | Command (baz in the example above)
newtype Command
Command :: ByteString -> Command
instance GHC.Classes.Eq Data.Makefile.Makefile
instance GHC.Show.Show Data.Makefile.Makefile
instance GHC.Classes.Eq Data.Makefile.Entry
instance GHC.Show.Show Data.Makefile.Entry
instance Data.String.IsString Data.Makefile.Command
instance GHC.Classes.Eq Data.Makefile.Command
instance GHC.Show.Show Data.Makefile.Command
instance Data.String.IsString Data.Makefile.Dependency
instance GHC.Classes.Eq Data.Makefile.Dependency
instance GHC.Show.Show Data.Makefile.Dependency
instance Data.String.IsString Data.Makefile.Target
instance GHC.Classes.Eq Data.Makefile.Target
instance GHC.Show.Show Data.Makefile.Target
module Data.Makefile.Parse.Internal
-- | Parse makefile.
--
-- Tries to open and parse a file name Makefile in the current
-- directory.
parseMakefile :: IO (Either String Makefile)
-- | Parse the specified file as a makefile.
parseAsMakefile :: FilePath -> IO (Either String Makefile)
-- | Parser for a makefile
makefile :: Parser Makefile
-- | Parser for a makefile entry (either a rule or a variable assignment)
entry :: Parser Entry
-- | Parser of variable assignment
assignment :: Parser Entry
-- | Parser for an entire rule
rule :: Parser Entry
-- | Parser for a command
command :: Parser Command
-- | Parser for a (rule) target
target :: Parser Target
-- | Parser for a (rule) dependency
dependency :: Parser Dependency
-- | Parser for variable name in declaration (lazy set, var = x)
--
-- -- >>> Atto.parseOnly lazyVar "CFLAGS=-c -Wall" -- Right "CFLAGS" --lazyVar :: Parser ByteString -- | Parser for variable name in declaration (immediate set, var := -- x) -- --
-- >>> Atto.parseOnly immVar "CFLAGS:=-c -Wall" -- Right "CFLAGS" --immVar :: Parser ByteString -- | Parser for a comment (the comment starts with the hashtag) -- --
-- >>> Atto.parseOnly comment "# I AM A COMMENT" -- Right " I AM A COMMENT" --comment :: Parser ByteString -- | Consume a newline character ('\n') nextLine :: Parser () -- | Consume an empty line (potentially containing spaces and/or tabs). -- --
-- >>> Atto.parseOnly emptyLine "\t\t \t \t\n" -- Right () --emptyLine :: Parser () isSpaceChar :: Char -> Bool toLineEnd1 :: Parser ByteString module Data.Makefile.Parse -- | Parse makefile. -- -- Tries to open and parse a file name Makefile in the current -- directory. parseMakefile :: IO (Either String Makefile) -- | Parse the specified file as a makefile. parseAsMakefile :: FilePath -> IO (Either String Makefile) -- | Parser for a makefile makefile :: Parser Makefile -- | Parser for a makefile entry (either a rule or a variable assignment) entry :: Parser Entry -- | Parser of variable assignment assignment :: Parser Entry -- | Parser for an entire rule rule :: Parser Entry -- | Parser for a command command :: Parser Command -- | Parser for a (rule) target target :: Parser Target -- | Parser for a (rule) dependency dependency :: Parser Dependency -- | Parser for variable name in declaration (lazy set, var = x) -- --
-- >>> Atto.parseOnly lazyVar "CFLAGS=-c -Wall" -- Right "CFLAGS" --lazyVar :: Parser ByteString -- | Parser for variable name in declaration (immediate set, var := -- x) -- --
-- >>> Atto.parseOnly immVar "CFLAGS:=-c -Wall" -- Right "CFLAGS" --immVar :: Parser ByteString -- | Parser for a comment (the comment starts with the hashtag) -- --
-- >>> Atto.parseOnly comment "# I AM A COMMENT" -- Right " I AM A COMMENT" --comment :: Parser ByteString