Documentation ¶
Index ¶
- Constants
- Variables
- type Assignment
- type AssignmentOperator
- type Block
- type BlockType
- type Command
- func (self *Command) Args() (first interface{}, second map[string]interface{}, argerr error)
- func (self *Command) Name() (string, string)
- func (self *Command) OutputName() string
- func (self *Command) Script() *Friendscript
- func (self *Command) SetOutputNameOverride(name string)
- func (self *Command) SourceContext() *Context
- func (self *Command) String() string
- type Comparator
- type Conditional
- func (self *Conditional) ElseBlocks() []*Block
- func (self *Conditional) ElseIfConditions() []*Conditional
- func (self *Conditional) IfBlocks() []*Block
- func (self *Conditional) IsNegated() bool
- func (self *Conditional) String() string
- func (self *Conditional) Type() ConditionalType
- func (self *Conditional) WithAssignment() (*Assignment, *ConditionalExpression)
- func (self *Conditional) WithCommand() (*Command, *ConditionalExpression)
- func (self *Conditional) WithComparator() (*Expression, Comparator, *Expression)
- func (self *Conditional) WithRegex() (*Expression, MatchOperator, *regexp.Regexp)
- type ConditionalExpression
- type ConditionalType
- type Context
- type ContextType
- type Directive
- type DirectiveType
- type Expression
- type FlowControlErr
- type FlowControlType
- type Friendscript
- func (t *Friendscript) AST() *node32
- func (t *Friendscript) Add(rule pegRule, begin, end, depth uint32, index int)
- func (self *Friendscript) Blocks() []*Block
- func (t *Friendscript) Error() []token32
- func (t *Friendscript) Expand(index int)
- func (self *Friendscript) Filename() string
- func (p *Friendscript) Highlighter()
- func (p *Friendscript) Init()
- func (t *Friendscript) Order() [][]token32
- func (t *Friendscript) PreOrder() (<-chan state32, [][]token32)
- func (t *Friendscript) Print()
- func (t *Friendscript) PrintSyntax()
- func (p *Friendscript) PrintSyntaxTree()
- func (self *Friendscript) Scope() *Scope
- func (self *Friendscript) SetScope(scope *Scope)
- func (t *Friendscript) Tokens() <-chan token32
- type Loop
- func (self *Loop) Blocks() []*Block
- func (self *Loop) CurrentIndex() int
- func (self *Loop) IteratableParts() ([]string, interface{})
- func (self *Loop) Reset()
- func (self *Loop) ShouldContinue() bool
- func (self *Loop) String() string
- func (self *Loop) Type() LoopType
- func (self *Loop) UpperBound() int
- type LoopType
- type MatchOperator
- type Resolvable
- type Scope
- func (self *Scope) Data() map[string]interface{}
- func (self *Scope) Declare(key string)
- func (self *Scope) EvalContext() *Context
- func (self *Scope) Get(key string, fallback ...interface{}) interface{}
- func (self *Scope) Interpolate(in string) string
- func (self *Scope) IsLocal(key string) bool
- func (self *Scope) Level() int
- func (self *Scope) LockContext(ctx *Context)
- func (self *Scope) MostRecentValue() interface{}
- func (self *Scope) OwnerOf(key string) *Scope
- func (self *Scope) Set(key string, value interface{})
- func (self *Scope) String() string
- func (self *Scope) Unlock()
- type Statement
- func (self *Statement) Assignment() *Assignment
- func (self *Statement) Command() *Command
- func (self *Statement) Conditional() *Conditional
- func (self *Statement) Directive() *Directive
- func (self *Statement) Loop() *Loop
- func (self *Statement) Script() *Friendscript
- func (self *Statement) SourceContext() *Context
- func (self *Statement) Type() StatementType
- type StatementType
Constants ¶
const ( BlockContext ContextType = `block` StatementContext = `statement` CommandContext = `command` )
Variables ¶
var DefaultIteratorCommandResultVariableName = `result`
var UnqualifiedModuleName = `core`
This represents the name of a module whose commands do not need to be qualified with a "name::" prefix.
Functions ¶
This section is empty.
Types ¶
type Assignment ¶
type Assignment struct { LeftHandSide []string Operator AssignmentOperator RightHandSide []*Expression // contains filtered or unexported fields }
func (*Assignment) String ¶
func (self *Assignment) String() string
type AssignmentOperator ¶
type AssignmentOperator int
func (AssignmentOperator) Evaluate ¶
func (self AssignmentOperator) Evaluate(lhs interface{}, rhs interface{}) (interface{}, error)
func (AssignmentOperator) ShouldPreclear ¶
func (self AssignmentOperator) ShouldPreclear() bool
func (AssignmentOperator) String ¶
func (self AssignmentOperator) String() string
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (*Block) FlowContinue ¶
func (*Block) Script ¶
func (self *Block) Script() *Friendscript
func (*Block) SourceContext ¶
Return the character offset and length of this block's source code.
func (*Block) Statements ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
func (*Command) Args ¶
Return the first and (optional) second arguments to a command. If the first argument is nil, but the second argument is not, then the second argument will be returned as first, and the second argument will return as nil. In this way, nil first arguments are collapsed and omitted.
func (*Command) OutputName ¶
Return the name of the variable that command output should be stored in.
func (*Command) Script ¶
func (self *Command) Script() *Friendscript
func (*Command) SetOutputNameOverride ¶
func (*Command) SourceContext ¶
type Comparator ¶
type Comparator int
func (Comparator) Evaluate ¶
func (self Comparator) Evaluate(lhs *Expression, rhs *Expression) bool
type Conditional ¶
type Conditional struct {
// contains filtered or unexported fields
}
func (*Conditional) ElseBlocks ¶
func (self *Conditional) ElseBlocks() []*Block
func (*Conditional) ElseIfConditions ¶
func (self *Conditional) ElseIfConditions() []*Conditional
func (*Conditional) IfBlocks ¶
func (self *Conditional) IfBlocks() []*Block
func (*Conditional) IsNegated ¶
func (self *Conditional) IsNegated() bool
func (*Conditional) String ¶
func (self *Conditional) String() string
func (*Conditional) Type ¶
func (self *Conditional) Type() ConditionalType
func (*Conditional) WithAssignment ¶
func (self *Conditional) WithAssignment() (*Assignment, *ConditionalExpression)
Return the objects necessary to perform assignment then evaluate an expression
func (*Conditional) WithCommand ¶
func (self *Conditional) WithCommand() (*Command, *ConditionalExpression)
Return the objects necessary to execute a command then evaluate an expression
func (*Conditional) WithComparator ¶
func (self *Conditional) WithComparator() (*Expression, Comparator, *Expression)
Return the the left- and right-hand sides of an if-test, joined by the comparator.
func (*Conditional) WithRegex ¶
func (self *Conditional) WithRegex() (*Expression, MatchOperator, *regexp.Regexp)
Return the expression, operator, and regular expression in a regex if-test
type ConditionalExpression ¶
type ConditionalExpression struct {
// contains filtered or unexported fields
}
func NewConditionalExpression ¶
func NewConditionalExpression(statement *Statement, node *node32) *ConditionalExpression
func (*ConditionalExpression) IsTrue ¶
func (self *ConditionalExpression) IsTrue() bool
type ConditionalType ¶
type ConditionalType int
const ( ConditionWithAssignment ConditionalType = iota ConditionWithCommand ConditionWithRegex ConditionWithComparator )
func (ConditionalType) String ¶
func (self ConditionalType) String() string
type Context ¶
type ContextType ¶
type ContextType string
type Directive ¶
type Directive struct {
// contains filtered or unexported fields
}
func (*Directive) Type ¶
func (self *Directive) Type() DirectiveType
func (*Directive) VariableNames ¶
type DirectiveType ¶
type DirectiveType int
const ( UnknownDirective DirectiveType = iota UnsetDirective IncludeDirective DeclareDirective )
func (DirectiveType) String ¶
func (self DirectiveType) String() string
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
func NewExpression ¶
func NewExpression(statement *Statement, node *node32) *Expression
func (*Expression) Script ¶
func (self *Expression) Script() *Friendscript
func (*Expression) String ¶
func (self *Expression) String() string
func (*Expression) Value ¶
func (self *Expression) Value() (interface{}, error)
type FlowControlErr ¶
type FlowControlErr struct { Type FlowControlType Level int }
func NewFlowControl ¶
func NewFlowControl(flowType FlowControlType, levels int) *FlowControlErr
func (FlowControlErr) Error ¶
func (self FlowControlErr) Error() string
type FlowControlType ¶
type FlowControlType int
const ( FlowBreak FlowControlType = iota FlowContinue )
type Friendscript ¶
type Friendscript struct { Buffer string Parse func(rule ...int) error Reset func() Pretty bool // contains filtered or unexported fields }
func LoadFromFile ¶ added in v0.7.0
func LoadFromFile(filename string) (*Friendscript, error)
func Parse ¶
func Parse(input string) (*Friendscript, error)
func (*Friendscript) Blocks ¶
func (self *Friendscript) Blocks() []*Block
Return all top-level blocks in the current script.
func (*Friendscript) Filename ¶ added in v0.7.0
func (self *Friendscript) Filename() string
func (*Friendscript) Highlighter ¶ added in v0.8.4
func (p *Friendscript) Highlighter()
func (*Friendscript) Init ¶
func (p *Friendscript) Init()
func (*Friendscript) PreOrder ¶ added in v0.8.4
func (t *Friendscript) PreOrder() (<-chan state32, [][]token32)
func (*Friendscript) PrintSyntax ¶ added in v0.8.4
func (t *Friendscript) PrintSyntax()
func (*Friendscript) PrintSyntaxTree ¶
func (p *Friendscript) PrintSyntaxTree()
func (*Friendscript) Scope ¶
func (self *Friendscript) Scope() *Scope
func (*Friendscript) SetScope ¶
func (self *Friendscript) SetScope(scope *Scope)
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
func (*Loop) CurrentIndex ¶
func (*Loop) IteratableParts ¶
func (*Loop) ShouldContinue ¶
func (*Loop) UpperBound ¶
type MatchOperator ¶
type MatchOperator int
type Resolvable ¶
type Resolvable interface {
Resolve() interface{}
}
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
func NewEphemeralScope ¶ added in v0.7.0
func NewIsolatedScope ¶
func (*Scope) EvalContext ¶ added in v0.7.0
Returnt the current evaluation context (if any, may be nil).
func (*Scope) Interpolate ¶
func (*Scope) LockContext ¶ added in v0.7.0
Sets the scope evaluation lock and store the given context.
func (*Scope) MostRecentValue ¶ added in v0.7.0
func (self *Scope) MostRecentValue() interface{}
func (*Scope) OwnerOf ¶
Returns the scope that "owns" the given key. This works by first checking for an already-set key in the current scope. If none exists, the parent scope is consulted for non-nil values (and so on, all the way up the scope chain).
If none of the ancestor scopes have a non-nil value at the given key, the current scope becomes the owner of the key and will be returned.
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
func (*Statement) Assignment ¶
func (self *Statement) Assignment() *Assignment
func (*Statement) Conditional ¶
func (self *Statement) Conditional() *Conditional
func (*Statement) Script ¶
func (self *Statement) Script() *Friendscript
func (*Statement) SourceContext ¶
func (*Statement) Type ¶
func (self *Statement) Type() StatementType
type StatementType ¶
type StatementType int
const ( UnknownStatement StatementType = iota AssignmentStatement DirectiveStatement ExpressionStatement CommandStatement ConditionalStatement LoopStatement FlowControlStatement NoOpStatement )
func (StatementType) String ¶
func (self StatementType) String() string
Source Files ¶
- block.go
- context.go
- friendscript.peg.go
- operators_assignment.go
- operators_compare.go
- operators_match.go
- operators_mutate.go
- scope.go
- script.go
- statement.go
- statement_assignment.go
- statement_command.go
- statement_conditional.go
- statement_conditional_expression.go
- statement_directive.go
- statement_expression.go
- statement_loop.go