language-puppet-0.1.3: Tools to parse and evaluate the Puppet DSL.

Safe HaskellSafe-Infered

Puppet.DSL.Parser

Description

This module exports the functions that will be useful to parse the DSL. They should be able to parse everything you throw at them. The Puppet language is extremely irregular, and most valid constructs are not documented in the official language guide. This parser has been created by parsing the author's own large manifests and the public Wikimedia ones.

Things that are known to not to be properly supported are :

  • "plussignement" such as foo +> bar. How to handle this is far from being obvious, as its actual behaviour is not documented.

Synopsis

Documentation

parse :: Stream s Identity t => Parsec s () a -> SourceName -> s -> Either ParseError a

parse p filePath input runs a parser p over Identity without user state. The filePath is only used in error messages and may be the empty string. Returns either a ParseError (Left) or a value of type a (Right).

  main    = case (parse numbers "" "11, 2, 43") of
             Left err  -> print err
             Right xs  -> print (sum xs)

  numbers = commaSep integer

exprparser :: ParsecT String u Identity ExpressionSource

This is a parser for Puppet Expressions.