Safe Haskell | Safe-Infered |
---|
Types used when parsing the Puppet DSL. A good knowledge of the Puppet language in required to understand them.
- data Parameters = Parameters [(Expression, Expression)]
- data TopLevelType
- = TopNode
- | TopDefine
- | TopClass
- | TopSpurious
- convertTopLevel :: Statement -> Either Statement (TopLevelType, String, Statement)
- data Value
- data Virtuality
- data Statement
- = Node String ![Statement] SourcePos
- | VariableAssignment String Expression SourcePos
- | Include String SourcePos
- | Import String SourcePos
- | Require String SourcePos
- | Resource String Expression ![(Expression, Expression)] Virtuality SourcePos
- | ResourceDefault String ![(Expression, Expression)] SourcePos
- | ResourceOverride String Expression ![(Expression, Expression)] SourcePos
- | ConditionalStatement ![(Expression, [Statement])] SourcePos
- | ClassDeclaration String (Maybe String) ![(String, Maybe Expression)] ![Statement] SourcePos
- | DefineDeclaration String ![(String, Maybe Expression)] ![Statement] SourcePos
- | ResourceCollection String !Expression ![(Expression, Expression)] SourcePos
- | VirtualResourceCollection String !Expression ![(Expression, Expression)] SourcePos
- | DependenceChain !(String, Expression) !(String, Expression) SourcePos
- | MainFunctionCall String ![Expression] SourcePos
- | TopContainer ![(String, Statement)] !Statement
- data Expression
- = LookupOperation !Expression !Expression
- | IsElementOperation !Expression !Expression
- | PlusOperation !Expression !Expression
- | MinusOperation !Expression !Expression
- | DivOperation !Expression !Expression
- | MultiplyOperation !Expression !Expression
- | ShiftLeftOperation !Expression !Expression
- | ShiftRightOperation !Expression !Expression
- | AndOperation !Expression !Expression
- | OrOperation !Expression !Expression
- | EqualOperation !Expression !Expression
- | DifferentOperation !Expression !Expression
- | AboveOperation !Expression !Expression
- | AboveEqualOperation !Expression !Expression
- | UnderEqualOperation !Expression !Expression
- | UnderOperation !Expression !Expression
- | RegexpOperation !Expression !Expression
- | NotRegexpOperation !Expression !Expression
- | NotOperation !Expression
- | NegOperation !Expression
- | ConditionalValue !Expression !Expression
- | Value Value
- | ResolvedResourceReference String String
- | BTrue
- | BFalse
- | Error String
Documentation
data Parameters Source
data TopLevelType Source
This type is used to differenciate the distinct top level types that are exposed by the DSL.
TopNode | This is for node entries. |
TopDefine | This is for defines. |
TopClass | This is for classes. |
TopSpurious | This one is special. It represents top level statements that are not part of a node, define or class. It is defined as spurious because it is not what you are supposed to be. Also the caching system doesn't like them too much right now. |
convertTopLevel :: Statement -> Either Statement (TopLevelType, String, Statement)Source
This function returns the TopLevelType
of a statement if it is either a
node, class or define. It returns Nothing otherwise.
The Value
type represents a Puppet value. It is the terminal in a puppet
Expression
Literal String | String literal. |
Interpolable [Value] | An interpolable string, represented as a |
PuppetRegexp String | A Puppet Regexp. This is very hackish as it alters the behaviour of some functions (such as conditional values). |
Double Double | |
Integer Integer | |
VariableReference String | Reference to a variable. The string contains what is acutally typed in the manifest. |
Empty | |
ResourceReference String Expression | |
PuppetArray [Expression] | |
PuppetHash Parameters | |
FunctionCall String [Expression] | |
Undefined | This is special and quite hackish too. |
The actual puppet statements
Node String ![Statement] SourcePos | This holds the node name and list of statements. | This holds the variable name and the expression that it represents. |
VariableAssignment String Expression SourcePos | |
Include String SourcePos | |
Import String SourcePos | |
Require String SourcePos | |
Resource String Expression ![(Expression, Expression)] Virtuality SourcePos | This holds the resource type, name, parameter list and virtuality. |
ResourceDefault String ![(Expression, Expression)] SourcePos | This is a resource default declaration, such as File {owner => 'root'; }. It holds the resource type and the list of default parameters. |
ResourceOverride String Expression ![(Expression, Expression)] SourcePos | This works like |
ConditionalStatement ![(Expression, [Statement])] SourcePos | The pairs hold on the left a value that is resolved as a boolean, and on the right the list of statements that correspond to this. This will be generated by if/then/else statement, but also by the case statement. |
ClassDeclaration String (Maybe String) ![(String, Maybe Expression)] ![Statement] SourcePos | The class declaration holds the class name, the optional name of the class it inherits from, a list of parameters with optional default values, and the list of statements it contains. |
DefineDeclaration String ![(String, Maybe Expression)] ![Statement] SourcePos | The define declaration is like the |
ResourceCollection String !Expression ![(Expression, Expression)] SourcePos | This is the resource collection syntax (<<| |>>). It holds the conditional expression, and an eventual list of overrides. This is important as the same token conveys two distinct Puppet concepts : resource collection and resource overrides. |
VirtualResourceCollection String !Expression ![(Expression, Expression)] SourcePos | Same as |
DependenceChain !(String, Expression) !(String, Expression) SourcePos | |
MainFunctionCall String ![Expression] SourcePos | |
TopContainer ![(String, Statement)] !Statement | This is a magic statement that is used to hold the spurious top level statements that comes in the same file as the correct top level statement that is stored in the second field. The first field contains pairs of filenames and statements. This is designed so that the interpreter can know whether it has already been evaluated. |
data Expression Source
Expressions will be described with a and b being the first and second field of the constructor.