logic

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Overview

Boolean operations and loop handling.

Index

Constants

This section is empty.

Variables

View Source
var Z_Types = typeinfo.TypeSet{
	Name: "logic",
	Comment: []string{
		"Boolean operations and loop handling.",
	},

	Slot:       z_slot_list,
	Flow:       z_flow_list,
	Signatures: z_signatures,
}

package listing of type data

View Source
var Zt_Always typeinfo.Flow

always, a type of flow.

View Source
var Zt_Brancher = typeinfo.Slot{
	Name: "brancher",
	Markup: map[string]any{
		"--": "Helper for the else statements of [ChooseBranch].",
	},
}

brancher, a type of slot.

View Source
var Zt_Break typeinfo.Flow

break, a type of flow.

View Source
var Zt_ChooseBranch typeinfo.Flow

choose_branch, a type of flow.

View Source
var Zt_ChooseNothingElse typeinfo.Flow

choose_nothing_else, a type of flow.

View Source
var Zt_ChooseNum typeinfo.Flow

choose_num, a type of flow.

View Source
var Zt_ChooseText typeinfo.Flow

choose_text, a type of flow.

View Source
var Zt_Continue typeinfo.Flow

continue, a type of flow.

View Source
var Zt_IsAll typeinfo.Flow

is_all, a type of flow.

View Source
var Zt_IsAny typeinfo.Flow

is_any, a type of flow.

View Source
var Zt_IsValue typeinfo.Flow

is_value, a type of flow.

View Source
var Zt_Never typeinfo.Flow

never, a type of flow.

not, a type of flow.

View Source
var Zt_NotAll typeinfo.Flow

not_all, a type of flow.

View Source
var Zt_NotAny typeinfo.Flow

not_any, a type of flow.

View Source
var Zt_NotValue typeinfo.Flow

not_value, a type of flow.

View Source
var Zt_Repeat typeinfo.Flow

repeat, a type of flow.

Functions

func Register added in v0.24.7

func Register(reg func(any))

gob like registration

Types

type Always

type Always struct {
	Markup map[string]any `json:",omitempty"`
}

This always returns true.

func (*Always) GetBool

func (op *Always) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*Always) GetMarkup

func (op *Always) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Always) TypeInfo

func (*Always) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Always_Slice

type Always_Slice []Always

Holds a slice of type Always.

func (*Always_Slice) Repeats

