Sha256: 452c9afcd673ca034d74c98dd62f8bddaf8c06518d10e9063f675cf5b04affb6

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 KB

Contents

# Check if variable is specific type
module SchemeChecker
  def check_for_bool(token)
    return true if token.boolean?
    is_instance_var = check_instance_var token
    return (check_for_bool get_var token) if is_instance_var
    false
  end

  def check_for_string(token)
    return true if token.string?
    is_instance_var = check_instance_var token
    return (check_for_string get_var token) if is_instance_var
    false
  end

  def check_for_num(token)
    return true if token.to_s.number?
    is_instance_var = check_instance_var token
    return (check_for_num get_var token) if is_instance_var
    false
  end

  def check_for_quote(token)
    return true if token[0].quote?
    is_instance_var = check_instance_var token
    return (check_for_num get_var token) if is_instance_var
    false
  end

  def check_for_symbol(var)
    var = var.join('') if var.is_a? Array
    return true if var.character?
    is_instance_var = check_instance_var var
    return (check_for_character get_var var) if is_instance_var
    false
  end

  def check_instance_var(var)
    return false if var.is_a? Proc
    return false unless valid_var_name var
    @procs.key? var.to_s
  end
end

Version data entries

14 entries across 11 versions & 1 rubygems

Version Path
lisp-interpreter-0.5.5 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.5.4 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.5.3 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.5.2 lib/lisp/interpreter/checker.rb
lisp-interpreter-0.5.2 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.5.1 lib/lisp/interpreter/checker.rb
lisp-interpreter-0.5.1 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.5.0 lib/lisp/interpreter/checker.rb
lisp-interpreter-0.5.0 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.4.4 lib/lisp/interpreter/helpers/checker.rb
lisp-interpreter-0.4.3 lib/lisp/interpreter/checker.rb
lisp-interpreter-0.4.2 lib/lisp/interpreter/checker.rb
lisp-interpreter-0.4.1 lib/lisp/interpreter/checker.rb
lisp-interpreter-0.4.0 lib/lisp/interpreter/checker.rb