Chervil is a toy Lisp interpreter written in Ruby
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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