conditions

package
v0.0.0-...-9f34108 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BooleanEqual

type BooleanEqual struct {
	// contains filtered or unexported fields
}

BooleanEqual implements a boolean expression which compares the value of two tokens

func NewBooleanEqual

func NewBooleanEqual(a, b token.Token) *BooleanEqual

NewBooleanEqual returns a new instance of a BooleanEqual token referencing two tokens

func (*BooleanEqual) Clone

func (c *BooleanEqual) Clone() token.Token

Clone returns a copy of the token and all its children

func (*BooleanEqual) Evaluate

func (c *BooleanEqual) Evaluate() bool

Evaluate evaluates the boolean expression and returns its result

func (*BooleanEqual) Get

func (c *BooleanEqual) Get(i int) (token.Token, error)

Get returns the current referenced token at the given index. The error return argument is not nil, if the index is out of bound.

func (*BooleanEqual) InternalGet

func (c *BooleanEqual) InternalGet(i int) (token.Token, error)

InternalGet returns the current referenced internal token at the given index. The error return argument is not nil, if the index is out of bound.

func (*BooleanEqual) InternalLen

func (c *BooleanEqual) InternalLen() int

InternalLen returns the number of referenced internal tokens

func (*BooleanEqual) InternalLogicalRemove

func (c *BooleanEqual) InternalLogicalRemove(tok token.Token) token.Token

InternalLogicalRemove removes the referenced internal token and returns the replacement for the current token or nil if the current token should be removed.

func (*BooleanEqual) InternalReplace

func (c *BooleanEqual) InternalReplace(oldToken, newToken token.Token) error

InternalReplace replaces an old with a new internal token if it is referenced by this token. The error return argument is not nil, if the replacement is not suitable.

func (*BooleanEqual) Len

func (c *BooleanEqual) Len() int

Len returns the number of the current referenced tokens

func (*BooleanEqual) Parse

func (c *BooleanEqual) Parse(pars *token.InternalParser, cur int) (int, []error)

Parse tries to parse the token beginning from the current position in the parser data. If the parsing is successful the error argument is nil and the next current position after the token is returned.

func (*BooleanEqual) Permutation

func (c *BooleanEqual) Permutation(i uint) error

Permutation sets a specific permutation for this token

func (*BooleanEqual) Permutations

func (c *BooleanEqual) Permutations() uint

Permutations returns the number of permutations for this token

func (*BooleanEqual) PermutationsAll

func (c *BooleanEqual) PermutationsAll() uint

PermutationsAll returns the number of all possible permutations for this token including its children

func (*BooleanEqual) String

func (c *BooleanEqual) String() string

type BooleanExpression

type BooleanExpression interface {
	token.Token

	// Evaluate evaluates the boolean expression and returns its result
	Evaluate() bool
}

BooleanExpression defines a boolean expression

type BooleanTrue

type BooleanTrue struct{}

BooleanTrue implements a boolean expression which evaluates to always true

func NewBooleanTrue

func NewBooleanTrue() *BooleanTrue

NewBooleanTrue returns a new instance of a BooleanTrue token

func (*BooleanTrue) Clone

func (c *BooleanTrue) Clone() token.Token

Clone returns a copy of the token and all its children

func (*BooleanTrue) Evaluate

func (c *BooleanTrue) Evaluate() bool

Evaluate evaluates the boolean expression and returns its result

func (*BooleanTrue) Get

func (c *BooleanTrue) Get(i int) (token.Token, error)

Get returns the current referenced token at the given index. The error return argument is not nil, if the index is out of bound.

func (*BooleanTrue) InternalGet

func (c *BooleanTrue) InternalGet(i int) (token.Token, error)

InternalGet returns the current referenced internal token at the given index. The error return argument is not nil, if the index is out of bound.

func (*BooleanTrue) InternalLen

func (c *BooleanTrue) InternalLen() int

InternalLen returns the number of referenced internal tokens

func (*BooleanTrue) InternalLogicalRemove

func (c *BooleanTrue) InternalLogicalRemove(tok token.Token) token.Token

InternalLogicalRemove removes the referenced internal token and returns the replacement for the current token or nil if the current token should be removed.

