Sha256: 00d2af6c10609bb050074e907bf844d7b1c68ef6e447b03abd43fa8f013f69b8

Contents?: true

Size: 949 Bytes

Versions: 4

Compression:

Stored size: 949 Bytes

Contents

module Mulang::Ruby
  module Sexp
    def sequence(*contents)
      if contents.empty?
        ms(:MuNil)
      elsif contents.size == 1
        contents[0]
      else
        ms(:Sequence, *contents)
      end
    end

    def ms(tag, *contents)
      if contents.empty?
        {tag: tag}
      elsif contents.size == 1
        {tag: tag, contents: contents.first}
      else
        {tag: tag, contents: contents}
      end
    end

    def simple_method(name, args, body)
      {
        tag: :Method,
        contents: [
          name, 
          [
            [ args, {tag: :UnguardedBody, contents: body }]
          ]
        ]
      }
    end

    def mu_method(tag, args, body)
      {
        tag: tag,
        contents: [
          [ args, {tag: :UnguardedBody, contents: body }]
        ]
      }
    end

    def simple_send(sender, message, args)
      ms(:Send, sender, {tag: :Reference, contents: message}, args)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mulang-ruby-4.1.0 lib/mulang/ruby/sexp.rb
mulang-ruby-4.0.2 lib/mulang/ruby/sexp.rb
mulang-ruby-4.0.1 lib/mulang/ruby/sexp.rb
mulang-ruby-4.0.0 lib/mulang/ruby/sexp.rb