[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dennou-ruby:003806] Re: Rubyパッケージ



西澤さま:

神代です.

僕も最近困っていたので, さっそく試してみました.

こちらでは

ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]

でうまくいっています. ありがとうございます.

以下, たいしたことではないですが,

numru-units-1.7.tar.gz にパッチをあててやってみました.
この場合,
% ruby install.rb
でインストールしますが, install.rb が古いため失敗してしまうので,
こいつでも ruby 1.6 を切り捨てる修正をしました.
あと, 修正版の src/units.rb が lib/numru/units.rb にコピーされ
てなかったので, そのままだと古いままになってしまうので,
% cp -p src/units.rb lib/numru/
をしました.
ここまでやった状態を numru-units-1.7-ruby2.2.0.patch としました
ので, ご利用ください.

--
神代 剛 (こうしろ つよし)
気象研究所気候研究部第四研究室 支援研究員


At Tue, 06 Jan 2015 01:59:21 +0000,
Seiya Nishizawa wrote:
> 
> 西澤です
> 
> 周りに ruby 2.1 が増えてきて、numru-units が動かないのが不便なので、対
> 応してみました。
> 
> 試した環境は
> ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
> ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
> です。
> ruby 1.6 は切り捨てることにしました
> 
> racc 1.4.5 で作ったので、もしかすると環境によっては動かないところがあ
> るかもしれませんので、
> テストしていただければと思います。
> 
> よろしくお願いします。
> 
> 西澤誠也
> 
> On Sat Dec 27 2014 at 16:44:06 Takeshi Horinouchi
> <horinout@xxxxxxxxxxxxxxxxx> wrote:
> 
>     堀之内です。
>     
>     > 確か ruby 2.0 じゃないと numru-units が動かないと思います。
>     
>     Ruby 2.1 では numru-units が利用する racc の振る舞いが
>     変わっててうまく動きません
>     ([dennou-ruby:003720] numru-units on ruby 2.1 のスレッド)。
>     これは未究明です。2.2 で自然解決してればいいんですが,
>     試してません。
>     
>     # racc はよくわかってなくて私が調査しても難航しそうで...
>     
>     > 大塚です。
>     >
>     > 確か ruby 2.0 じゃないと numru-units が動かないと思います。
>     > この問題、解決しましたっけ?
>     
>     

diff -uNr numru-units-1.7_orig/install.rb numru-units-1.7/install.rb
--- numru-units-1.7_orig/install.rb	2008-02-05 18:08:06.000000000 +0900
+++ numru-units-1.7/install.rb	2015-01-06 13:30:42.857768006 +0900
@@ -1,13 +1,8 @@
 require 'rbconfig'
 require 'find'
-include Config
+include RbConfig
 
-if CONFIG["MINOR"].to_i > 6 then $rb_18 = true else $rb_18 = false end
-if $rb_18
-  require 'fileutils'
-else
-  require 'ftools'
-end
+require 'fileutils'
 
 =begin
 $version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
@@ -40,20 +35,12 @@
   for f in dir
     next if f == "."
     next if f == "CVS"
-    if $rb_18
-      FileUtils.makedirs(File.join(destdir, f))
-    else
-      File::makedirs(File.join(destdir, f))
-    end
+    FileUtils.makedirs(File.join(destdir, f))
   end
   for f in path
     next if (/\~$/ =~ f)
     next if (/^\./ =~ File.basename(f))
-    if $rb_18
-      FileUtils.install(File.join("lib", f), File.join(destdir, f), {:mode => 0644, :verbose => true})
-    else
-      File::install(File.join("lib", f), File.join(destdir, f), 0644, true)
-    end
+    FileUtils.install(File.join("lib", f), File.join(destdir, f), {:mode => 0644, :verbose => true})
   end
 end
 
diff -uNr numru-units-1.7_orig/lib/numru/units.rb numru-units-1.7/lib/numru/units.rb
--- numru-units-1.7_orig/lib/numru/units.rb	2011-08-03 18:16:07.000000000 +0900
+++ numru-units-1.7/lib/numru/units.rb	2015-01-06 13:29:53.745769402 +0900
@@ -3,457 +3,8 @@
 # This file is automatically generated by racc 1.4.5
 # from racc grammer file "units.racc".
 #
-#
-# tmp.rb: generated by racc (runtime embedded)
-#
-###### racc/parser.rb begin
-unless $".index 'racc/parser.rb'
-$".push 'racc/parser.rb'
-
-#
-# $Id: units.rb,v 1.19 2011-08-03 09:16:07 horinout Exp $
-#
-# Copyright (c) 1999-2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# As a special exception, when this code is copied by Racc
-# into a Racc output file, you may use that output file
-# without restriction.
-#
 