func (*BooleanTrue) InternalReplace

func (c *BooleanTrue) InternalReplace(oldToken, newToken token.Token) error

InternalReplace replaces an old with a new internal token if it is referenced by this token. The error return argument is not nil, if the replacement is not suitable.

func (*BooleanTrue) Len

func (c *BooleanTrue) Len() int

Len returns the number of the current referenced tokens

func (*BooleanTrue) Parse

func (c *BooleanTrue) Parse(pars *token.InternalParser, cur int) (int, []error)

Parse tries to parse the token beginning from the current position in the parser data. If the parsing is successful the error argument is nil and the next current position after the token is returned.

func (*BooleanTrue) Permutation

func (c *BooleanTrue) Permutation(i uint) error

Permutation sets a specific permutation for this token

func (*BooleanTrue) Permutations

func (c *BooleanTrue) Permutations() uint

Permutations returns the number of permutations for this token

func (*BooleanTrue) PermutationsAll

func (c *BooleanTrue) PermutationsAll() uint

PermutationsAll returns the number of all possible permutations for this token including its children

func (*BooleanTrue) String

func (c *BooleanTrue) String() string

type ExpressionPointer

type ExpressionPointer struct {
	// contains filtered or unexported fields
}

ExpressionPointer implements a token pointer to an expression token

func NewExpressionPointer

func NewExpressionPointer(token token.Token) *ExpressionPointer

NewExpressionPointer returns a new instance of a ExpressionPointer token referencing the given token

func (*ExpressionPointer) Clone

func (c *ExpressionPointer) Clone() token.Token

Clone returns a copy of the token and all its children

func (*ExpressionPointer) Evaluate

func (c *ExpressionPointer) Evaluate() bool

Evaluate evaluates the boolean expression and returns its result

func (*ExpressionPointer) Get

func (c *ExpressionPointer) Get() token.Token

Get returns the current referenced token

func (*ExpressionPointer) InternalGet

func (c *ExpressionPointer) InternalGet() token.Token

InternalGet returns the current referenced internal token

func (*ExpressionPointer) InternalLogicalRemove

func (c *ExpressionPointer) InternalLogicalRemove(tok token.Token) token.Token

InternalLogicalRemove removes the referenced internal token and returns the replacement for the current token or nil if the current token should be removed.

func (*ExpressionPointer) InternalReplace

func (c *ExpressionPointer) InternalReplace(oldToken, newToken token.Token) error

InternalReplace replaces an old with a new internal token if it is referenced by this token. The error return argument is not nil, if the replacement is not suitable.

func (*ExpressionPointer) Parse

func (c *ExpressionPointer) Parse(pars *token.InternalParser, cur int) (int, []error)

Parse tries to parse the token beginning from the current position in the parser data. If the parsing is successful the error argument is nil and the next current position after the token is returned.

func (*ExpressionPointer) Permutation

func (c *ExpressionPointer) Permutation(i uint) error

Permutation sets a specific permutation for this token

func (*ExpressionPointer) Permutations

func (c *ExpressionPointer) Permutations() uint

Permutations returns the number of permutations for this token

func (*ExpressionPointer) PermutationsAll

func (c *ExpressionPointer) PermutationsAll() uint

PermutationsAll returns the number of all possible permutations for this token including its children

func (*ExpressionPointer) SetScope

func (c *ExpressionPointer) SetScope(variableScope *token.VariableScope)

SetScope sets the scope of the token

func (*ExpressionPointer) String

func (c *ExpressionPointer) String() string

type If

type If struct {
	Pairs []IfPair
}

If implements a condition token which holds a list of IfPairs which belong together (e.g. If Elsif ... Else)

func NewIf

func NewIf(Pairs ...IfPair) *If

NewIf returns a new instance of a If token referencing a list of IfPairs

func (*If) Clone

func (c *If) Clone() token.Token

Clone returns a copy of the token and all its children

func (*If) Parse

func (c *If) Parse(pars *token.InternalParser, cur int) (int, []error)

Parse tries to parse the token beginning from the current position in the parser data. If the parsing is successful the error argument is nil and the next current position after the token is returned.

