Sha256: 0f7febb6fae2a04f2603da8e274771c48344d30469be12309fb8d2b95c79a240

Contents?: true

Size: 902 Bytes

Versions: 19

Compression:

Stored size: 902 Bytes

Contents

module Dentaku
  module TokenMatchers
    def self.token_matchers(*symbols)
      symbols.map { |s| matcher(s) }
    end

    def self.function_token_matchers(function_name, *symbols)
      token_matchers(:open, *symbols, :close).unshift(
        TokenMatcher.send(function_name)
      )
    end

    def self.matcher(symbol)
      @matchers ||= [
        :datetime, :numeric, :string, :addsub, :subtract, :muldiv, :pow, :mod,
        :comparator, :comp_gt, :comp_lt, :open, :close, :comma,
        :non_close_plus, :non_group, :non_group_star, :arguments,
        :logical, :combinator, :if, :round, :roundup, :rounddown, :not,
        :anchored_minus, :math_neg_pow, :math_neg_mul
      ].each_with_object({}) do |name, matchers|
        matchers[name] = TokenMatcher.send(name)
      end

      @matchers.fetch(symbol) do
        raise "Unknown token symbol #{ symbol }"
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
dentaku-3.5.4 lib/dentaku/token_matchers.rb
dentaku-3.5.3 lib/dentaku/token_matchers.rb
dentaku-3.5.2 lib/dentaku/token_matchers.rb
dentaku_zevo-3.5.2 lib/dentaku/token_matchers.rb
dentaku-3.5.1 lib/dentaku/token_matchers.rb
dentaku-3.5.0 lib/dentaku/token_matchers.rb
dentaku-3.4.2 lib/dentaku/token_matchers.rb
dentaku-3.4.1 lib/dentaku/token_matchers.rb
dentaku-3.4.0 lib/dentaku/token_matchers.rb
dentaku-3.3.4 lib/dentaku/token_matchers.rb
dentaku-3.3.3 lib/dentaku/token_matchers.rb
dentaku-3.3.2 lib/dentaku/token_matchers.rb
dentaku-3.3.1 lib/dentaku/token_matchers.rb
dentaku-3.3.0 lib/dentaku/token_matchers.rb
dentaku-3.2.1 lib/dentaku/token_matchers.rb
dentaku-3.2.0 lib/dentaku/token_matchers.rb
dentaku-3.1.0 lib/dentaku/token_matchers.rb
dentaku-3.0.0 lib/dentaku/token_matchers.rb
dentaku-2.0.11 lib/dentaku/token_matchers.rb