Sha256: 8001508a2d3cbe566f60eabd47e8cc02ca4179416fa9188cb584bab052041031

Contents?: true

Size: 358 Bytes

Versions: 30

Compression:

Stored size: 358 Bytes

Contents

module Babelyoda
  class StringsLexer
    TOKENS = [ :multiline_comment, :singleline_comment, :string, :reserved0, :equal_sign, :semicolon ].freeze

    def lex(str)
      str.scan(/(\/\*.*\*\/)|(\s*\/\/.*\n)|((["])(?:\\?+.)*?\4)|(\s*=\s*)|(;)/).each do |m|
        idx = m.index { |x| x }
        yield TOKENS[idx], m[idx].strip
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
babelyoda-2.1.1 lib/babelyoda/strings_lexer.rb
babelyoda-2.1.0 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.7 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.6 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.5 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.4 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.3 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.2 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.1 lib/babelyoda/strings_lexer.rb
babelyoda-2.0.0 lib/babelyoda/strings_lexer.rb