Revisions

gist: 191852 Download_button fork
public
Public Clone URL: git://gist.github.com/191852.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  ruby-1.8.6-p383 > Hopcroft::Regex.parse("a|b")
   => #<Hopcroft::Regex::Alternation:0x122698c @expressions=[#<Hopcroft::Regex::Char:0x12240ec @expression="a">, #<Hopcroft::Regex::Char:0x1224a4c @expression="b">]>
  ruby-1.8.6-p383 > Hopcroft::Regex.parse("a|b").to_machine
   => #<Hopcroft::Machine::StateMachine:0x121f074 @start_state=State 1 {start: true, final: false, transitions: 2}>
  ruby-1.8.6-p383 > Hopcroft::Regex.parse("a|b").to_machine.to_dfa
   => #<Hopcroft::Machine::StateMachine:0x120d630 @start_state=State 12 {start: true, final: false, transitions: 2}>
 
  ruby-1.8.6-p383 > Hopcroft::Regex.parse("a|b").to_machine
   => #<Hopcroft::Machine::StateMachine:0x5f1b1c @start_state=State 24 {start: true, final: false, transitions: 2}>
  ruby-1.8.6-p383 > Hopcroft::Regex.parse("a|b").to_machine.state_table
   =>
  +-------------+------------+------------+--------------------------------------+
  | | b | a | Hopcroft::Machine::EpsilonTransition |
  +-------------+------------+------------+--------------------------------------+
  | State 32 | * State 33 | | |
  | State 30 | | * State 31 | |
  | -> State 29 | | | State 30, State 32 |
  +-------------+------------+------------+--------------------------------------+
 
  ruby-1.8.6-p383 > Hopcroft::Regex.parse("a|b").to_machine.to_dfa.state_table
   =>
  +-------------+----------+----------+
  | | a | b |
  +-------------+----------+----------+
  | -> State 21 | State 22 | State 23 |
  +-------------+----------+----------+