options

package
v0.0.0-...-9033d6b Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Lookahead: 3,
}

DefaultOptions is the Options, to be optionally modified by Option functions.

Functions

This section is empty.

Types

type Option

type Option func(slice.Untyped, *Options)

Option modifies an Options.

func BruteForce

func BruteForce() Option

BruteForce returns an Option that sets the Lookahead to the length of the longest [str.String] in the slice.Slice. Thus, for each stage in the process, every [str.String] index that could yield a Pivot is considered. This scales really badly for large sets.

func Lookahead

func Lookahead(v int) Option

Lookahead returns an Option that modifies the Lookahead value.

type Options

type Options struct {
	// Lookahead defines the number of extra indices to consider.
	// By default, when the compiler looks for a Pivot, it considers Symbols at
	// the position immediately after the longest common prefix of all the
	// [String] values in the [Slice]. If Lookahead=n && n>0, the compiler will
	// also look for a Pivot in the next n subsequent positions, and from the
	// resulting Pivots, choose the one with the lowest Balance value (meaning,
	// the pivot that comes closest to bisecting the Slice). This gives the
	// compiler more opportunities to create a more balanced search tree for the
	// [program.Program] to carry out.
	//
	// A non-zero Lookahead means the final [program.Program] can backtrack by a
	// maximum number of Symbols equal to the Lookahead value.
	Lookahead int
}

Options configures the process of building of a [program.Program].

func Build

func Build(s slice.Untyped, o ...Option) Options

Build starts with a copy of DefaultOptions,

Jump to

Keyboard shortcuts

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