Sha256: 2bb564cf51c573e685b9e6cfc19f591ff7b2503f771bf245eb6fc398ddfe5211

Contents?: true

Size: 624 Bytes

Versions: 3

Compression:

Stored size: 624 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
    :operator
  when :open, :close
    :grouping
  when :le, :ge, :ne, :ne, :lt, :gt, :eq
    :comparator
  when :and, :or
    :combinator
  when :true, :false
    :logical
  when :if, :round, :not
    :function
  else
    :identifier
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dentaku-0.2.8 spec/spec_helper.rb
dentaku-0.2.7 spec/spec_helper.rb
dentaku-0.2.6 spec/spec_helper.rb