(alphatize-states fsm-coll)
Rename all states in a collection of FSMs such that no two states
share the same name. Renames all map keys for the :states
metadata
value if provided.
Rename all states in a collection of FSMs such that no two states share the same name. Renames all map keys for the `:states` metadata value if provided.
(alphatize-states-fsm fsm)
Rename all states in a single FSM. Renames all map keys for the :states
metadata value if provided.
Rename all states in a single FSM. Renames all map keys for the `:states` metadata value if provided.
(concat-nfa nfa-coll)
(concat-nfa nfa-coll meta?)
Concat a collection of NFAs in sequential order. The function throws
an exception on empty collections. If meta?
is true
, then assoc the
alphatized :states
metadata to the NFA.
Concat a collection of NFAs in sequential order. The function throws an exception on empty collections. If `meta?` is `true`, then assoc the alphatized `:states` metadata to the NFA.
(epsilon-closure {nfa-transitions :transitions :as _nfa} init-state)
Given an NFA with transitions and an init-state
, returns the
epsilon closure for that state.
Given an NFA with transitions and an `init-state`, returns the epsilon closure for that state.
(kleene-nfa nfa)
(kleene-nfa {:keys [symbols states start accepts transitions] :as nfa} meta?)
Apply the Kleene star operation on an NFA (the "*" regex symbol),
which means the NFA can be taken zero or more times. If meta
is true
,
copy the original :states
metadata.
Apply the Kleene star operation on an NFA (the "*" regex symbol), which means the NFA can be taken zero or more times. If `meta` is `true`, copy the original `:states` metadata.
(minimize-dfa dfa)
Minimize the DFA using Brzozowski's Algorithm, which reverses and determinizes the DFA twice.
Minimize the DFA using Brzozowski's Algorithm, which reverses and determinizes the DFA twice.
(nfa->dfa {start :start :as nfa})
Given an NFA with epsilon transitions, perform the powerset construction in order to (semi)-determinize it and remove epsilon transitions.
Given an NFA with epsilon transitions, perform the powerset construction in order to (semi)-determinize it and remove epsilon transitions.
(optional-nfa nfa)
(optional-nfa {:keys [symbols states start accepts transitions] :as nfa} meta?)
Apply the optional operation on an NFA (the "?" regex symbol), which
means the NFA may or may not be taken. If meta
is true
, copy the
original :states
metadata.
Apply the optional operation on an NFA (the "?" regex symbol), which means the NFA may or may not be taken. If `meta` is `true`, copy the original `:states` metadata.
(plus-nfa nfa)
(plus-nfa {:keys [symbols states start accepts transitions] :as nfa} meta?)
Apply the Kleene plus operation on an NFA (the "+" regex symbol),
which means the NFA can be taken one or more times. If meta
is true
,
copy the original :states
metadata.
Apply the Kleene plus operation on an NFA (the "+" regex symbol), which means the NFA can be taken one or more times. If `meta` is `true`, copy the original `:states` metadata.
(read-next fsm state-info input)
(read-next fsm start-opts state-info input)
Given a compiled fsm
, the current state-info
, and input
, let
the FSM read that input; this function returns updated state info.
The state info is a set of maps with the following fields:
Key | Description |
---|---|
:state | The states arrived at in the FSM after reading the input. |
:accepted? | true if the FSM as arrived at an accept state after reading the input; false otherwise. |
In addition to the required args, the optional start-opts
map
can be passed. Valid options include:
Key | Description |
---|---|
:record-visits? | If true , each state info map will contain an extra :visited value that is a list of visited transition IDs. |
If state-info
is nil
, the function starts at the start state,
with start-opts
applied as needed. As indicated by its name,
start-opts
not applied when state-info
is not nil
.
If state-info
is #{}
, i.e. is empty, it is returned as-is, since an
empty set indicates that no more states can be matched.
Given a compiled `fsm`, the current `state-info`, and `input`, let the FSM read that input; this function returns updated state info. The state info is a set of maps with the following fields: | Key | Description | --- | --- | `:state` | The states arrived at in the FSM after reading the input. | `:accepted?` | `true` if the FSM as arrived at an accept state after reading the input; `false` otherwise. In addition to the required args, the optional `start-opts` map can be passed. Valid options include: | Key | Description | --- | --- | `:record-visits?` | If `true`, each state info map will contain an extra `:visited` value that is a list of visited transition IDs. If `state-info` is `nil`, the function starts at the start state, with `start-opts` applied as needed. As indicated by its name, `start-opts` not applied when `state-info` is not `nil`. If `state-info` is `#{}`, i.e. is empty, it is returned as-is, since an empty set indicates that no more states can be matched.
(transition-nfa fn-symbol f)
(transition-nfa fn-symbol f meta?)
Create an NFA that accepts a single input. If meta?
is true
, then
associate :states
metadata to the NFA.
Create an NFA that accepts a single input. If `meta?` is `true`, then associate `:states` metadata to the NFA.
(union-nfa nfa-coll)
(union-nfa nfa-coll meta?)
Construct a union of NFAs (corresponding to the "|" regex symbol.)
If meta?
is true
, then assoc the alphatized :states
metadata to
the NFA.
Construct a union of NFAs (corresponding to the "|" regex symbol.) If `meta?` is `true`, then assoc the alphatized `:states` metadata to the NFA.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close