Sha256: 66a954bc7526cc2f8c3920f47785400c64741c28cdf713716fb188ed665a8cbb
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
class Nydp::Symbol EMPTY = :"" attr_accessor :name attr_reader :hash def initialize name name = name.to_s @name = name.to_sym @inspection = "|#{name}|" if untidy(name) @hash = name.hash end def untidy str (str == "") || (str == nil) || (str =~ /\s/) end def value context=nil raise Nydp::Error.new("unbound symbol: #{self.inspect}") if @value == nil @value end def self.mk name, ns name = name.to_sym return Nydp::NIL if name == :nil return Nydp::T if name == :t sym = ns[name] unless sym sym = new(name) ns[name] = sym end sym end def self.find name, ns ; ns[name.to_sym] ; end def nydp_type ; :symbol ; end def inspect ; @inspection || name.to_s ; end def to_s ; name.to_s ; end def to_sym ; name ; end def to_ruby ; to_sym ; end def eql? other ; self == other ; end def is? nm ; self.name == nm.to_sym ; end def > other ; self.name > other.name ; end def < other ; self.name < other.name ; end def <=> other ; self.name <=> other.name ; end def == other other.is_a?(Nydp::Symbol) && (self.name == other.name) end def execute vm vm.push_arg self.value end def assign value, _=nil @value = value end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nydp-0.3.0 | lib/nydp/symbol.rb |
nydp-0.2.6 | lib/nydp/symbol.rb |
nydp-0.2.5 | lib/nydp/symbol.rb |