-unless defined?(NotImplementedError)
-  NotImplementedError = NotImplementError
-end
-
-module Racc
-  class ParseError < StandardError; end
-end
-unless defined?(::ParseError)
-  ParseError = Racc::ParseError
-end
-
-module Racc
-
-  unless defined?(Racc_No_Extentions)
-    Racc_No_Extentions = false
-  end
-
-  class Parser
-
-    Racc_Runtime_Version = '1.4.5'
-    Racc_Runtime_Revision = '$Revision: 1.19 $'.split[1]
-
-    Racc_Runtime_Core_Version_R = '1.4.5'
-    Racc_Runtime_Core_Revision_R = '$Revision: 1.19 $'.split[1]
-    begin
-      require 'racc/cparse'
-    # Racc_Runtime_Core_Version_C  = (defined in extention)
-      Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
-      unless new.respond_to?(:_racc_do_parse_c, true)
-        raise LoadError, 'old cparse.so'
-      end
-      if Racc_No_Extentions
-        raise LoadError, 'selecting ruby version of racc runtime core'
-      end
-
-      Racc_Main_Parsing_Routine    = :_racc_do_parse_c
-      Racc_YY_Parse_Method         = :_racc_yyparse_c
-      Racc_Runtime_Core_Version    = Racc_Runtime_Core_Version_C
-      Racc_Runtime_Core_Revision   = Racc_Runtime_Core_Revision_C
-      Racc_Runtime_Type            = 'c'
-    rescue LoadError
-      Racc_Main_Parsing_Routine    = :_racc_do_parse_rb
-      Racc_YY_Parse_Method         = :_racc_yyparse_rb
-      Racc_Runtime_Core_Version    = Racc_Runtime_Core_Version_R
-      Racc_Runtime_Core_Revision   = Racc_Runtime_Core_Revision_R
-      Racc_Runtime_Type            = 'ruby'
-    end
-
-    def Parser.racc_runtime_type
-      Racc_Runtime_Type
-    end
-
-    private
-
-    def _racc_setup
-      @yydebug = false unless self.class::Racc_debug_parser
-      @yydebug = false unless defined?(@yydebug)
-      if @yydebug
-        @racc_debug_out = $stderr unless defined?(@racc_debug_out)
-        @racc_debug_out ||= $stderr
-      end
-      arg = self.class::Racc_arg
-      arg[13] = true if arg.size < 14
-      arg
-    end
-
-    def _racc_init_sysvars
-      @racc_state  = [0]
-      @racc_tstack = []
-      @racc_vstack = []
-
-      @racc_t = nil
-      @racc_val = nil
-
-      @racc_read_next = true
-
-      @racc_user_yyerror = false
-      @racc_error_status = 0
-    end
-
-    ###
-    ### do_parse
-    ###
-
-    def do_parse
-      __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
-    end
-
-    def next_token
-      raise NotImplementedError, "#{self.class}\#next_token is not defined"
-    end
-
-    def _racc_do_parse_rb(arg, in_debug)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-
-      _racc_init_sysvars
-      tok = act = i = nil
-      nerr = 0
-
-      catch(:racc_end_parse) {
-        while true
-          if i = action_pointer[@racc_state[-1]]
-            if @racc_read_next
-              if @racc_t != 0   # not EOF
-                tok, @racc_val = next_token()
-                unless tok      # EOF
-                  @racc_t = 0
-                else
-                  @racc_t = (token_table[tok] or 1)   # error token
-                end
-                racc_read_token(@racc_t, tok, @racc_val) if @yydebug
-                @racc_read_next = false
-              end
-            end
-            i += @racc_t
-            unless i >= 0 and
-                   act = action_table[i] and
-                   action_check[i] == @racc_state[-1]
-              act = action_default[@racc_state[-1]]
-            end
-          else
-            act = action_default[@racc_state[-1]]
-          end
-          while act = _racc_evalact(act, arg)
-            ;
-          end
-        end
-      }
-    end
-
-    ###
-    ### yyparse
-    ###
-
-    def yyparse(recv, mid)
-      __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
-    end
-
-    def _racc_yyparse_rb(recv, mid, arg, c_debug)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-
-      _racc_init_sysvars
-      tok = nil
-      act = nil
-      i = nil
-      nerr = 0
-
-      catch(:racc_end_parse) {
-        until i = action_pointer[@racc_state[-1]]
-          while act = _racc_evalact(action_default[@racc_state[-1]], arg)
-            ;
-          end
-        end
-        recv.__send__(mid) do |tok, val|
-          unless tok
-            @racc_t = 0
-          else
-            @racc_t = (token_table[tok] or 1)   # error token
-          end
-          @racc_val = val
-          @racc_read_next = false
-
-          i += @racc_t
-          unless i >= 0 and
-                 act = action_table[i] and
-                 action_check[i] == @racc_state[-1]
-            act = action_default[@racc_state[-1]]
-          end
-          while act = _racc_evalact(act, arg)
-            ;
-          end
-
-          while not (i = action_pointer[@racc_state[-1]]) or
-                not @racc_read_next or
-                @racc_t == 0   # $
-            unless i and i += @racc_t and
-                   i >= 0 and
-                   act = action_table[i] and
-                   action_check[i] == @racc_state[-1]
-              act = action_default[@racc_state[-1]]
-            end
-            while act = _racc_evalact(act, arg)
-              ;
-            end
-          end
-        end
-      }
-    end
-
-    ###
-    ### common
-    ###
-
-    def _racc_evalact(act, arg)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-      nerr = 0   # tmp
-
-      if act > 0 and act < shift_n
-        #
-        # shift
-        #
-        if @racc_error_status > 0
-          @racc_error_status -= 1 unless @racc_t == 1   # error token
-        end
-        @racc_vstack.push @racc_val
-        @racc_state.push act
-        @racc_read_next = true
-        if @yydebug
-          @racc_tstack.push @racc_t
-          racc_shift @racc_t, @racc_tstack, @racc_vstack
-        end
-
-      elsif act < 0 and act > -reduce_n
-        #
-        # reduce
-        #
-        code = catch(:racc_jump) {
-          @racc_state.push _racc_do_reduce(arg, act)
-          false
-        }
-        if code
-          case code
-          when 1 # yyerror
-            @racc_user_yyerror = true   # user_yyerror
-            return -reduce_n
-          when 2 # yyaccept
-            return shift_n
-          else
-            raise '[Racc Bug] unknown jump code'
-          end
-        end
-
-      elsif act == shift_n
-        #
-        # accept
-        #
-        racc_accept if @yydebug
-        throw :racc_end_parse, @racc_vstack[0]
-
-      elsif act == -reduce_n
-        #
-        # error
-        #
-        case @racc_error_status
-        when 0
-          unless arg[21]    # user_yyerror
-            nerr += 1
-            on_error @racc_t, @racc_val, @racc_vstack
-          end
-        when 3
-          if @racc_t == 0   # is $
-            throw :racc_end_parse, nil
-          end
-          @racc_read_next = true
-        end
-        @racc_user_yyerror = false
-        @racc_error_status = 3
-        while true
-          if i = action_pointer[@racc_state[-1]]
-            i += 1   # error token
-            if  i >= 0 and
-                (act = action_table[i]) and
-                action_check[i] == @racc_state[-1]
-              break
-            end
-          end
-          throw :racc_end_parse, nil if @racc_state.size <= 1
-          @racc_state.pop
-          @racc_vstack.pop
-          if @yydebug
-            @racc_tstack.pop
-            racc_e_pop @racc_state, @racc_tstack, @racc_vstack
-          end
-        end
-        return act
-
-      else
-        raise "[Racc Bug] unknown action #{act.inspect}"
-      end
-
-      racc_next_state(@racc_state[-1], @racc_state) if @yydebug
-
-      nil
-    end
-
-    def _racc_do_reduce(arg, act)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-      state = @racc_state
-      vstack = @racc_vstack
-      tstack = @racc_tstack
-
-      i = act * -3
-      len       = reduce_table[i]
-      reduce_to = reduce_table[i+1]
-      method_id = reduce_table[i+2]
-      void_array = []
-
-      tmp_t = tstack[-len, len] if @yydebug
-      tmp_v = vstack[-len, len]
-      tstack[-len, len] = void_array if @yydebug
-      vstack[-len, len] = void_array
-      state[-len, len]  = void_array
-
-      # tstack must be updated AFTER method call
-      if use_result
-        vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
-      else
-        vstack.push __send__(method_id, tmp_v, vstack)
-      end
-      tstack.push reduce_to
-
-      racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
-
-      k1 = reduce_to - nt_base
-      if i = goto_pointer[k1]
-        i += state[-1]
-        if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
-          return curstate
-        end
-      end
-      goto_default[k1]
-    end
-
-    def on_error(t, val, vstack)
-      raise ParseError, sprintf("\nparse error on value %s (%s)",
-                                val.inspect, token_to_str(t) || '?')
-    end
-
-    def yyerror
-      throw :racc_jump, 1
-    end
-
-    def yyaccept
-      throw :racc_jump, 2
-    end
-
-    def yyerrok
-      @racc_error_status = 0
-    end
-
-    #
-    # for debugging output
-    #
-
-    def racc_read_token(t, tok, val)
-      @racc_debug_out.print 'read    '
-      @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
-      @racc_debug_out.puts val.inspect
-      @racc_debug_out.puts
-    end
-
-    def racc_shift(tok, tstack, vstack)
-      @racc_debug_out.puts "shift   #{racc_token2str tok}"
-      racc_print_stacks tstack, vstack
-      @racc_debug_out.puts
-    end
-
-    def racc_reduce(toks, sim, tstack, vstack)
-      out = @racc_debug_out
-      out.print 'reduce '
-      if toks.empty?
-        out.print ' <none>'
-      else
-        toks.each {|t| out.print ' ', racc_token2str(t) }
-      end
-      out.puts " --> #{racc_token2str(sim)}"
-          
-      racc_print_stacks tstack, vstack
-      @racc_debug_out.puts
-    end
-
-    def racc_accept
-      @racc_debug_out.puts 'accept'
-      @racc_debug_out.puts
-    end
-
-    def racc_e_pop(state, tstack, vstack)
-      @racc_debug_out.puts 'error recovering mode: pop token'
-      racc_print_states state
-      racc_print_stacks tstack, vstack
-      @racc_debug_out.puts
-    end
-
-    def racc_next_state(curstate, state)
-      @racc_debug_out.puts  "goto    #{curstate}"
-      racc_print_states state
-      @racc_debug_out.puts
-    end
-
-    def racc_print_stacks(t, v)
-      out = @racc_debug_out
-      out.print '        ['
-      t.each_index do |i|
-        out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
-      end
-      out.puts ' ]'
-    end
-
-    def racc_print_states(s)
-      out = @racc_debug_out
-      out.print '        ['
-      s.each {|st| out.print ' ', st }
-      out.puts ' ]'
-    end
-
-    def racc_token2str(tok)
-      self.class::Racc_token_to_s_table[tok] or
-          raise "[Racc Bug] can't convert token #{tok} to string"
-    end
-
-    def token_to_str(t)
-      self.class::Racc_token_to_s_table[t]
-    end
-
-  end
-
-end
-end
-###### racc/parser.rb end
+require 'racc/parser'
 
 
 
