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.

definition.rb 444B

12345678910111213141516171819202122
  1. module Chervil::AST
  2. class Definition
  3. attr_reader :name
  4. attr_reader :value
  5. def initialize(name, value)
  6. @name = name
  7. @value = value
  8. end
  9. def ==(other)
  10. @name == other.name && @value == other.value
  11. end
  12. def evaluate(env)
  13. @value = value.evaluate(env) if value.is_a?(Identifier)
  14. return @value if @value.is_a?(::Chervil::Error)
  15. env.set(@name.name, @value)
  16. nil
  17. end
  18. end
  19. end