class Kleene::NFA
- Kleene::NFA
- Reference
- Object
Defined in:
nfa.crConstructors
Instance Method Summary
- #accept?
- #add_state(new_state)
- #add_states(states)
- #add_transition(token : Char, from_state, to_state)
- #all_transitions : Array(NFATransition)
- #alphabet : Set(Char)
- #alphabet=(alphabet : Set(Char))
- #current_states : Set(State)
- #current_states=(current_states : Set(State))
- #deep_clone
- #epsilon_closure(state_set : Set(State)) : Set(State)
-
#epsilon_closure(state : State) : Set(State)
Determine the epsilon closure of the given state set That is, determine what states are reachable on an epsilon transition from the current state set (@current_states).
- #error_states
- #final_states : Set(State)
- #final_states=(final_states : Set(State))
- #graphviz
-
#handle_token!(input_token : Char)
process another input token
- #match?(input : String) : MatchRef | Nil
-
#matches(input)
Returns an array of matches found anywhere in the input string
-
#matches_at_offset(input, input_start_offset)
Returns an array of matches found in the input string, each of which begins at the offset input_start_offset
- #next_states(state_set, input_token)
-
#reachable_states(start_state)
Returns a set of State objects which are reachable through any transition path from the NFA's start_state.
- #regex_pattern
- #remove_state(state)
- #reset_current_states
- #set_regex_pattern(pattern : Nil | String)
- #start_state : State
- #start_state=(start_state : State)
- #states : Set(State)
- #states=(states : Set(State))
-
#to_dfa
This implements the subset construction algorithm presented on page 118 of the first edition of the dragon book.
-
#to_s(verbose = false)
Returns a nicely readable and concise string representation of this object, typically intended for users.
- #transitions : Hash(State, Hash(Char, Set(NFATransition)))
- #transitions=(transitions : Hash(State, Hash(Char, Set(NFATransition))))
- #transitions_from(state_set : Set(State)) : Set(NFATransition)
- #transitions_from(state : State) : Set(NFATransition)
- #update_final_states
Constructor Detail
Instance Method Detail
Determine the epsilon closure of the given state set That is, determine what states are reachable on an epsilon transition from the current state set (@current_states). Returns a Set of State objects.
Returns an array of matches found in the input string, each of which begins at the offset input_start_offset
Returns a set of State objects which are reachable through any transition path from the NFA's start_state.
This implements the subset construction algorithm presented on page 118 of the first edition of the dragon book. I found a similar explanation at: http://web.cecs.pdx.edu/~harry/compilers/slides/LexicalPart3.pdf
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.