Chervil is a toy Lisp interpreter written in Ruby
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

application.rb 459B

12345678910111213141516171819202122
  1. module Chervil::AST
  2. class Application
  3. attr_reader :expr
  4. attr_reader :arguments
  5. def initialize(expr, arguments)
  6. @expr = expr
  7. @arguments = arguments
  8. end
  9. def ==(other)
  10. @expr == other.expr && @arguments == other.arguments
  11. end
  12. def evaluate(env)
  13. if @expr.class == Identifier
  14. function = env.get(@expr.name)
  15. function.call(@arguments.map { |arg| arg.evaluate(env) })
  16. end
  17. end
  18. end
  19. end