Object
# File lib/gherkin/parser/parser.rb, line 93
93: def event(ev, line)
94: states = @transition_map[@state]
95: raise "Unknown state: #{@state.inspect} for machine #{@name}" if states.nil?
96: new_state = states[ev]
97: case new_state
98: when "E"
99: yield @state, expected
100: when /push\((.+)\)/
101: @parser.push_machine($1)
102: @parser.event(ev, line)
103: when "pop()"
104: @parser.pop_machine()
105: @parser.event(ev, line)
106: else
107: raise "Unknown transition: #{ev.inspect} among #{states.inspect} for machine #{@name}" if new_state.nil?
108: @state = new_state
109: end
110: end
# File lib/gherkin/parser/parser.rb, line 125
125: def build_transition_map(name)
126: table = transition_table(name)
127: events = table.shift[1..1]
128: table.inject({}) do |machine, actions|
129: state = actions.shift
130: machine[state] = Hash[*events.zip(actions).flatten]
131: machine
132: end
133: end
# File lib/gherkin/parser/parser.rb, line 121
121: def transition_map(name)
122: @@transition_maps[name] ||= build_transition_map(name)
123: end
# File lib/gherkin/parser/parser.rb, line 135
135: def transition_table(name)
136: state_machine_reader = StateMachineReader.new
137: lexer = Gherkin::I18n.new('en').lexer(state_machine_reader)
138: machine = File.dirname(__FILE__) + "/#{name}.txt"
139: lexer.scan(File.read(machine))
140: state_machine_reader.rows
141: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.