Safe Haskell | None |
---|---|
Language | Haskell2010 |
- parseMakefile :: IO (Either String Makefile)
- parseAsMakefile :: FilePath -> IO (Either String Makefile)
- parseMakefileContents :: Text -> Either String Makefile
- makefile :: Parser Makefile
- entry :: Parser Entry
- assignment :: Parser Entry
- takeWhileM :: (Char -> Parser Bool) -> Parser Text
- variableName :: Parser Text
- assignmentType :: Parser AssignmentType
- rule :: Parser Entry
- command :: Parser Command
- target :: Parser Target
- dependency :: Parser Dependency
- lazyVar :: Parser Text
- immVar :: Parser Text
- comment :: Parser Text
- nextLine :: Parser ()
- emptyLine :: Parser ()
- toLineEnd :: Parser Text
- toEscapedLineEnd :: Parser Text
- stripped :: Parser Text -> Parser Text
Documentation
>>>
:set -XOverloadedStrings
parseMakefile :: IO (Either String Makefile) Source #
Parse makefile.
Tries to open and parse a file name Makefile
in the current directory.
parseAsMakefile :: FilePath -> IO (Either String Makefile) Source #
Parse the specified file as a makefile.
assignment :: Parser Entry Source #
Parser of variable assignment (see Assignment
). Note that leading and
trailing whitespaces will be stripped both from the variable name and
assigned value.
Note that this tries to follow GNU make's (crazy) behavior when it comes to variable names and assignment operators.
>>>
Atto.parseOnly assignment "foo = bar "
Right (Assignment RecursiveAssign "foo" "bar")
>>>
Atto.parseOnly assignment "foo := bar "
Right (Assignment SimpleAssign "foo" "bar")
>>>
Atto.parseOnly assignment "foo ::= bar "
Right (Assignment SimplePosixAssign "foo" "bar")
>>>
Atto.parseOnly assignment "foo?= bar "
Right (Assignment ConditionalAssign "foo" "bar")
>>>
Atto.parseOnly assignment "foo??= bar "
Right (Assignment ConditionalAssign "foo?" "bar")
>>>
Atto.parseOnly assignment "foo!?!= bar "
Right (Assignment ShellAssign "foo!?" "bar")
dependency :: Parser Dependency Source #
Parser for a (rule) dependency
lazyVar :: Parser Text Source #
Parser for variable name in declaration (lazy set, var = x
)
>>>
Atto.parseOnly lazyVar "CFLAGS=-c -Wall"
Right "CFLAGS"
immVar :: Parser Text Source #
Parser for variable name in declaration (immediate set, var := x
)
>>>
Atto.parseOnly immVar "CFLAGS:=-c -Wall"
Right "CFLAGS"
comment :: Parser Text Source #
Parser for a comment (the comment starts with the hashtag)
>>>
Atto.parseOnly comment "# I AM A COMMENT"
Right " I AM A COMMENT"
emptyLine :: Parser () Source #
Consume an empty line (potentially containing spaces and/or tabs).
>>>
Atto.parseOnly emptyLine "\t\t \t \t\n"
Right ()
toEscapedLineEnd :: Parser Text Source #
Get the contents until the end of the (potentially multi) line. Multiple
lines are separated by a \
char and individual lines will be stripped and
spaces will be interspersed.
The final n
character is consumed.
>>>
Atto.parseOnly toEscapedLineEnd "foo bar \\\n baz"
Right "foo bar baz"
>>>
Atto.parseOnly toEscapedLineEnd "foo \t\\\n bar \\\n baz \\\n \t"
Right "foo bar baz"