Documentation ¶
Index ¶
- Constants
- func Pretty(pretty bool) func(*Grammar) error
- func Size(size int) func(*Grammar) error
- type ArrayExpr
- type Compiler
- type FunctionExpr
- type Grammar
- func (t *Grammar) AST() *node32
- func (t *Grammar) Add(rule pegRule, begin, end, index uint32)
- func (p *Grammar) Init(options ...func(*Grammar) error) error
- func (g *Grammar) LoadUAST()
- func (p *Grammar) Parse(rule ...int) error
- func (t *Grammar) PrettyPrintSyntaxTree(buffer string)
- func (t *Grammar) Print()
- func (p *Grammar) PrintSyntaxTree()
- func (p *Grammar) Reset()
- func (p *Grammar) SprintSyntaxTree() string
- func (t *Grammar) Tokens() []token32
- func (t *Grammar) Trim(length uint32)
- func (p *Grammar) WriteSyntaxTree(w io.Writer)
- type NumberExpr
- type ObjectExpr
- type PairExpr
- type TaskExpr
- type Type
- type UAST
- type ValueExpr
Constants ¶
const ( UnknownType = iota ArrayType BoolType FunctionType NumberType ObjectType StringType )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
func NewCompiler ¶ added in v0.2.0
func (*Compiler) Compile ¶
Compile returns a `*dst.File` which can be formatted into Go using `go/format` or `go/printer`. The Load() method must be called before this.
func (*Compiler) Load ¶
Load the compiler's playbook file and parse it into the Unobin AST or return an error.
func (*Compiler) PackageResources ¶ added in v0.3.0
PackageResources bundles files from a playbook's resources directory into a file called resources.go using github.com/go-bindata/go-bindata.
func (*Compiler) Validate ¶ added in v0.2.0
Validate checks for errors not caught by the parser. For example, the parser only knows that attributes should be pairs of string -> value, but does not enforce the underlying type required for the value. This function ensures that:
- Required attributes are present: name, description, imports, and input-schema, and that they are the correct type.
- Imports are defined as an object with string keys and string values, and that the import paths are correctly formatted. TODO: check that module exists on the given path.
- The input schema is a valid JSON schema.
- Tasks refer only to modules that are defined in imports.
type FunctionExpr ¶ added in v0.2.0
func (*FunctionExpr) ToGoAST ¶ added in v0.2.0
func (f *FunctionExpr) ToGoAST() dst.Expr
func (*FunctionExpr) ToGoValue ¶ added in v0.2.0
func (f *FunctionExpr) ToGoValue() []interface{}
type Grammar ¶ added in v0.2.0
func (*Grammar) PrettyPrintSyntaxTree ¶ added in v0.2.0
func (t *Grammar) PrettyPrintSyntaxTree(buffer string)
func (*Grammar) PrintSyntaxTree ¶ added in v0.2.0
func (p *Grammar) PrintSyntaxTree()
func (*Grammar) SprintSyntaxTree ¶ added in v0.2.0
func (*Grammar) WriteSyntaxTree ¶ added in v0.2.0
type NumberExpr ¶ added in v0.2.0
func (*NumberExpr) ToGoAST ¶ added in v0.2.0
func (n *NumberExpr) ToGoAST() dst.Expr
func (*NumberExpr) ToGoValue ¶ added in v0.2.0
func (n *NumberExpr) ToGoValue() interface{}
type ObjectExpr ¶ added in v0.2.0
func (ObjectExpr) ToGoAST ¶ added in v0.2.0
func (o ObjectExpr) ToGoAST() dst.Expr
func (ObjectExpr) ToGoValue ¶ added in v0.2.0
func (o ObjectExpr) ToGoValue() map[string]interface{}
type TaskExpr ¶ added in v0.2.0
type TaskExpr struct { Description string Module string When *FunctionExpr Args ObjectExpr Body []*TaskExpr Rescue []*TaskExpr Always []*TaskExpr }
type UAST ¶ added in v0.2.0
type UAST struct { Attributes ObjectExpr Tasks []*TaskExpr }
UAST is the Unobin AST, so named to avoid confusion with the Go AST, which is generated during compilation.
type ValueExpr ¶ added in v0.2.0
type ValueExpr struct { Array ArrayExpr Bool *bool Function *FunctionExpr Number *NumberExpr Object ObjectExpr String *string }