Sha256: 634540a4d4cc5a943f32ce74c964679db1003c3334a7acb194fef7d81718fee3

Contents?: true

Size: 660 Bytes

Versions: 5

Compression:

Stored size: 660 Bytes

Contents

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dentaku-1.2.0 spec/spec_helper.rb
dentaku-1.1.0 spec/spec_helper.rb
dentaku-1.0.0 spec/spec_helper.rb
dentaku-0.2.14 spec/spec_helper.rb
dentaku-0.2.13 spec/spec_helper.rb