class Cucumber::CucumberExpressions::CucumberExpressionGenerator

def generate_expressions(text)

def generate_expressions(text)
  parameter_type_combinations = []
  parameter_type_matchers = create_parameter_type_matchers(text)
  expression_template = +''
  pos = 0
  loop do
    matching_parameter_type_matchers = []
    parameter_type_matchers.each do |parameter_type_matcher|
      advanced_parameter_type_matcher = parameter_type_matcher.advance_to(pos)
      matching_parameter_type_matchers.push(advanced_parameter_type_matcher) if advanced_parameter_type_matcher.find
    end
    if matching_parameter_type_matchers.any?
      matching_parameter_type_matchers = matching_parameter_type_matchers.sort
      best_parameter_type_matcher = matching_parameter_type_matchers[0]
      best_parameter_type_matchers = matching_parameter_type_matchers.select do |m|
        (m <=> best_parameter_type_matcher).zero?
      end
      # Build a list of parameter types without duplicates. The reason there
      # might be duplicates is that some parameter types have more than one regexp,
      # which means multiple ParameterTypeMatcher objects will have a reference to the
      # same ParameterType.
      # We're sorting the list so prefer_for_regexp_match parameter types are listed first.
      # Users are most likely to want these, so they should be listed at the top.
      parameter_types = []
      best_parameter_type_matchers.each do |parameter_type_matcher|
        parameter_types.push(parameter_type_matcher.parameter_type) unless parameter_types.include?(parameter_type_matcher.parameter_type)
      end
      parameter_types.sort!
      parameter_type_combinations.push(parameter_types)
      expression_template += escape(text.slice(pos...best_parameter_type_matcher.start))
      expression_template += '{%s}'
      pos = best_parameter_type_matcher.start + best_parameter_type_matcher.group.length
    else
      break
    end
    break if pos >= text.length
  end
  expression_template += escape(text.slice(pos..-1))
  CombinatorialGeneratedExpressionFactory.new(
    expression_template,
    parameter_type_combinations
  ).generate_expressions
end