Sha256: c8ea8299139efc826396fe22b815a6bef09b1f45825062bb68d52bf6fa6db857

Contents?: true

Size: 655 Bytes

Versions: 6

Compression:

Stored size: 655 Bytes

Contents

require 'pry'

# automatically create a token stream from bare values
def token_stream(*args)
  args.map do |value|
    type = type_for(value)
    Dentaku::Token.new(type, value)
  end
end

# make a (hopefully intelligent) guess about type
def type_for(value)
  case value
  when Numeric
    :numeric
  when String
    :string
  when true, false
    :logical
  when :add, :subtract, :multiply, :divide, :mod, :pow
    :operator
  when :open, :close, :comma
    :grouping
  when :le, :ge, :ne, :ne, :lt, :gt, :eq
    :comparator
  when :and, :or
    :combinator
  when :if, :round, :roundup, :rounddown, :not
    :function
  else
    :identifier
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dentaku-2.0.7 spec/spec_helper.rb
dentaku-2.0.6 spec/spec_helper.rb
dentaku-2.0.5 spec/spec_helper.rb
dentaku-2.0.4 spec/spec_helper.rb
dentaku-2.0.3 spec/spec_helper.rb
dentaku-2.0.2 spec/spec_helper.rb