Documentation ¶
Index ¶
- func EvalForms(name string, scope Scope, forms []*Form) interface{}
- type Form
- type FormFn
- type NTForms
- type Scope
- func (scope Scope) Clone() Scope
- func (scope Scope) Del(name string, value interface{}, g bool) Scope
- func (scope Scope) Get(name string) (value interface{}, g, ok bool)
- func (scope Scope) GetBagdir() string
- func (scope Scope) GetInt64(name string) (i int64, g, ok bool)
- func (scope Scope) GetNonTerminal(name string) (nt []*Form, ok bool)
- func (scope Scope) GetProdfile() string
- func (scope Scope) GetRandom() *rand.Rand
- func (scope Scope) GetString(name string) (s string, g, ok bool)
- func (scope Scope) GetWeight(name string) (value float64, ok bool)
- func (scope Scope) RebuildContext() Scope
- func (scope Scope) Set(name string, value interface{}, g bool) Scope
- func (scope Scope) SetBagdir(bagdir string) Scope
- func (scope Scope) SetNonTerminal(name string, nt []*Form) Scope
- func (scope Scope) SetProdfile(prodfile string) Scope
- func (scope Scope) SetRandom(rnd *rand.Rand) Scope
- func (scope Scope) SetWeight(name string, value float64) Scope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Form ¶
Form defines the structure of any form.
func (*Form) SetDefaultWeight ¶
SetDefaultWeight will set a default weightage for this form, if a weightage is not defined already. Typically this form will be rule-form.
type FormFn ¶
type FormFn func(scope Scope, args ...interface{}) interface{}
FormFn function signature for all forms.
type Scope ¶
type Scope map[string]interface{}
Scope of production grammar, a scope can be evaluated to generate permutations and combinations. For the first time after compiling the production grammar into a scope, BuildContext() shall be called on the scope before evaluating it. Mutiple evaluation on the same scope is possible after calling the RebuildContext() on the scope.
func NewScopeFromRoot ¶
func NewScopeFromRoot(ns []parsec.ParsecNode) Scope
NewScopeFromRoot will create a new scope from root non-terminal.
func (Scope) GetNonTerminal ¶
GetNonTerminal will return the rule-forms for non-terminal `name`.
func (Scope) GetProdfile ¶
GetProdfile will return the current production filename.
func (Scope) RebuildContext ¶
RebuildContext to evaluate same generation tree multiple times.
func (Scope) SetNonTerminal ¶
SetNonTerminal will set the rule-forms for non-terminal `name`.
func (Scope) SetProdfile ¶
SetProdfile will production filename.