### Home Classes Methods

### In Files

- lib/gherkin/parser/parser.rb

### Parent

Object

### Namespace

- CLASS Gherkin::Parser::Parser::Machine::StateMachineReader

### Methods

- ::new
- #event
- #expected

### Files

- LICENSE
- README.rdoc
- meta.txt
- root.txt
- steps.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Gherkin
- Gherkin::CLexer
- Gherkin::Cli
- Gherkin::Cli::Main
- Gherkin::Formatter
- Gherkin::Formatter::Argument
- Gherkin::Formatter::Colors
- Gherkin::Formatter::Escaping
- Gherkin::Formatter::JSONFormatter
- Gherkin::Formatter::MonochromeFormat
- Gherkin::Formatter::PrettyFormatter
- Gherkin::I18n
- Gherkin::I18nLexer
- Gherkin::JSONLexer
- Gherkin::Parser
- Gherkin::Parser::Event
- Gherkin::Parser::FilterListener
- Gherkin::Parser::FormatterListener
- Gherkin::Parser::ParseError
- Gherkin::Parser::Parser
- Gherkin::Parser::Parser::Machine
- Gherkin::Parser::Parser::Machine::StateMachineReader
- Gherkin::Parser::Row
- Gherkin::Parser::TagExpression
- Gherkin::RbLexer
- Gherkin::Rubify
- Gherkin::Tools
- Gherkin::Tools::Files
- Gherkin::Tools::Reformat
- Gherkin::Tools::Stats
- Gherkin::Tools::StatsListener
- Class

No matching classes.

# Gherkin::Parser::Parser::Machine

### Public Class Methods

new(parser, name) click to toggle source

    # File lib/gherkin/parser/parser.rb, line 72
    def initialize(parser, name)
      @parser = parser
      @name = name
      @transition_map = transition_map(name)
      @state = name
    end

### Public Instance Methods

event(ev, line) click to toggle source

    # File lib/gherkin/parser/parser.rb, line 79
    def event(ev, line)
      states = @transition_map[@state]
      raise "Unknown state: #{@state.inspect} for machine #{@name}" if states.nil?
      new_state = states[ev]
      case new_state
      when "E"
        yield @state, expected
      when /push\((.+)\)/
        @parser.push_machine($1)
        @parser.event(ev, line)
      when "pop()"
        @parser.pop_machine()
        @parser.event(ev, line)
      else
        raise "Unknown transition: #{ev.inspect} among #{states.inspect} for machine #{@name}" if new_state.nil?
        @state = new_state
      end
    end

expected() click to toggle source

    # File lib/gherkin/parser/parser.rb, line 98
    def expected
      allowed = @transition_map[@state].find_all { |_, action| action != "E" }
      allowed.collect { |state| state[0] }.sort - ['eof']
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.