Method: Kleene::DSL#any
- Defined in:
- lib/kleene/dsl.rb
#any(token_collection, alphabet = DEFAULT_ALPHABET) ⇒ Object
two states: start state and final state structure: start state -> transitions for each token in the token collection -> final state
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kleene/dsl.rb', line 31 def any(token_collection, alphabet = DEFAULT_ALPHABET) start = State.new nfa = NFA.new(start, alphabet) final = State.new(true) token_collection.each {|token| nfa.add_transition(token, start, final) } nfa.update_final_states regex_pattern = "[#{token_collection.join("")}]" nfa.set_regex_pattern(regex_pattern) nfa end |