A toy dynamic programming language 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 287B

1234567891011121314151617
  1. class AST::Identifier
  2. attr_reader :name
  3. def initialize(name)
  4. @name = name
  5. end
  6. def ==(other)
  7. other.is_a?(AST::Identifier) && other.name == @name
  8. end
  9. def execute(env)
  10. value = env.get(@name)
  11. value.respond_to?(:execute) ? value.execute(env) : value
  12. end
  13. end