File: concrete-syntax/core/expression/unary/container/tuple.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: ConcreteSyntax#8
  module: Core#10
  module: Expression#12
has properties
function: make_tuple / 2 #53
  module: Unary#14
  module: Container#16
  class: Tuple#18
inherits from
  Abstract ( Umu::ConcreteSyntax::Core::Expression::Unary::Container )
has properties
method: initialize / 2 #19
method: to_s #27
method: pretty_print / 1 #32
method: __desugar__ / 2 #39

Code

   1  # coding: utf-8
   2  # frozen_string_literal: true
   3 
   4 
   5 
   6  module Umu
   7 
   8  module ConcreteSyntax
   9 
  10  module Core
  11 
  12  module Expression
  13 
  14  module Unary
  15 
  16  module Container
  17 
  18  class Tuple < Abstract
  19      def initialize(loc, exprs)
  20          ASSERT.kind_of  exprs, ::Array
  21          ASSERT.assert   exprs.size >= 2
  22 
  23          super
  24      end
  25 
  26 
  27      def to_s
  28          format "(%s)", self.map(&:to_s).join(', ')
  29      end
  30 
  31 
  32      def pretty_print(q)
  33          PRT.group_for_enum q, self, bb:'(', eb:')', join:', '
  34      end
  35 
  36 
  37  private
  38 
  39      def __desugar__(env, event)
  40          new_env = env.enter event
  41 
  42          ASCE.make_tuple(self.loc, self.map { |elem| elem.desugar(new_env) })
  43      end
  44  end
  45 
  46  end # Umu::ConcreteSyntax::Core::Expression::Unary::Container
  47 
  48  end # Umu::ConcreteSyntax::Core::Expression::Unary
  49 
  50 
  51  module_function
  52 
  53      def make_tuple(loc, exprs)
  54          ASSERT.kind_of loc,     LOC::Entry
  55          ASSERT.kind_of exprs,   ::Array
  56 
  57          Unary::Container::Tuple.new(loc, exprs.freeze).freeze
  58      end
  59 
  60  end # Umu::ConcreteSyntax::Core::Expression
  61 
  62  end # Umu::ConcreteSyntax::Core
  63 
  64  end # Umu::ConcreteSyntax
  65 
  66  end # Umu