require 'erb' require 'cucumber/platform' require 'cucumber/ast' require 'cucumber/parser/treetop_ext' require 'cucumber/parser/table' module Cucumber # Classes in this module parse feature files and translate the parse tree # (concrete syntax tree) into an abstract syntax tree (AST) using # Embedded translation. # # The AST is built by the various #build methods in the parse tree. # # The AST classes are defined in the Cucumber::Ast module. module Parser translator = Module.new do def keywordz(key) 'Scenario' end end def self.load_parser(keywords) Loader.new(keywords) end class Loader def initialize(keywords) @keywords = keywords template = File.open(File.dirname(__FILE__) + "/parser/i18n.tt", Cucumber.file_mode('r')).read erb = ERB.new(template) grammar = erb.result(binding) Treetop.load_from_string(grammar) require 'cucumber/parser/feature' end def keywords(key) values = @keywords[key].split('|') values.map{|value| "'#{value}'"}.join(" / ") end end end end