fsm

package module
v0.0.0-...-efdf94b Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DFA

type DFA struct {
	States          []string
	Alphabet        []rune
	InitialState    string
	AcceptingStates []string
	CurrentState    string
	Transition      map[string]map[rune]string
}

DFA defines information about DFA

func FromCSV

func FromCSV(file string) (*DFA, error)

FromCSV builds a DFA from Transcition Table specified in a csv file.

func FromTable

func FromTable(transitionTable map[string]map[rune]string) (*DFA, error)

FromTable creates a DFA from Transition Table

func NFAtoDFA

func NFAtoDFA(nfa NFA) (DFA, error)

NFAtoDFA converts NFA to DFA

func (*DFA) IsAccepted

func (dfa *DFA) IsAccepted() bool

IsAccepted checks whether the input so far is accepted

func (*DFA) Next

func (dfa *DFA) Next(r rune) string

Next proceeds to the next state of DFA according to transition table

func (*DFA) Reset

func (dfa *DFA) Reset() string

Reset resets the DFA to start state

func (DFA) String

func (dfa DFA) String() string

func (DFA) ToCSV

func (dfa DFA) ToCSV(file string) error

ToCSV writes the DFA definition to a csv file

type NFA

type NFA struct {
	States          []string
	Alphabet        []rune
	InitialState    string
	AcceptingStates []string
	CurrentStates   []string
	Transition      map[string]map[rune][]string
}

NFA defines Non Deterministic Finite Automaton

func NFAfromCSV

func NFAfromCSV(file string) (*NFA, error)

NFAfromCSV builds an NFA from Transcition Table specified in a csv file.

func NFAfromTable

func NFAfromTable(transitionTable map[string]map[rune][]string) (*NFA, error)

NFAfromTable creates a DFA from Transition Table

func (*NFA) IsAccepted

func (nfa *NFA) IsAccepted() bool

IsAccepted checks whether the input so far is accepted

func (*NFA) Next

func (nfa *NFA) Next(r rune) []string

Next proceeds to the next state of DFA according to transition table

func (*NFA) Reset

func (nfa *NFA) Reset() []string

Reset resets the DFA to start state

func (NFA) String

func (nfa NFA) String() string

func (NFA) ToCSV

func (nfa NFA) ToCSV(file string) error

ToCSV writes the DFA definition to a csv file

Jump to

Keyboard shortcuts

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