func (op *Always_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Always.

func (*Always_Slice) TypeInfo

func (*Always_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Always.

type Brancher

type Brancher interface {
	Branch(rt.Runtime) error
}

Brancher connects else and else-if clauses.

type Brancher_Slot

type Brancher_Slot struct{ Value Brancher }

Holds a single slot.

func (*Brancher_Slot) TypeInfo

func (*Brancher_Slot) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a single slot.

type Brancher_Slots

type Brancher_Slots []Brancher

Holds a slice of slots.

func (*Brancher_Slots) Repeats

func (op *Brancher_Slots) Repeats() bool

Implements typeinfo.Repeats for a slice of slots.

func (*Brancher_Slots) TypeInfo

func (*Brancher_Slots) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of slots.

type Break

type Break struct {
	Markup map[string]any `json:",omitempty"`
}

In a repeating loop, exit the loop; or, in a rule, stop processing rules.

func (*Break) Execute

func (*Break) Execute(rt.Runtime) error

func (*Break) GetMarkup

func (op *Break) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Break) TypeInfo

func (*Break) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Break_Slice

type Break_Slice []Break

Holds a slice of type Break.

func (*Break_Slice) Repeats

func (op *Break_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Break.

func (*Break_Slice) TypeInfo

func (*Break_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Break.

type ChooseBranch

type ChooseBranch struct {
	Condition rtti.BoolEval
	Args      []call.Arg
	Exe       []rtti.Execute
	Else      Brancher
	Markup    map[string]any `json:",omitempty"`
}

Select a block of statements to run based on a true/false check.

func PickTree

func PickTree(exe []rt.Execute) (ret *ChooseBranch)

scan for an initial branching statement in a "case like" switch,. that statement indicates a filter for a rule; returns nil if no such statement exists

func (*ChooseBranch) Branch

func (op *ChooseBranch) Branch(run rt.Runtime) (err error)

func (*ChooseBranch) Execute

func (op *ChooseBranch) Execute(run rt.Runtime) (err error)

func (*ChooseBranch) GetMarkup

func (op *ChooseBranch) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*ChooseBranch) PickBranch

func (op *ChooseBranch) PickBranch(run rt.Runtime, pushes *int) (ret []rt.Execute, err error)

loop through descendant branches to find which block we should run. rationale: patterns sometimes need to update counters and *not* run the block which guard them. this makes rule processing and normal branch selection the same.

func (*ChooseBranch) TypeInfo

func (*ChooseBranch) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type ChooseBranch_Slice

type ChooseBranch_Slice []ChooseBranch

Holds a slice of type ChooseBranch.

func (*ChooseBranch_Slice) Repeats

func (op *ChooseBranch_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of ChooseBranch.

func (*ChooseBranch_Slice) TypeInfo

func (*ChooseBranch_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of ChooseBranch.

type ChooseNothingElse

type ChooseNothingElse struct {
	Exe    []rtti.Execute
	Markup map[string]any `json:",omitempty"`
}

Run a set of statements after a condition has failed.

func (*ChooseNothingElse) Branch

func (op *ChooseNothingElse) Branch(run rt.Runtime) (err error)

else statements can only be run in the context of previous decisions ( include things like the branch of an empty while statements )

func (*ChooseNothingElse) GetMarkup

func (op *ChooseNothingElse) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*ChooseNothingElse) TypeInfo

func (*ChooseNothingElse) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type ChooseNothingElse_Slice

type ChooseNothingElse_Slice []ChooseNothingElse

Holds a slice of type ChooseNothingElse.

func (*ChooseNothingElse_Slice) Repeats

func (op *ChooseNothingElse_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of ChooseNothingElse.

func (*ChooseNothingElse_Slice) TypeInfo

func (*ChooseNothingElse_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of ChooseNothingElse.

type ChooseNum

type ChooseNum struct {
	If     rtti.BoolEval
	Args   []call.Arg
	True   rtti.NumEval
	False  rtti.NumEval
	Markup map[string]any `json:",omitempty"`
}

Pick one of two possible text values based on a condition. ( This acts similar to a ternary. )

func (*ChooseNum) GetMarkup

func (op *ChooseNum) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*ChooseNum) GetNum

func (op *ChooseNum) GetNum(run rt.Runtime) (ret rt.Value, err error)

func (*ChooseNum) TypeInfo

func (*ChooseNum) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type ChooseNum_Slice

type ChooseNum_Slice []ChooseNum

Holds a slice of type ChooseNum.

func (*ChooseNum_Slice) Repeats

func (op *ChooseNum_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of ChooseNum.

func (*ChooseNum_Slice) TypeInfo

func (*ChooseNum_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of ChooseNum.

type ChooseText

type ChooseText struct {
	If     rtti.BoolEval
	Args   []call.Arg
	True   rtti.TextEval
	False  rtti.TextEval
	Markup map[string]any `json:",omitempty"`
}

Pick one of two possible text values based on a condition. ( This acts similar to a ternary. )

func (*ChooseText) GetMarkup

func (op *ChooseText) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*ChooseText) GetText

func (op *ChooseText) GetText(run rt.Runtime) (ret rt.Value, err error)

func (*ChooseText) TypeInfo

func (*ChooseText) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type ChooseText_Slice

type ChooseText_Slice []ChooseText

Holds a slice of type ChooseText.

func (*ChooseText_Slice) Repeats

func (op *ChooseText_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of ChooseText.

func (*ChooseText_Slice) TypeInfo

func (*ChooseText_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of ChooseText.

type Continue

type Continue struct {
	Markup map[string]any `json:",omitempty"`
}

In a repeating loop, try the next iteration of the loop; or, in a rule, continue to the next rule.

func (*Continue) Execute

func (*Continue) Execute(rt.Runtime) error

func (*Continue) GetMarkup

func (op *Continue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Continue) TypeInfo

func (*Continue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Continue_Slice

type Continue_Slice []Continue

Holds a slice of type Continue.

func (*Continue_Slice) Repeats

func (op *Continue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Continue.

func (*Continue_Slice) TypeInfo

func (*Continue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Continue.

type DoInterrupt

type DoInterrupt struct{ KeepGoing bool }

DoInterrupt - an error code to break out of loops

func (DoInterrupt) Error

func (e DoInterrupt) Error() string

func (DoInterrupt) NoPanic

func (e DoInterrupt) NoPanic()

type IsAll

type IsAll struct {
	Test   []rtti.BoolEval
	Markup map[string]any `json:",omitempty"`
}

Check that every condition in a set of conditions returns true. Stops after finding a failed condition. An empty list returns false.

func (*IsAll) GetBool

func (op *IsAll) GetBool(run rt.Runtime) (ret rt.Value, err error)

check if all conditions return true.

func (*IsAll) GetMarkup

func (op *IsAll) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*IsAll) TypeInfo

func (*IsAll) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type IsAll_Slice

type IsAll_Slice []IsAll

Holds a slice of type IsAll.

func (*IsAll_Slice) Repeats

func (op *IsAll_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of IsAll.

func (*IsAll_Slice) TypeInfo

func (*IsAll_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of IsAll.

type IsAny

type IsAny struct {
	Test   []rtti.BoolEval
	Markup map[string]any `json:",omitempty"`
}

Check whether any condition in a set of conditions returns true. Stops after finding the first successful condition. An empty list returns false.

func (*IsAny) GetBool

func (op *IsAny) GetBool(run rt.Runtime) (ret rt.Value, err error)

check if any conditions return true.

func (*IsAny) GetMarkup

func (op *IsAny) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*IsAny) TypeInfo

func (*IsAny) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type IsAny_Slice

type IsAny_Slice []IsAny

Holds a slice of type IsAny.

func (*IsAny_Slice) Repeats

func (op *IsAny_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of IsAny.

func (*IsAny_Slice) TypeInfo

func (*IsAny_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of IsAny.

type IsValue

type IsValue struct {
	Value  rtti.Assignment
	Markup map[string]any `json:",omitempty"`
}

Determine the "truthiness" of a value. Bool values simply return their value. Num values: are true when not exactly zero. Text values: are true whenever they contain content. List values: are true whenever the list is non-empty. ( note this is similar to python, and different than javascript. ) Record values: are true whenever they have been initialized. ( only sub-records start uninitialized; record variables are always true. )

func (*IsValue) GetBool

func (op *IsValue) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*IsValue) GetMarkup

func (op *IsValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*IsValue) TypeInfo

func (*IsValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type IsValue_Slice

type IsValue_Slice []IsValue

Holds a slice of type IsValue.

func (*IsValue_Slice) Repeats

func (op *IsValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of IsValue.

func (*IsValue_Slice) TypeInfo

func (*IsValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of IsValue.

type MaxLoopError

type MaxLoopError int

MaxLoopError provides both an error and a counter

var MaxLoopIterations MaxLoopError = 0xbad

func (MaxLoopError) Error

func (e MaxLoopError) Error() string

type Never

type Never struct {
	Markup map[string]any `json:",omitempty"`
}

This always returns false.

func (*Never) GetBool

func (op *Never) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*Never) GetMarkup

func (op *Never) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Never) TypeInfo

func (*Never) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Never_Slice

type Never_Slice []Never

Holds a slice of type Never.

func (*Never_Slice) Repeats

func (op *Never_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Never.

func (*Never_Slice) TypeInfo

func (*Never_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Never.

type Not

type Not struct {
	Test   rtti.BoolEval
	Markup map[string]any `json:",omitempty"`
}

Determine the opposite of a condition.

func (*Not) GetBool

func (op *Not) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*Not) GetMarkup

func (op *Not) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Not) TypeInfo

func (*Not) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type NotAll

type NotAll struct {
	Test   []rtti.BoolEval
	Markup map[string]any `json:",omitempty"`
}

Check that every condition in a set of conditions returns false. Stops after finding any successful condition. An empty list returns false.

func (*NotAll) GetBool

func (op *NotAll) GetBool(run rt.Runtime) (ret rt.Value, err error)

check if all conditions return false.

func (*NotAll) GetMarkup

func (op *NotAll) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*NotAll) TypeInfo

func (*NotAll) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type NotAll_Slice

type NotAll_Slice []NotAll

Holds a slice of type NotAll.

func (*NotAll_Slice) Repeats

func (op *NotAll_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of NotAll.

func (*NotAll_Slice) TypeInfo

func (*NotAll_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of NotAll.

type NotAny

type NotAny struct {
	Test   []rtti.BoolEval
	Markup map[string]any `json:",omitempty"`
}

Check whether any condition in a set of conditions returns false. Stops after finding any failed condition. An empty list returns false.

func (*NotAny) GetBool

func (op *NotAny) GetBool(run rt.Runtime) (ret rt.Value, err error)

check if any conditions return false.

func (*NotAny) GetMarkup

func (op *NotAny) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*NotAny) TypeInfo

func (*NotAny) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type NotAny_Slice

type NotAny_Slice []NotAny

Holds a slice of type NotAny.

func (*NotAny_Slice) Repeats

func (op *NotAny_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of NotAny.

func (*NotAny_Slice) TypeInfo

func (*NotAny_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of NotAny.

type NotValue

type NotValue struct {
	Value  rtti.Assignment
	Markup map[string]any `json:",omitempty"`
}

Determine the "falsiness" of a value. This is the opposite of [TrueValue].

func (*NotValue) GetBool

func (op *NotValue) GetBool(run rt.Runtime) (ret rt.Value, err error)

func (*NotValue) GetMarkup

func (op *NotValue) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*NotValue) TypeInfo

func (*NotValue) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type NotValue_Slice

type NotValue_Slice []NotValue

Holds a slice of type NotValue.

func (*NotValue_Slice) Repeats

func (op *NotValue_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of NotValue.

func (*NotValue_Slice) TypeInfo

func (*NotValue_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of NotValue.

type Not_Slice

type Not_Slice []Not

Holds a slice of type Not.

func (*Not_Slice) Repeats

func (op *Not_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Not.

func (*Not_Slice) TypeInfo

func (*Not_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Not.

type Repeat

type Repeat struct {
	Condition rtti.BoolEval
	Initial   []call.Arg
	Args      []call.Arg
	Exe       []rtti.Execute
	Markup    map[string]any `json:",omitempty"`
}

Keep running a series of actions while a condition succeeds.

func (*Repeat) Execute

func (op *Repeat) Execute(run rt.Runtime) (err error)

func (*Repeat) GetMarkup

func (op *Repeat) GetMarkup(ensure bool) map[string]any

Implements typeinfo.Markup

func (*Repeat) TypeInfo

func (*Repeat) TypeInfo() typeinfo.T

Implements typeinfo.Instance

type Repeat_Slice

type Repeat_Slice []Repeat

Holds a slice of type Repeat.

func (*Repeat_Slice) Repeats

func (op *Repeat_Slice) Repeats() bool

Implements typeinfo.Repeats for a slice of Repeat.

func (*Repeat_Slice) TypeInfo

func (*Repeat_Slice) TypeInfo() typeinfo.T

Implements typeinfo.Instance for a slice of Repeat.

Jump to

Keyboard shortcuts

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