Sha256: 339a808f907fa0aa6af400810dbec296314e7986ec64c0bff57ca544774fa556

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

module Cuker
  class GherkinLexer
    NonLexicalError = Class.new NotImplementedError

    attr_reader :lexed_ary
    attr :file_name

    def initialize raw_str_ary, file_name = nil
      @raw_strs_ary = raw_str_ary
      @file_name = file_name
      @lexed_ary = []
    end

    def lex
      # temp = nil
      @raw_strs_ary.each_with_index do |raw_str, line_num|
        res = case raw_str
              when /^\s*#/
                Comment.new raw_str
              else
                raise NonLexicalError.new "unable to lex line: #{line_num} :'#{raw_str}' #{"in file #{@file_name}" if @file_name}"
              end
        # if temp
        #   temp.items << Comment.new raw_str
        # else
        #   temp = nil
        # end
        @lexed_ary << res
      end
      @lexed_ary
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuker-0.4.0 lib/cuker/gherkin_lexer.rb
cuker-0.3.17 lib/cuker/gherkin_lexer.rb
cuker-0.3.15 lib/cuker/gherkin_lexer.rb