NFARunAutomaton

A RunAutomaton that does not require DFA. It will lazily determinize on-demand, memorizing the generated DFA states that has been explored. Note: the current implementation is NOT thread-safe

implemented based on: https://swtch.com/~rsc/regexp/regexp1.html

Constructors

Link copied to clipboard
constructor(automaton: Automaton, alphabetSize: Int)
constructor(automaton: Automaton)

Constructor, assuming alphabet size is the whole Unicode code point space

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).

Link copied to clipboard
Link copied to clipboard
open override val size: Int

Returns number of states this automaton has, note this may not be an accurate number in case of NFA

Functions

Link copied to clipboard

Gets character class of given codepoint

Link copied to clipboard
open override fun getNextTransition(t: Transition)

Iterate to the next transition after the provided one

Link copied to clipboard
open override fun getNumTransitions(state: Int): Int

How many transitions this state has.

Link copied to clipboard
open override fun getTransition(state: Int, index: Int, t: Transition)

Fill the provided Transition with the index'th transition leaving the specified state.

Link copied to clipboard
open override fun initTransition(state: Int, t: Transition): Int

Initialize the provided Transition to iterate through all transitions leaving the specified state. You must call .getNextTransition to get each transition. Returns the number of transitions leaving this state.

Link copied to clipboard
open override fun isAccept(state: Int): Boolean

Returns acceptance status for given state.

Link copied to clipboard
open override fun ramBytesUsed(): Long

Return the memory usage of this object in bytes. Negative values are illegal.

Link copied to clipboard
open fun run(s: ByteArray, offset: Int, length: Int): Boolean

Returns true if the given byte array is accepted by this automaton

Run through a given codepoint array, return accepted or not, should only be used in test

Link copied to clipboard
open override fun step(state: Int, c: Int): Int

For a given state and an incoming character (codepoint), return the next state