Safe Haskell | Safe-Inferred |
---|
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, Text, Statement)
- data Value
- = Literal !Text
- | Interpolable ![Value]
- | PuppetRegexp !Text
- | Double !Double
- | Integer !Integer
- | VariableReference !Text
- | Empty
- | ResourceReference !Text !Expression
- | PuppetArray ![Expression]
- | PuppetHash !Parameters
- | FunctionCall !Text ![Expression]
- | PuppetBool Bool
- | Undefined
- data Virtuality
- data Statement
- = Node Text ![Statement] !SourcePos
- | VariableAssignment !Text !Expression !SourcePos
- | Include !Expression !SourcePos
- | Import !Text !SourcePos
- | Require !Text !SourcePos
- | Resource !Text !Expression ![(Expression, Expression)] !Virtuality !SourcePos
- | ResourceDefault !Text ![(Expression, Expression)] !SourcePos
- | ResourceOverride !Text !Expression ![(Expression, Expression)] !SourcePos
- | ConditionalStatement ![(Expression, [Statement])] !SourcePos
- | ClassDeclaration !Text !(Maybe Text) ![(Text, Maybe Expression)] ![Statement] !SourcePos
- | DefineDeclaration !Text ![(Text, Maybe Expression)] ![Statement] !SourcePos
- | ResourceCollection !Text !Expression ![(Expression, Expression)] !SourcePos
- | VirtualResourceCollection !Text !Expression ![(Expression, Expression)] !SourcePos
- | DependenceChain !(Text, Expression) !(Text, Expression) !SourcePos
- | MainFunctionCall !Text ![Expression] !SourcePos
- | TopContainer ![(Text, 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 !Text !Text
- | BTrue
- | BFalse
- capitalizeResType :: Text -> Text
- capitalize' :: Text -> Text
Documentation
data Parameters Source
Parameters ![(Expression, Expression)] |
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, Text, 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 !Text | String literal. |
Interpolable ![Value] | An interpolable string, represented as a |
PuppetRegexp !Text | A Puppet Regexp. This is very hackish as it alters the behaviour of some functions (such as conditional values). |
Double !Double | |
Integer !Integer | |
VariableReference !Text | Reference to a variable. The string contains what is acutally typed in the manifest. |
Empty | |
ResourceReference !Text !Expression | |
PuppetArray ![Expression] | |
PuppetHash !Parameters | |
FunctionCall !Text ![Expression] | |
PuppetBool Bool | |
Undefined | This is special and quite hackish too. |
The actual puppet statements
Node Text ![Statement] !SourcePos | This holds the node name and list of statements. | This holds the variable name and the expression that it represents. |
VariableAssignment !Text !Expression !SourcePos | |
Include !Expression !SourcePos | |
Import !Text !SourcePos | |
Require !Text !SourcePos | |
Resource !Text !Expression ![(Expression, Expression)] !Virtuality !SourcePos | This holds the resource type, name, parameter list and virtuality. |
ResourceDefault !Text ![(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 !Text !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 !Text !(Maybe Text) ![(Text, 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 !Text ![(Text, Maybe Expression)] ![Statement] !SourcePos | The define declaration is like the |
ResourceCollection !Text !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 !Text !Expression ![(Expression, Expression)] !SourcePos | Same as |
DependenceChain !(Text, Expression) !(Text, Expression) !SourcePos | |
MainFunctionCall !Text ![Expression] !SourcePos | |
TopContainer ![(Text, 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.
capitalizeResType :: Text -> TextSource
capitalize' :: Text -> TextSource