File: concrete-syntax/core/expression/nary/branch/case/entry.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_case / 5 #58
  module: Nary#14
  module: Branch#16
  class: Case#18
inherits from
  Abstract ( Umu::ConcreteSyntax::Core::Expression::Nary::Branch )
has properties
method: __keyword__ #22
method: __desugar__ / 2 #27

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  class Case < Abstract
  19 
  20  private
  21 
  22      def __keyword__
  23          'case'
  24      end
  25 
  26 
  27      def __desugar__(env, event)
  28          new_env = env.enter event
  29 
  30          fst_head = self.fst_rule.head
  31          ASSERT.kind_of fst_head, Rule::Case::Abstract
  32          expr = case fst_head
  33                  when Rule::Case::Atom
  34                      fst_head.desugar_for_rule new_env, self
  35                  when Rule::Case::Datum
  36                      fst_head.desugar_for_rule new_env, self
  37                  when Rule::Case::Class
  38                      fst_head.desugar_for_rule new_env, self
  39                  when Rule::Case::Polymorph::Abstract
  40                      fst_head.desugar_for_rule new_env, self
  41                  when Rule::Case::Monomorph::Abstraction::Abstract
  42                      fst_head.desugar_for_rule new_env, self
  43                  else
  44                      ASSERT.abort "Np case: %s", fst_head.inspect
  45                  end
  46 
  47          ASSERT.kind_of expr, ASCE::Abstract
  48      end
  49  end
  50 
  51  end # Umu::ConcreteSyntax::Core::Expression::Nary::Branch
  52 
  53  end # Umu::ConcreteSyntax::Core::Expression::Nary
  54 
  55 
  56  module_function
  57 
  58      def make_case(loc, expr, fst_rule, snd_rules, opt_else_expr)
  59          ASSERT.kind_of      loc,            LOC::Entry
  60          ASSERT.kind_of      expr,           CSCE::Abstract
  61          ASSERT.kind_of      fst_rule,
  62                                  CSCEN::Branch::Rule::Abstraction::Abstract
  63          ASSERT.kind_of      snd_rules,      ::Array
  64          ASSERT.opt_kind_of  opt_else_expr,  CSCE::Abstract
  65 
  66          Nary::Branch::Case.new(
  67              loc, expr, fst_rule, snd_rules, opt_else_expr
  68          ).freeze
  69      end
  70 
  71 
  72  end # Umu::ConcreteSyntax::Core::Expression
  73 
  74  end # Umu::ConcreteSyntax::Core
  75 
  76  end # Umu::ConcreteSyntax
  77 
  78  end # Umu