File: concrete-syntax/core/expression/unary/atom/number.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_integer / 2 #75
function: make_float / 2 #83
  module: Unary#14
  module: Atom#16
  module: Number#18
  class: Abstract#20
inherits from
  Abstract ( Umu::ConcreteSyntax::Core::Expression::Unary::Atom )
has properties
method: initialize / 2 #21
method: to_s #28
  class: Int#34
inherits from
  Abstract ( Umu::ConcreteSyntax::Core::Expression::Unary::Atom::Number )
has properties
method: initialize / 2 #35
method: __desugar__ / 2 #44
  class: Float#50
inherits from
  Abstract ( Umu::ConcreteSyntax::Core::Expression::Unary::Atom::Number )
has properties
method: initialize / 2 #51
method: __desugar__ / 2 #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 Expression
  13 
  14  module Unary
  15 
  16  module Atom
  17 
  18  module Number
  19 
  20  class Abstract < Atom::Abstract
  21      def initialize(loc, obj)
  22          ASSERT.kind_of obj, ::Numeric
  23 
  24          super
  25      end
  26 
  27 
  28      def to_s
  29          self.obj.to_s
  30      end
  31  end
  32 
  33 
  34  class Int < Abstract
  35      def initialize(loc, obj)
  36          ASSERT.kind_of obj, ::Integer
  37 
  38          super
  39      end
  40 
  41 
  42  private
  43 
  44      def __desugar__(_env, _event)
  45          ASCE.make_integer self.loc, self.obj
  46      end
  47  end
  48 
  49 
  50  class Float < Abstract
  51      def initialize(loc, obj)
  52          ASSERT.kind_of obj, ::Float
  53 
  54          super
  55      end
  56 
  57 
  58  private
  59 
  60      def __desugar__(_env, _event)
  61          ASCE.make_float self.loc, self.obj
  62      end
  63  end
  64 
  65  end # Umu::ConcreteSyntax::Expression::Core::Unary::Number::Atom
  66 
  67  end # Umu::ConcreteSyntax::Expression::Core::Unary::Number
  68 
  69  end # Umu::ConcreteSyntax::Expression::Core::Unary
  70 
  71 
  72 
  73  module_function
  74 
  75      def make_integer(loc, obj)
  76          ASSERT.kind_of loc, LOC::Entry
  77          ASSERT.kind_of obj, ::Integer
  78 
  79          Unary::Atom::Number::Int.new(loc, obj).freeze
  80      end
  81 
  82 
  83      def make_float(loc, obj)
  84          ASSERT.kind_of loc, LOC::Entry
  85          ASSERT.kind_of obj, ::Float
  86 
  87          Unary::Atom::Number::Float.new(loc, obj).freeze
  88      end
  89 
  90  end # Umu::ConcreteSyntax::Expression::Core
  91 
  92  end # Umu::ConcreteSyntax::Core
  93 
  94  end # Umu::ConcreteSyntax
  95 
  96  end # Umu