machine

package
v0.0.0-...-a2c9c92 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Deterministic Finite Automaton
	DFA = "DFA"

	// Non-Deterministic Finite Automaton
	NFA = "NFA"

	// Pushdown Automaton
	PDA = "PDA"

	// Turing Machine
	TM = "TM"
)

Machine types

View Source
const SCHEMA = `` /* 2479-byte string literal not displayed */

Compiled version of the schema for use as a default schema - needs to be updated whenever the master copy gets updated

Variables

This section is empty.

Functions

func GetSchema

func GetSchema() map[string]interface{}

func LoadMap

func LoadMap(document interface{}) (map[string]interface{}, error)

func ParseMachineType

func ParseMachineType(machineType string) string

func ValidateJson

func ValidateJson(
	schema map[string]interface{},
	document map[string]interface{},
) (*gojsonschema.Result, error)

Types

type Graph

type Graph struct {
	Start       *State       `json:"Start"`
	States      []State      `json:"States"`
	Transitions []Transition `json:"Transitions"`
}

func From

func From(params GraphParams) *Graph

func Load

func Load(document interface{}) (*Graph, error)

func LoadWithSchema

func LoadWithSchema(document interface{}, schema interface{}) (*Graph, error)

func NewBlankGraph

func NewBlankGraph() *Graph

func NewGraph

func NewGraph(start *State, states []State, transitions []Transition) *Graph

func (*Graph) Copy

func (g *Graph) Copy() *Graph

Deep copy a Machine

func (*Graph) FindState

func (g *Graph) FindState(id string) *State

func (*Graph) Json

func (g *Graph) Json() string

func (*Graph) JsonMap

func (g *Graph) JsonMap() map[string]interface{}

func (*Graph) String

func (g *Graph) String() string

func (*Graph) WithState

func (g *Graph) WithState(state State) *Graph

func (*Graph) WithStates

func (g *Graph) WithStates(states ...State) *Graph

func (*Graph) WithTransition

func (g *Graph) WithTransition(transition Transition) *Graph

func (*Graph) WithTransitions

func (g *Graph) WithTransitions(transitions ...Transition) *Graph

type GraphParams

type GraphParams struct {
	Start       string
	States      []State
	Transitions []TransitionParams
}

type Marshalable

type Marshalable interface {
	Json() string
	JsonMap() map[string]interface{}
	String() string
}

Some methods for serializing types

type State

type State struct {
	Id     string `json:"Id"`
	Ending bool   `json:"Ending"`
}

func (State) Copy

func (s State) Copy() State

func (State) Json

func (s State) Json() string

func (State) JsonMap

func (s State) JsonMap() map[string]interface{}

func (State) String

func (s State) String() string

type Transition

type Transition struct {
	Start  *State `json:"Start"`
	End    *State `json:"End"`
	Symbol string `json:"Symbol"`
}

func (Transition) Copy

func (s Transition) Copy() *Transition

func (Transition) Json

func (s Transition) Json() string

func (Transition) JsonMap

func (s Transition) JsonMap() map[string]interface{}

func (Transition) String

func (s Transition) String() string

type TransitionParams

type TransitionParams struct {
	Start  string
	End    string
	Symbol string
}

Jump to

Keyboard shortcuts

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