fsm

package
v0.0.0-...-212f30a Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const FailState = -1

A state in every DFA that traps and is not an accept state.

Variables

This section is empty.

Functions

func AdvanceAll

func AdvanceAll(c rune, dfas ...StateMachine) int

Types

type DFA

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

func NewForwardDFA

func NewForwardDFA(desc *DFADescription) DFA

func (*DFA) Accepted

func (d *DFA) Accepted() bool

func (*DFA) Feed

func (d *DFA) Feed(c rune)

func (DFA) State

func (d DFA) State() int

type DFADescription

type DFADescription struct {
	Rules       []TransitionRule
	AcceptState uint8
}

func BinaryLiteral

func BinaryLiteral() *DFADescription

func DecimalLiteral

func DecimalLiteral() *DFADescription

func FloatLiteral

func FloatLiteral() *DFADescription

func HexLiteral

func HexLiteral() *DFADescription

func IdentifierName

func IdentifierName() *DFADescription

type NFA

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

func NewBackwardNFA

func NewBackwardNFA(desc *DFADescription) NFA

func (*NFA) Accepted

func (m *NFA) Accepted() bool

func (*NFA) Feed

func (m *NFA) Feed(c rune)

type StateMachine

type StateMachine interface {
	Feed(rune)
	Accepted() bool
}

func BackwardNumLiteralMachines

func BackwardNumLiteralMachines() []StateMachine

func ForwardNumLiteralMachines

func ForwardNumLiteralMachines() []StateMachine

TODO refactor newFoward and newBackward to return StateMachine to get rid of duplication

type TransitionRule

type TransitionRule struct {
	Current uint8
	Char    rune
	To      uint8
}

Jump to

Keyboard shortcuts

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