Chervil is a toy Lisp interpreter written in Ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

identifier.rb 447B

1234567891011121314151617181920212223242526
  1. module Chervil::AST
  2. class Identifier
  3. attr_reader :name
  4. def initialize(name)
  5. @name = name
  6. end
  7. def ==(other)
  8. @name == other.name
  9. end
  10. def evaluate(env)
  11. value = env.get(@name)
  12. if value.nil?
  13. ::Chervil::Error.new("unbound variable #{@name}")
  14. else
  15. if value.respond_to?(:evaluate)
  16. value.evaluate(env)
  17. else
  18. value
  19. end
  20. end
  21. end
  22. end
  23. end