tavor: github.com/zimmski/tavor/token/constraints Index | Files

package constraints

import "github.com/zimmski/tavor/token/constraints"


Package Files


type Optional Uses

type Optional struct {
    // contains filtered or unexported fields

Optional implements a constraint and optional token which references another token which can be de(activated)

func NewOptional Uses

func NewOptional(tok token.Token) *Optional

NewOptional returns a new instance of a Optional token referencing the given token and setting the initial state to deactivated

func (*Optional) Activate Uses

func (c *Optional) Activate()

Activate activates this token

func (*Optional) Clone Uses

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

Clone returns a copy of the token and all its children

func (*Optional) Deactivate Uses

func (c *Optional) Deactivate()

Deactivate deactivates this token

func (*Optional) Get Uses

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

Get returns the current referenced token

func (*Optional) InternalGet Uses

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

InternalGet returns the current referenced internal token

func (*Optional) InternalLogicalRemove Uses

func (c *Optional) 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 (*Optional) InternalReplace Uses

func (c *Optional) 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 (*Optional) IsOptional Uses

func (c *Optional) IsOptional() bool

IsOptional checks dynamically if this token is in the current state optional

func (*Optional) Parse Uses

func (c *Optional) 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 (*Optional) Permutation Uses

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

Permutation sets a specific permutation for this token

func (*Optional) Permutations Uses

func (c *Optional) Permutations() uint

Permutations returns the number of permutations for this token

func (*Optional) PermutationsAll Uses

func (c *Optional) PermutationsAll() uint

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

func (*Optional) Reduce Uses

func (c *Optional) Reduce(i uint) error

Reduce sets a specific reduction for this token

func (*Optional) Reduces Uses

func (c *Optional) Reduces() uint

Reduces returns the number of reductions for this token

func (*Optional) String Uses

func (c *Optional) String() string

Package constraints imports 1 packages (graph) and is imported by 5 packages. Updated 2018-12-05. Refresh now. Tools for package owners.