File: concrete-syntax/core/expression/nary/branch/case/rule/monomoph.rb

Overview
Module Structure
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: ConcreteSyntax#8
  module: Core#10
  module: Expression#12
has properties
function: make_case_rule_list_nil / 1 #69
function: make_case_rule_list_cons / 3 #76
function: make_case_rule_cell_stream_nil / 1 #89
function: make_case_rule_cell_stream_cons / 3 #96
function: make_case_rule_memo_stream_nil / 1 #109
function: make_case_rule_memo_stream_cons / 3 #116
  module: Nary#14
  module: Branch#16
  module: Rule#18
  module: Case#20
has properties
function: make_rule_mono_nil / 2 #24
function: make_rule_mono_cons / 4 #32

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 Nary
  15 
  16  module Branch
  17 
  18  module Rule
  19 
  20  module Case
  21 
  22  module_function
  23 
  24      def make_rule_mono_nil(loc, type_sym)
  25          ASSERT.kind_of loc,         LOC::Entry
  26          ASSERT.kind_of type_sym,    ::Symbol
  27 
  28          CSCE.make_case_rule_poly_nil(loc, type_sym)
  29      end
  30 
  31 
  32      def make_rule_mono_cons(loc, head_pat, tail_pat, type_sym)
  33          ASSERT.kind_of loc,         LOC::Entry
  34          ASSERT.kind_of head_pat,    CSCP::ElementOfContainer::Variable
  35          ASSERT.kind_of tail_pat,    CSCP::ElementOfContainer::Variable
  36          ASSERT.kind_of type_sym,    ::Symbol
  37 
  38          if tail_pat.opt_type_sym
  39              raise X::SyntaxError.new(
  40                  tail_pat.loc,
  41                  format("In case-expression, " +
  42                          "can not specify type assertion for " +
  43                                                  "tail pattern: '%s'",
  44                      tail_pat.to_s,
  45                  )
  46              )
  47          end
  48 
  49          CSCE.make_case_rule_poly_cons(
  50              loc,
  51              head_pat,
  52              CSCP.make_variable(tail_pat.loc, tail_pat.var_sym, type_sym),
  53              type_sym
  54          )
  55      end
  56 
  57  end # Umu::ConcreteSyntax::Core::Expression::Nary::Branch::Rule::Case
  58 
  59  end # Umu::ConcreteSyntax::Core::Expression::Nary::Branch::Rule
  60 
  61  end # Umu::ConcreteSyntax::Core::Expression::Nary::Branch
  62 
  63  end # Umu::ConcreteSyntax::Core::Expression::Nary
  64 
  65  module_function
  66 
  67      # 1. For list
  68 
  69      def make_case_rule_list_nil(loc)
  70          ASSERT.kind_of loc, LOC::Entry
  71 
  72          Nary::Branch::Rule::Case.make_rule_mono_nil(loc, :List)
  73      end
  74 
  75 
  76      def make_case_rule_list_cons(loc, head_pat, tail_pat)
  77          ASSERT.kind_of loc,         LOC::Entry
  78          ASSERT.kind_of head_pat,    CSCP::ElementOfContainer::Variable
  79          ASSERT.kind_of tail_pat,    CSCP::ElementOfContainer::Variable
  80 
  81          Nary::Branch::Rule::Case.make_rule_mono_cons(
  82              loc, head_pat, tail_pat, :List
  83          )
  84      end
  85 
  86 
  87      # 2. For cell stream
  88 
  89      def make_case_rule_cell_stream_nil(loc)
  90          ASSERT.kind_of loc, LOC::Entry
  91 
  92          Nary::Branch::Rule::Case.make_rule_mono_nil(loc, :CellStream)
  93      end
  94 
  95 
  96      def make_case_rule_cell_stream_cons(loc, head_pat, tail_pat)
  97          ASSERT.kind_of loc,         LOC::Entry
  98          ASSERT.kind_of head_pat,    CSCP::ElementOfContainer::Variable
  99          ASSERT.kind_of tail_pat,    CSCP::ElementOfContainer::Variable
 100 
 101          Nary::Branch::Rule::Case.make_rule_mono_cons(
 102              loc, head_pat, tail_pat, :CellStream
 103          )
 104      end
 105 
 106 
 107      # 3. For memorized stream
 108 
 109      def make_case_rule_memo_stream_nil(loc)
 110          ASSERT.kind_of loc, LOC::Entry
 111 
 112          Nary::Branch::Rule::Case.make_rule_mono_nil(loc, :MemoStream)
 113      end
 114 
 115 
 116      def make_case_rule_memo_stream_cons(loc, head_pat, tail_pat)
 117          ASSERT.kind_of loc,         LOC::Entry
 118          ASSERT.kind_of head_pat,    CSCP::ElementOfContainer::Variable
 119          ASSERT.kind_of tail_pat,    CSCP::ElementOfContainer::Variable
 120 
 121          Nary::Branch::Rule::Case.make_rule_mono_cons(
 122              loc, head_pat, tail_pat, :MemoStream
 123          )
 124      end
 125 
 126  end # Umu::ConcreteSyntax::Core::Expression
 127 
 128  end # Umu::ConcreteSyntax::Core
 129 
 130  end # Umu::ConcreteSyntax
 131 
 132  end # Umu