@@ -461,8 +12,10 @@
 
 
 module NumRu
-class Units < Racc::Parser
 
+  class Units < Racc::Parser
+
+module_eval <<'..end units.racc modeval..id921bcb696a', 'units.racc', 65
 
 =begin
 = class Node
@@ -3127,6 +2680,7 @@
 	a ** b
     end
 end
+..end units.racc modeval..id921bcb696a
 
 ##### racc 1.4.5 generates ###
 
@@ -3282,101 +2836,142 @@
 
  # reduce 1 omitted
 
+module_eval <<'.,.,', 'units.racc', 9
   def _reduce_2( val, _values)
- yyaccept;
+ val[0]
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 10
   def _reduce_3( val, _values)
  yyerrok
   end
+.,.,
 
  # reduce 4 omitted
 
+module_eval <<'.,.,', 'units.racc', 15
   def _reduce_5( val, _values)
  val[0].shift(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 16
   def _reduce_6( val, _values)
  val[0].shift(val[2])
   end
+.,.,
 
  # reduce 7 omitted
 
  # reduce 8 omitted
 
+module_eval <<'.,.,', 'units.racc', 22
   def _reduce_9( val, _values)
  val[0].mul(val[1])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 23
   def _reduce_10( val, _values)
  val[0].mul(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 24
   def _reduce_11( val, _values)
  val[0].divide(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 25
   def _reduce_12( val, _values)
  val[0].mul(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 26
   def _reduce_13( val, _values)
  val[0].divide(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 30
   def _reduce_14( val, _values)
  NameNode.new(val[0])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 31
   def _reduce_15( val, _values)
  val[0].pow(val[1])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 32
   def _reduce_16( val, _values)
  val[0].pow(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 33
   def _reduce_17( val, _values)
  val[1]
   end
+.,.,
 
  # reduce 18 omitted
 
+module_eval <<'.,.,', 'units.racc', 38
   def _reduce_19( val, _values)
  val[1]
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 42
   def _reduce_20( val, _values)
  NumberNode.new(val[0])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 43
   def _reduce_21( val, _values)
  NumberNode.new(val[0])
   end
+.,.,
 
  # reduce 22 omitted
 
+module_eval <<'.,.,', 'units.racc', 48
   def _reduce_23( val, _values)
  val[1]
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 52
   def _reduce_24( val, _values)
  TimeNode.new(val[0], 0.0, 0)
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 53
   def _reduce_25( val, _values)
  TimeNode.new(val[0], val[1], 0)
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 54
   def _reduce_26( val, _values)
  TimeNode.new(val[0], val[1], val[2])
   end
+.,.,
 
  def _reduce_none( val, _values)
   val[0]
  end
 
-end   # class Units
+  end   # class Units
+
 end   # module NumRu
 
 ####################
@@ -3390,7 +2985,7 @@
   
   puts "=== reduce1 ==="
   
-  assert Units.new('').reduce1.to_s, ""
+  assert Units.new('').reduce1.to_s, "1"
   assert Units.new('m').reduce1.to_s, "m"
   assert Units.new('3').reduce1.to_s, "3"
   assert Units.new('3.14').reduce1.to_s, "3.14"
@@ -3457,25 +3052,30 @@
   assert Units.new('km2').reduce4.to_s, "km2"
   assert Units.new('hours.hour').reduce4.to_s, "hour2"
   assert Units.new('(10)^2').reduce4.to_s, "100"
-  assert Units.new('100/10').reduce4.to_s, "10.0"
-  assert Units.new('(10)^2/100').reduce4.to_s, "1.0"
+  #assert Units.new('100/10').reduce4.to_s, "10.0"
+  assert Units.new('100/10').reduce4.to_s, "10"
+  #assert Units.new('(10)^2/100').reduce4.to_s, "1.0"
+  assert Units.new('(10)^2/100').reduce4.to_s, "1"
   
   puts "=== reduce5 ==="
   
   assert Units.new('km2').reduce5.to_s, "1000000 m2"
-  assert Units.new('(10)^2/100').reduce5.to_s, "1.0"
+  #assert Units.new('(10)^2/100').reduce5.to_s, "1.0"
+  assert Units.new('(10)^2/100').reduce5.to_s, "1"
   
   assert Units.new('hPa').reduce5.to_s, "100 kg.m-1 s-2"
-  assert Units.new('mb').reduce5.to_s, "100.0 kg.m-1 s-2"
+  #assert Units.new('mb').reduce5.to_s, "100.0 kg.m-1 s-2"
+  assert Units.new('mb').reduce5.to_s, "100 kg.m-1 s-2"
   
-  assert Units.new('hPa/mb').reduce5.to_s, "1.0"
+  #assert Units.new('hPa/mb').reduce5.to_s, "1.0"
+  assert Units.new('hPa/mb').reduce5.to_s, "1"
   
   assert Units.new('(K @ 273.15)@ 10').reduce5.to_s, "(K @ 283.15)"
   
   puts "=== APPLICATIONS ==="
   
   assert Units.new('km @ 2').convert(3, Units.new('m @ 100')), 4900
-  assert Units.new('degree_F').convert(32, Units.new('K')).to_s, "273.15"
+  assert Units.new('degree_F').convert(32, Units.new('K')).to_s, ((32+459.67)*(1.8**-1)).to_s
   
   u1 = Units.new('m/s')
   u2 = Units.new('mm/s')
diff -uNr numru-units-1.7_orig/src/Makefile numru-units-1.7/src/Makefile
--- numru-units-1.7_orig/src/Makefile	2011-08-03 18:16:07.000000000 +0900
+++ numru-units-1.7/src/Makefile	2015-01-06 13:29:53.745769402 +0900
@@ -1,10 +1,8 @@
 all: units.rb
 
 units.rb: units.racc
-	racc -E -l units.racc -o tmp.rb
-	(ruby -n -e 'if /^class Units/; print("module NumRu\n",$$_); elsif /end\s*#\s*class\s*Units/; print($$_,"end   # module NumRu\n"); else print $$_; end' tmp.rb > units.rb)
+	racc units.racc -o units.rb
 	(( echo ; echo '####################' ; echo 'if $$0 == __FILE__' ; tail -n +2 test.rb | ruby -p -e 'print "  "' ; echo 'end' )  >> units.rb)
-	@rm tmp.rb
 
 test: units.rb
 	ruby test.rb
diff -uNr numru-units-1.7_orig/src/test.rb numru-units-1.7/src/test.rb
--- numru-units-1.7_orig/src/test.rb	2004-03-01 13:45:28.000000000 +0900
+++ numru-units-1.7/src/test.rb	2015-01-06 13:29:53.745769402 +0900
@@ -8,7 +8,7 @@
 
 puts "=== reduce1 ==="
 
-assert Units.new('').reduce1.to_s, ""
+assert Units.new('').reduce1.to_s, "1"
 assert Units.new('m').reduce1.to_s, "m"
 assert Units.new('3').reduce1.to_s, "3"
 assert Units.new('3.14').reduce1.to_s, "3.14"
@@ -75,25 +75,30 @@
 assert Units.new('km2').reduce4.to_s, "km2"
 assert Units.new('hours.hour').reduce4.to_s, "hour2"
 assert Units.new('(10)^2').reduce4.to_s, "100"
-assert Units.new('100/10').reduce4.to_s, "10.0"
-assert Units.new('(10)^2/100').reduce4.to_s, "1.0"
+#assert Units.new('100/10').reduce4.to_s, "10.0"
+assert Units.new('100/10').reduce4.to_s, "10"
+#assert Units.new('(10)^2/100').reduce4.to_s, "1.0"
+assert Units.new('(10)^2/100').reduce4.to_s, "1"
 
 puts "=== reduce5 ==="
 
 assert Units.new('km2').reduce5.to_s, "1000000 m2"
-assert Units.new('(10)^2/100').reduce5.to_s, "1.0"
+#assert Units.new('(10)^2/100').reduce5.to_s, "1.0"
+assert Units.new('(10)^2/100').reduce5.to_s, "1"
 
 assert Units.new('hPa').reduce5.to_s, "100 kg.m-1 s-2"
-assert Units.new('mb').reduce5.to_s, "100.0 kg.m-1 s-2"
+#assert Units.new('mb').reduce5.to_s, "100.0 kg.m-1 s-2"
+assert Units.new('mb').reduce5.to_s, "100 kg.m-1 s-2"
 
-assert Units.new('hPa/mb').reduce5.to_s, "1.0"
+#assert Units.new('hPa/mb').reduce5.to_s, "1.0"
+assert Units.new('hPa/mb').reduce5.to_s, "1"
 
 assert Units.new('(K @ 273.15)@ 10').reduce5.to_s, "(K @ 283.15)"
 
 puts "=== APPLICATIONS ==="
 
 assert Units.new('km @ 2').convert(3, Units.new('m @ 100')), 4900
-assert Units.new('degree_F').convert(32, Units.new('K')).to_s, "273.15"
+assert Units.new('degree_F').convert(32, Units.new('K')).to_s, ((32+459.67)*(1.8**-1)).to_s
 
 u1 = Units.new('m/s')
 u2 = Units.new('mm/s')
diff -uNr numru-units-1.7_orig/src/units.racc numru-units-1.7/src/units.racc
--- numru-units-1.7_orig/src/units.racc	2011-08-03 18:16:08.000000000 +0900
+++ numru-units-1.7/src/units.racc	2015-01-06 13:29:53.745769402 +0900
@@ -1,4 +1,4 @@
-class Units
+class NumRu::Units
 
   token INT ERR SHIFT SPACE MULTIPLY DIVIDE EXPONENT REAL NAME DATE TIME ZONE
   options no_result_var
@@ -7,7 +7,7 @@
 
 unit_spec:
 	/* { yyaccept; }  */  /* <-- to acccept empty unit_spec */
-	| origin_exp { yyaccept; }
+	| origin_exp { val[0] }
 	| error { yyerrok }
 	;
 
diff -uNr numru-units-1.7_orig/src/units.rb numru-units-1.7/src/units.rb
--- numru-units-1.7_orig/src/units.rb	2011-08-03 18:16:08.000000000 +0900
+++ numru-units-1.7/src/units.rb	2015-01-06 13:29:53.745769402 +0900
@@ -3,457 +3,8 @@
 # This file is automatically generated by racc 1.4.5
 # from racc grammer file "units.racc".
 #
-#
-# tmp.rb: generated by racc (runtime embedded)
-#
-###### racc/parser.rb begin
-unless $".index 'racc/parser.rb'
-$".push 'racc/parser.rb'
-
-#
-# $Id: units.rb,v 1.24 2011-08-03 09:16:08 horinout Exp $
-#
-# Copyright (c) 1999-2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-#
-# As a special exception, when this code is copied by Racc
-# into a Racc output file, you may use that output file
-# without restriction.
-#
 
-unless defined?(NotImplementedError)
-  NotImplementedError = NotImplementError
-end
-
-module Racc
-  class ParseError < StandardError; end
-end
-unless defined?(::ParseError)
-  ParseError = Racc::ParseError
-end
-
-module Racc
-
-  unless defined?(Racc_No_Extentions)
-    Racc_No_Extentions = false
-  end
-
-  class Parser
-
-    Racc_Runtime_Version = '1.4.5'
-    Racc_Runtime_Revision = '$Revision: 1.24 $'.split[1]
-
-    Racc_Runtime_Core_Version_R = '1.4.5'
-    Racc_Runtime_Core_Revision_R = '$Revision: 1.24 $'.split[1]
-    begin
-      require 'racc/cparse'
-    # Racc_Runtime_Core_Version_C  = (defined in extention)
-      Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
-      unless new.respond_to?(:_racc_do_parse_c, true)
-        raise LoadError, 'old cparse.so'
-      end
-      if Racc_No_Extentions
-        raise LoadError, 'selecting ruby version of racc runtime core'
-      end
-
-      Racc_Main_Parsing_Routine    = :_racc_do_parse_c
-      Racc_YY_Parse_Method         = :_racc_yyparse_c
-      Racc_Runtime_Core_Version    = Racc_Runtime_Core_Version_C
-      Racc_Runtime_Core_Revision   = Racc_Runtime_Core_Revision_C
-      Racc_Runtime_Type            = 'c'
-    rescue LoadError
-      Racc_Main_Parsing_Routine    = :_racc_do_parse_rb
-      Racc_YY_Parse_Method         = :_racc_yyparse_rb
-      Racc_Runtime_Core_Version    = Racc_Runtime_Core_Version_R
-      Racc_Runtime_Core_Revision   = Racc_Runtime_Core_Revision_R
-      Racc_Runtime_Type            = 'ruby'
-    end
-
-    def Parser.racc_runtime_type
-      Racc_Runtime_Type
-    end
-
-    private
-
-    def _racc_setup
-      @yydebug = false unless self.class::Racc_debug_parser
-      @yydebug = false unless defined?(@yydebug)
-      if @yydebug
-        @racc_debug_out = $stderr unless defined?(@racc_debug_out)
-        @racc_debug_out ||= $stderr
-      end
-      arg = self.class::Racc_arg
-      arg[13] = true if arg.size < 14
-      arg
-    end
-
-    def _racc_init_sysvars
-      @racc_state  = [0]
-      @racc_tstack = []
-      @racc_vstack = []
-
-      @racc_t = nil
-      @racc_val = nil
-
-      @racc_read_next = true
-
-      @racc_user_yyerror = false
-      @racc_error_status = 0
-    end
-
-    ###
-    ### do_parse
-    ###
-
-    def do_parse
-      __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
-    end
-
-    def next_token
-      raise NotImplementedError, "#{self.class}\#next_token is not defined"
-    end
-
-    def _racc_do_parse_rb(arg, in_debug)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-
-      _racc_init_sysvars
-      tok = act = i = nil
-      nerr = 0
-
-      catch(:racc_end_parse) {
-        while true
-          if i = action_pointer[@racc_state[-1]]
-            if @racc_read_next
-              if @racc_t != 0   # not EOF
-                tok, @racc_val = next_token()
-                unless tok      # EOF
-                  @racc_t = 0
-                else
-                  @racc_t = (token_table[tok] or 1)   # error token
-                end
-                racc_read_token(@racc_t, tok, @racc_val) if @yydebug
-                @racc_read_next = false
-              end
-            end
-            i += @racc_t
-            unless i >= 0 and
-                   act = action_table[i] and
-                   action_check[i] == @racc_state[-1]
-              act = action_default[@racc_state[-1]]
-            end
-          else
-            act = action_default[@racc_state[-1]]
-          end
-          while act = _racc_evalact(act, arg)
-            ;
-          end
-        end
-      }
-    end
-
-    ###
-    ### yyparse
-    ###
-
-    def yyparse(recv, mid)
-      __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
-    end
-
-    def _racc_yyparse_rb(recv, mid, arg, c_debug)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-
-      _racc_init_sysvars
-      tok = nil
-      act = nil
-      i = nil
-      nerr = 0
-
-      catch(:racc_end_parse) {
-        until i = action_pointer[@racc_state[-1]]
-          while act = _racc_evalact(action_default[@racc_state[-1]], arg)
-            ;
-          end
-        end
-        recv.__send__(mid) do |tok, val|
-          unless tok
-            @racc_t = 0
-          else
-            @racc_t = (token_table[tok] or 1)   # error token
-          end
-          @racc_val = val
-          @racc_read_next = false
-
-          i += @racc_t
-          unless i >= 0 and
-                 act = action_table[i] and
-                 action_check[i] == @racc_state[-1]
-            act = action_default[@racc_state[-1]]
-          end
-          while act = _racc_evalact(act, arg)
-            ;
-          end
-
-          while not (i = action_pointer[@racc_state[-1]]) or
-                not @racc_read_next or
-                @racc_t == 0   # $
-            unless i and i += @racc_t and
-                   i >= 0 and
-                   act = action_table[i] and
-                   action_check[i] == @racc_state[-1]
-              act = action_default[@racc_state[-1]]
-            end
-            while act = _racc_evalact(act, arg)
-              ;
-            end
-          end
-        end
-      }
-    end
-
-    ###
-    ### common
-    ###
-
-    def _racc_evalact(act, arg)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-      nerr = 0   # tmp
-
-      if act > 0 and act < shift_n
-        #
-        # shift
-        #
-        if @racc_error_status > 0
-          @racc_error_status -= 1 unless @racc_t == 1   # error token
-        end
-        @racc_vstack.push @racc_val
-        @racc_state.push act
-        @racc_read_next = true
-        if @yydebug
-          @racc_tstack.push @racc_t
-          racc_shift @racc_t, @racc_tstack, @racc_vstack
-        end
-
-      elsif act < 0 and act > -reduce_n
-        #
-        # reduce
-        #
-        code = catch(:racc_jump) {
-          @racc_state.push _racc_do_reduce(arg, act)
-          false
-        }
-        if code
-          case code
-          when 1 # yyerror
-            @racc_user_yyerror = true   # user_yyerror
-            return -reduce_n
-          when 2 # yyaccept
-            return shift_n
-          else
-            raise '[Racc Bug] unknown jump code'
-          end
-        end
-
-      elsif act == shift_n
-        #
-        # accept
-        #
-        racc_accept if @yydebug
-        throw :racc_end_parse, @racc_vstack[0]
-
-      elsif act == -reduce_n
-        #
-        # error
-        #
-        case @racc_error_status
-        when 0
-          unless arg[21]    # user_yyerror
-            nerr += 1
-            on_error @racc_t, @racc_val, @racc_vstack
-          end
-        when 3
-          if @racc_t == 0   # is $
-            throw :racc_end_parse, nil
-          end
-          @racc_read_next = true
-        end
-        @racc_user_yyerror = false
-        @racc_error_status = 3
-        while true
-          if i = action_pointer[@racc_state[-1]]
-            i += 1   # error token
-            if  i >= 0 and
-                (act = action_table[i]) and
-                action_check[i] == @racc_state[-1]
-              break
-            end
-          end
-          throw :racc_end_parse, nil if @racc_state.size <= 1
-          @racc_state.pop
-          @racc_vstack.pop
-          if @yydebug
-            @racc_tstack.pop
-            racc_e_pop @racc_state, @racc_tstack, @racc_vstack
-          end
-        end
-        return act
-
-      else
-        raise "[Racc Bug] unknown action #{act.inspect}"
-      end
-
-      racc_next_state(@racc_state[-1], @racc_state) if @yydebug
-
-      nil
-    end
-
-    def _racc_do_reduce(arg, act)
-      action_table, action_check, action_default, action_pointer,
-      goto_table,   goto_check,   goto_default,   goto_pointer,
-      nt_base,      reduce_table, token_table,    shift_n,
-      reduce_n,     use_result,   * = arg
-      state = @racc_state
-      vstack = @racc_vstack
-      tstack = @racc_tstack
-
-      i = act * -3
-      len       = reduce_table[i]
-      reduce_to = reduce_table[i+1]
-      method_id = reduce_table[i+2]
-      void_array = []
-
-      tmp_t = tstack[-len, len] if @yydebug
-      tmp_v = vstack[-len, len]
-      tstack[-len, len] = void_array if @yydebug
-      vstack[-len, len] = void_array
-      state[-len, len]  = void_array
-
-      # tstack must be updated AFTER method call
-      if use_result
-        vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
-      else
-        vstack.push __send__(method_id, tmp_v, vstack)
-      end
-      tstack.push reduce_to
-
-      racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
-
-      k1 = reduce_to - nt_base
-      if i = goto_pointer[k1]
-        i += state[-1]
-        if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
-          return curstate
-        end
-      end
-      goto_default[k1]
-    end
-
-    def on_error(t, val, vstack)
-      raise ParseError, sprintf("\nparse error on value %s (%s)",
-                                val.inspect, token_to_str(t) || '?')
-    end
-
-    def yyerror
-      throw :racc_jump, 1
-    end
-
-    def yyaccept
-      throw :racc_jump, 2
-    end
-
-    def yyerrok
-      @racc_error_status = 0
-    end
-
-    #
-    # for debugging output
-    #
-
-    def racc_read_token(t, tok, val)
-      @racc_debug_out.print 'read    '
-      @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
-      @racc_debug_out.puts val.inspect
-      @racc_debug_out.puts
-    end
-
-    def racc_shift(tok, tstack, vstack)
-      @racc_debug_out.puts "shift   #{racc_token2str tok}"
-      racc_print_stacks tstack, vstack
-      @racc_debug_out.puts
-    end
-
-    def racc_reduce(toks, sim, tstack, vstack)
-      out = @racc_debug_out
-      out.print 'reduce '
-      if toks.empty?
-        out.print ' <none>'
-      else
-        toks.each {|t| out.print ' ', racc_token2str(t) }
-      end
-      out.puts " --> #{racc_token2str(sim)}"
-          
-      racc_print_stacks tstack, vstack
-      @racc_debug_out.puts
-    end
-
-    def racc_accept
-      @racc_debug_out.puts 'accept'
-      @racc_debug_out.puts
-    end
-
-    def racc_e_pop(state, tstack, vstack)
-      @racc_debug_out.puts 'error recovering mode: pop token'
-      racc_print_states state
-      racc_print_stacks tstack, vstack
-      @racc_debug_out.puts
-    end
-
-    def racc_next_state(curstate, state)
-      @racc_debug_out.puts  "goto    #{curstate}"
-      racc_print_states state
-      @racc_debug_out.puts
-    end
-
-    def racc_print_stacks(t, v)
-      out = @racc_debug_out
-      out.print '        ['
-      t.each_index do |i|
-        out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
-      end
-      out.puts ' ]'
-    end
-
-    def racc_print_states(s)
-      out = @racc_debug_out
-      out.print '        ['
-      s.each {|st| out.print ' ', st }
-      out.puts ' ]'
-    end
-
-    def racc_token2str(tok)
-      self.class::Racc_token_to_s_table[tok] or
-          raise "[Racc Bug] can't convert token #{tok} to string"
-    end
-
-    def token_to_str(t)
-      self.class::Racc_token_to_s_table[t]
-    end
-
-  end
-
-end
-end
-###### racc/parser.rb end
+require 'racc/parser'
 
 
 
@@ -461,8 +12,10 @@
 
 
 module NumRu
-class Units < Racc::Parser
 
+  class Units < Racc::Parser
+
+module_eval <<'..end units.racc modeval..id921bcb696a', 'units.racc', 65
 
 =begin
 = class Node
@@ -3127,6 +2680,7 @@
 	a ** b
     end
 end
+..end units.racc modeval..id921bcb696a
 
 ##### racc 1.4.5 generates ###
 
@@ -3282,101 +2836,142 @@
 
  # reduce 1 omitted
 
+module_eval <<'.,.,', 'units.racc', 9
   def _reduce_2( val, _values)
- yyaccept;
+ val[0]
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 10
   def _reduce_3( val, _values)
  yyerrok
   end
+.,.,
 
  # reduce 4 omitted
 
+module_eval <<'.,.,', 'units.racc', 15
   def _reduce_5( val, _values)
  val[0].shift(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 16
   def _reduce_6( val, _values)
  val[0].shift(val[2])
   end
+.,.,
 
  # reduce 7 omitted
 
  # reduce 8 omitted
 
+module_eval <<'.,.,', 'units.racc', 22
   def _reduce_9( val, _values)
  val[0].mul(val[1])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 23
   def _reduce_10( val, _values)
  val[0].mul(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 24
   def _reduce_11( val, _values)
  val[0].divide(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 25
   def _reduce_12( val, _values)
  val[0].mul(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 26
   def _reduce_13( val, _values)
  val[0].divide(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 30
   def _reduce_14( val, _values)
  NameNode.new(val[0])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 31
   def _reduce_15( val, _values)
  val[0].pow(val[1])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 32
   def _reduce_16( val, _values)
  val[0].pow(val[2])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 33
   def _reduce_17( val, _values)
  val[1]
   end
+.,.,
 
  # reduce 18 omitted
 
+module_eval <<'.,.,', 'units.racc', 38
   def _reduce_19( val, _values)
  val[1]
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 42
   def _reduce_20( val, _values)
  NumberNode.new(val[0])
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 43
   def _reduce_21( val, _values)
  NumberNode.new(val[0])
   end
+.,.,
 
  # reduce 22 omitted
 
+module_eval <<'.,.,', 'units.racc', 48
   def _reduce_23( val, _values)
  val[1]
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 52
   def _reduce_24( val, _values)
  TimeNode.new(val[0], 0.0, 0)
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 53
   def _reduce_25( val, _values)
  TimeNode.new(val[0], val[1], 0)
   end
+.,.,
 
+module_eval <<'.,.,', 'units.racc', 54
   def _reduce_26( val, _values)
  TimeNode.new(val[0], val[1], val[2])
   end
+.,.,
 
  def _reduce_none( val, _values)
   val[0]
  end
 
-end   # class Units
+  end   # class Units
+
 end   # module NumRu
 
 ####################
@@ -3390,7 +2985,7 @@
   
   puts "=== reduce1 ==="
   
-  assert Units.new('').reduce1.to_s, ""
+  assert Units.new('').reduce1.to_s, "1"
   assert Units.new('m').reduce1.to_s, "m"
   assert Units.new('3').reduce1.to_s, "3"
   assert Units.new('3.14').reduce1.to_s, "3.14"
@@ -3457,25 +3052,30 @@
   assert Units.new('km2').reduce4.to_s, "km2"
   assert Units.new('hours.hour').reduce4.to_s, "hour2"
   assert Units.new('(10)^2').reduce4.to_s, "100"
-  assert Units.new('100/10').reduce4.to_s, "10.0"
-  assert Units.new('(10)^2/100').reduce4.to_s, "1.0"
+  #assert Units.new('100/10').reduce4.to_s, "10.0"
+  assert Units.new('100/10').reduce4.to_s, "10"
+  #assert Units.new('(10)^2/100').reduce4.to_s, "1.0"
+  assert Units.new('(10)^2/100').reduce4.to_s, "1"
   
   puts "=== reduce5 ==="
   
   assert Units.new('km2').reduce5.to_s, "1000000 m2"
-  assert Units.new('(10)^2/100').reduce5.to_s, "1.0"
+  #assert Units.new('(10)^2/100').reduce5.to_s, "1.0"
+  assert Units.new('(10)^2/100').reduce5.to_s, "1"
   
   assert Units.new('hPa').reduce5.to_s, "100 kg.m-1 s-2"
-  assert Units.new('mb').reduce5.to_s, "100.0 kg.m-1 s-2"
+  #assert Units.new('mb').reduce5.to_s, "100.0 kg.m-1 s-2"
+  assert Units.new('mb').reduce5.to_s, "100 kg.m-1 s-2"
   
-  assert Units.new('hPa/mb').reduce5.to_s, "1.0"
+  #assert Units.new('hPa/mb').reduce5.to_s, "1.0"
+  assert Units.new('hPa/mb').reduce5.to_s, "1"
   
   assert Units.new('(K @ 273.15)@ 10').reduce5.to_s, "(K @ 283.15)"
   
   puts "=== APPLICATIONS ==="
   
   assert Units.new('km @ 2').convert(3, Units.new('m @ 100')), 4900
-  assert Units.new('degree_F').convert(32, Units.new('K')).to_s, "273.15"
+  assert Units.new('degree_F').convert(32, Units.new('K')).to_s, ((32+459.67)*(1.8**-1)).to_s
   
   u1 = Units.new('m/s')
   u2 = Units.new('mm/s')