FSM

sealed class FSM

A representation of a generic finite state automaton. Can either a NFA or a DFA.

Inheritors

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun addEdge(from: State, edge: Edge)

Creates an edge between two nodes with a given label (operator and optional base).

Link copied to clipboard
fun addState(isStart: Boolean = false, isAcceptingState: Boolean = false): State

Generates a new state and adds it to this FSM.

Link copied to clipboard
fun changeStateProperty(state: State, name: Int? = null, isStart: Boolean? = null, isAcceptingState: Boolean? = null): Boolean

Safely change a property of a state contained in this FSM. Before changing the property, this method makes sure that e.g., no other start state exists or that no other state already has the suggested name.

Link copied to clipboard
fun checkedChangeStateProperty(state: State, name: Int? = null, isStart: Boolean? = null, isAcceptingState: Boolean? = null)

Same as changeStateProperty but throws an IllegalStateException if the property could not be changed.

Link copied to clipboard
open fun checkEdge(state: State, edge: Edge)

This function is set as State.edgeCheck inside addState. In case the edge must not be added to the state, this function must throw an exception.

Link copied to clipboard
abstract fun copy(): FSM

Creates a shallow copy.

Link copied to clipboard
open fun deepCopy(): FSM

Creates a deep copy of this FSM to enable multiple independent branches of execution.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Checks whether the given object is an FSM and whether it accepts the same language as this FSM

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
Link copied to clipboard

Generates the string representing this FSM in DOT format. This allows a simple visualization of the resulting automaton.