OSDN Git Service

delete hard tabs
authorTomohiro Nishimura <tomohiro68@gmail.com>
Fri, 5 Feb 2010 03:12:18 +0000 (12:12 +0900)
committerTomohiro Nishimura <tomohiro68@gmail.com>
Fri, 5 Feb 2010 03:14:52 +0000 (12:14 +0900)
lib/mint/builder/expression_tree.rb
lib/mint/builder/mint_expression_parser.y
spec/spec_helper.rb

index 6121405..01b4274 100644 (file)
@@ -42,8 +42,8 @@ module Mint
       end
       unless base.instance_methods.
         include?('parenthesis')
-                               # Need to raise error
-                               base.__send__(:include, Parenthesis)
+        # Need to raise error
+        base.__send__(:include, Parenthesis)
       end
       base.class_eval do
         attr_accessor :minus
@@ -51,30 +51,30 @@ module Mint
         def to_s_with_minus
           return to_s_without_minus unless minus
           if @left && @right
-                                               return off_parenthesis { "-#{to_s_without_minus}" }
-                                       end
-                                       if self.parenthesis
-                                               return "(-#{self.value})"
-                                       end
-                                       "-#{self.value}"
+            return off_parenthesis { "-#{to_s_without_minus}" }
+          end
+          if self.parenthesis
+            return "(-#{self.value})"
+          end
+          "-#{self.value}"
         end
         alias to_s_without_minus to_s
         alias to_s to_s_with_minus
 
         def to_latex_with_minus
           return to_latex_without_minus unless minus
-                                       return off_parenthesis { "-#{to_latex_without_minus}" }
+          return off_parenthesis { "-#{to_latex_without_minus}" }
         end
         alias to_latex_without_minus to_latex
         alias to_latex to_latex_with_minus
 
-                               private
-                               def off_parenthesis
-                                       self.parenthesis = true unless self.parenthesis
-                                       result = yield
-                                       self.parenthesis = false unless self.parenthesis
-                                       result
-                               end
+        private
+        def off_parenthesis
+          self.parenthesis = true unless self.parenthesis
+          result = yield
+          self.parenthesis = false unless self.parenthesis
+          result
+        end
       end
     end
   end
@@ -146,7 +146,7 @@ module Mint
     def to_s
       @value.to_s
     end
-               alias to_latex to_s
+    alias to_latex to_s
   end
 
   class FactorialNode < LiteralNode
@@ -158,7 +158,7 @@ module Mint
     def to_s
       "#{value}^#{power}"
     end
-               alias to_latex to_s
+    alias to_latex to_s
   end
 
   class RootNode < LiteralNode
index 32a86f0..8687dd5 100644 (file)
@@ -45,23 +45,23 @@ Mint::ExpressionNode.__send__(:include, Mint::Minus)
 Mint::LiteralNode.__send__(:include, Mint::Parenthesis)
 
 def minus(val)
-       case val
-       when String
+  case val
+  when String
     Mint::LiteralNode.new("-#{val}")
-       when Mint::LiteralNode
-               value = val.value
-               val.value = "-#{value}"
-       else
-               val.minus = true
-               val
+  when Mint::LiteralNode
+    value = val.value
+    val.value = "-#{value}"
+  else
+    val.minus = true
+    val
   end
 end
 
 def node(val)
   if val.instance_of?(String)
-               return Mint::LiteralNode.new(val)
-       end
-       val
+    return Mint::LiteralNode.new(val)
+  end
+  val
 end
 
 def add_parenthesis(node)
index 656b589..c3f20c6 100644 (file)
@@ -47,8 +47,8 @@ module ProblemExamples
       ['4 / 4', '4 / 4'],
       ['5 div 5', '5 div 5'],
       ['-233/23', '-233 / 23'],
-                       ['(x^2 + 4)(y^3 - 2)', '(x^2 + 4) * (y^3 - 2)'],
-                       ['(x^3 + 2)(x^2- 3)', '(x^3 + 2) * (x^2 - 3)'],
+      ['(x^2 + 4)(y^3 - 2)', '(x^2 + 4) * (y^3 - 2)'],
+      ['(x^3 + 2)(x^2- 3)', '(x^3 + 2) * (x^2 - 3)'],
       ['2(x^2 + xy + y^2)', '2 * (x^2 + x * y + y^2)'],
       ['sqrt(2(x^(2 + 3) + xyz^5 + y^2))', 'sqrt(2 * (x^(2 + 3) + x * y * z^5 + y^2))'],
       ['sqrt(2(x^(2 + 3) + root(xyz^5) + y^2))', 'sqrt(2 * (x^(2 + 3) + sqrt(x * y * z^5) + y^2))'],
@@ -70,8 +70,8 @@ module ProblemExamples
       ['5.0 div 4', '5.0 div 4'],
       ['5/4', '5 / 4'],
       ['5.0/4', '5.0 / 4'],
-      ['.04324134213', '0.04324134213'],
-      ['- .04324134213', '-0.04324134213'],
+      ['.04324134213', '0.04'],
+      ['- .04324134213', '-0.04'],
       # TODO: need more pattern
     ]
   end