func (*If) Permutation

func (c *If) Permutation(i uint) error

Permutation sets a specific permutation for this token

func (*If) Permutations

func (c *If) Permutations() uint

Permutations returns the number of permutations for this token

func (*If) PermutationsAll

func (c *If) PermutationsAll() uint

PermutationsAll returns the number of all possible permutations for this token including its children

func (*If) SetScope

func (c *If) SetScope(variableScope *token.VariableScope)

SetScope sets the scope of the token

func (*If) String

func (c *If) String() string

type IfPair

type IfPair struct {
	Head BooleanExpression
	Body token.Token
}

IfPair implements a condition token which holds an If condition with its head and body

func (*IfPair) Clone

func (c *IfPair) Clone() token.Token

Clone returns a copy of the token and all its children

func (*IfPair) Get

func (c *IfPair) Get(i int) (token.Token, error)

Get returns the current referenced token at the given index. The error return argument is not nil, if the index is out of bound.

func (*IfPair) InternalGet

func (c *IfPair) InternalGet(i int) (token.Token, error)

InternalGet returns the current referenced internal token at the given index. The error return argument is not nil, if the index is out of bound.

func (*IfPair) InternalLen

func (c *IfPair) InternalLen() int

InternalLen returns the number of referenced internal tokens

func (*IfPair) InternalLogicalRemove

func (c *IfPair) InternalLogicalRemove(tok token.Token) token.Token

InternalLogicalRemove removes the referenced internal token and returns the replacement for the current token or nil if the current token should be removed.

func (*IfPair) InternalReplace

func (c *IfPair) InternalReplace(oldToken, newToken token.Token) error

InternalReplace replaces an old with a new internal token if it is referenced by this token. The error return argument is not nil, if the replacement is not suitable.

func (*IfPair) Len

func (c *IfPair) Len() int

Len returns the number of the current referenced tokens

func (*IfPair) Parse

func (c *IfPair) Parse(pars *token.InternalParser, cur int) (int, []error)

Parse tries to parse the token beginning from the current position in the parser data. If the parsing is successful the error argument is nil and the next current position after the token is returned.

func (*IfPair) Permutation

func (c *IfPair) Permutation(i uint) error

Permutation sets a specific permutation for this token

func (*IfPair) Permutations

func (c *IfPair) Permutations() uint

Permutations returns the number of permutations for this token

func (*IfPair) PermutationsAll

func (c *IfPair) PermutationsAll() uint

PermutationsAll returns the number of all possible permutations for this token including its children

func (*IfPair) String

func (c *IfPair) String() string

type VariableDefined

type VariableDefined struct {
	// contains filtered or unexported fields
}

VariableDefined implements a boolean expression which evaluates if a variable is defined in a given scope

func NewVariableDefined

func NewVariableDefined(name string, variableScope *token.VariableScope) *VariableDefined

NewVariableDefined returns a new instance of a VariableDefined token initialzed with the given name and scope

func (*VariableDefined) Clone

func (c *VariableDefined) Clone() token.Token

Clone returns a copy of the token and all its children

func (*VariableDefined) Evaluate

func (c *VariableDefined) Evaluate() bool

Evaluate evaluates the boolean expression and returns its result

func (*VariableDefined) Parse

func (c *VariableDefined) Parse(pars *token.InternalParser, cur int) (int, []error)

Parse tries to parse the token beginning from the current position in the parser data. If the parsing is successful the error argument is nil and the next current position after the token is returned.

func (*VariableDefined) Permutation

func (c *VariableDefined) Permutation(i uint) error

Permutation sets a specific permutation for this token

func (*VariableDefined) Permutations

func (c *VariableDefined) Permutations() uint

Permutations returns the number of permutations for this token

func (*VariableDefined) PermutationsAll

func (c *VariableDefined) PermutationsAll() uint

PermutationsAll returns the number of all possible permutations for this token including its children

func (*VariableDefined) SetScope

func (c *VariableDefined) SetScope(variableScope *token.VariableScope)

SetScope sets the scope of the token

func (*VariableDefined) String

func (c *VariableDefined) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL