Documentation ¶
Index ¶
Constants ¶
const FileHeader = "slice_id.Program v0\n"
const NullFileHeader = "slice_id.null\n"
Variables ¶
var InvalidHeader = errors.New("Invalid file header")
Functions ¶
func InvalidSymbolType ¶
Types ¶
type Instruction ¶
Instruction represents a single step in the execution of a Program. Each instruction describes:
- A comparison operation for the state machine to perform, at a single index in the input string, and
- A pair of Program array indices referring to the next instruction to execute, one for each outcome of the comparison operation.
- The Program array indices are signed, with a negative value representing both the termination condition and the final output value to return.
func (Instruction[T, I, S]) Graph ¶
func (i Instruction[T, I, S]) Graph(index int, ports bool) []string
func (Instruction[T, I, S]) String ¶
func (i Instruction[T, I, S]) String() string
type Interface ¶
type Interface[S str.Symbol, T str.String[S]] interface { Identify(b T) int Length() int Graph(w io.Writer, cluster bool, ports bool) error Write(io.Writer) error // contains filtered or unexported methods }
Interface is a duplicate of [slice_id.Set], implemented by Program.
type Program ¶
type Program[T str.Symbol, I SIndex, S Index] []Instruction[T, I, S]
Program is a collection of Instruction objects, that implements a [Set]. The Program begins execution at the last Instruction in the Program, and repeatedly jumps to and executes the next Instruction based on the jump target defined by the current Instruction.
- The type parameter T defines the [Symbol] type of the [String] type the program matches.
- I defines the SIndex type used in the Low and High fields of each Instruction.
- S identifies the Index type used in the Index field of each Instruction.
func New ¶
New compiles a slice.Slice to a Program with a given SIndex and Index type. The resulting Program implements a [slice_id.Set] reprenting all the Strings in the Slice. The resulting Program has a size of i*(n-1) bytes, with n being the length of the Slice, and i being the Instruction size. See the Instruction type for more information on how the Instruction size is determined.
func (Program[T, I, S]) Length ¶
Length() returns the number of Strings represented by this Program.