File: concrete-syntax/core/pattern/container/morph/list.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: ConcreteSyntax#8
  module: Core#10
  module: Pattern#12
has properties
function: make_list / 3 #74
  module: Container#14
  module: Morph#16
  module: Monomorph#18
  class: List#20
inherits from
  Abstract ( Umu::ConcreteSyntax::Core::Pattern::Container::Morph )
has properties
method: initialize / 3 #21
method: __bb__ #40
method: __eb__ #45
method: __opt_type_sym_of_morph__ #50
method: __opt_type_sym_of_nil__ #55
method: __opt_type_sym_of_cons__ #60

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 Pattern
  13 
  14  module Container
  15 
  16  module Morph
  17 
  18  module Monomorph
  19 
  20  class List < Abstract
  21      def initialize(loc, pats, opt_last_pat)
  22          ASSERT.kind_of      pats,           ::Array
  23          ASSERT.opt_kind_of  opt_last_pat,   ElementOfContainer::Variable
  24 
  25          super
  26 
  27          if opt_last_pat && opt_last_pat.opt_type_sym
  28              raise X::SyntaxError.new(
  29                  opt_last_pat.loc,
  30                  "In list pattern, can not assert type to tail: '%s'",
  31                  opt_last_pat.to_s
  32              )
  33          end
  34      end
  35 
  36 
  37 
  38  private
  39 
  40      def __bb__
  41          '['
  42      end
  43 
  44 
  45      def __eb__
  46          ']'
  47      end
  48 
  49 
  50      def __opt_type_sym_of_morph__
  51          :List
  52      end
  53 
  54 
  55      def __opt_type_sym_of_nil__
  56          :Nil
  57      end
  58 
  59 
  60      def __opt_type_sym_of_cons__
  61          :Cons
  62      end
  63  end
  64 
  65  end # Umu::ConcreteSyntax::Core::Pattern::Container::Morph::Monomorph
  66 
  67  end # Umu::ConcreteSyntax::Core::Pattern::Container::Morph
  68 
  69  end # Umu::ConcreteSyntax::Core::Pattern::Container
  70 
  71 
  72  module_function
  73 
  74      def make_list(loc, pats = [], opt_last_pat = nil)
  75          ASSERT.kind_of      loc,            LOC::Entry
  76          ASSERT.kind_of      pats,           ::Array
  77          ASSERT.opt_kind_of  opt_last_pat,   ElementOfContainer::Variable
  78 
  79          Container::Morph::Monomorph::List.new(
  80              loc, pats.freeze, opt_last_pat
  81          ).freeze
  82      end
  83 
  84  end # Umu::ConcreteSyntax::Core::Pattern
  85 
  86  end # Umu::ConcreteSyntax::Core
  87 
  88  end # Umu::ConcreteSyntax
  89 
  90  end # Umu