lib/nydp/pair.rb in nydp-0.0.3 vs lib/nydp/pair.rb in nydp-0.0.4

- old
+ new

@@ -64,10 +64,28 @@ if Nydp.NIL.is? cdr.cdr "'#{cdr.car.to_s}" else "'#{cdr.to_s}" end + elsif car.is_a?(Nydp::Symbol) && car.is?(:quasiquote) + if Nydp.NIL.is? cdr.cdr + "`#{cdr.car.to_s}" + else + "`#{cdr.to_s}" + end + elsif car.is_a?(Nydp::Symbol) && car.is?(:unquote) + if Nydp.NIL.is? cdr.cdr + ",#{cdr.car.to_s}" + else + ",#{cdr.to_s}" + end + elsif car.is_a?(Nydp::Symbol) && car.is?(:"unquote-splicing") + if Nydp.NIL.is? cdr.cdr + ",@#{cdr.car.to_s}" + else + ",@#{cdr.to_s}" + end else "(#{to_s_rest})" end end @@ -93,16 +111,16 @@ end [car.inspect, cdr_s].compact.join " " end - def append pair + def append thing if Nydp.NIL.is? self.cdr - self.cdr = pair + self.cdr = thing elsif pair? self.cdr - self.cdr.append pair + self.cdr.append thing else - raise "can't append #{pair} to list #{self} : cdr is #{self.cdr.inspect}" + raise "can't append #{thing} to list #{self} : cdr is #{self.cdr.inspect}" end self end def repush instructions, _