maths 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/maths +8 -1
- data/lib/maths/brain.rb +1 -1
- data/lib/maths/calc.y +2 -7
- data/lib/maths/version.rb +1 -1
- data/lib/maths.rb +2 -1
- metadata +1 -1
data/bin/maths
CHANGED
@@ -30,7 +30,14 @@ while command = Readline.readline(prompt, true)
|
|
30
30
|
puts
|
31
31
|
else
|
32
32
|
begin
|
33
|
-
|
33
|
+
result = parser.parse(command)
|
34
|
+
|
35
|
+
if result.frac == 0
|
36
|
+
output = result.to_i.to_s
|
37
|
+
else
|
38
|
+
output = result.to_s("F")
|
39
|
+
end
|
40
|
+
puts "= #{output}"
|
34
41
|
rescue ParseError
|
35
42
|
puts $!
|
36
43
|
end
|
data/lib/maths/brain.rb
CHANGED
data/lib/maths/calc.y
CHANGED
@@ -41,9 +41,9 @@ module Maths
|
|
41
41
|
when /\A[A-Za-z]+[0-9]*/
|
42
42
|
@q.push [:VARIABLE, $&]
|
43
43
|
when /\A\d+\.\d+/
|
44
|
-
@q.push [:FLOAT,
|
44
|
+
@q.push [:FLOAT, BigDecimal.new($&)]
|
45
45
|
when /\A\d+/
|
46
|
-
@q.push [:NUMBER,
|
46
|
+
@q.push [:NUMBER, BigDecimal.new($&)]
|
47
47
|
when /\A.|\n/o
|
48
48
|
s = $&
|
49
49
|
@q.push [s, s]
|
@@ -57,11 +57,6 @@ module Maths
|
|
57
57
|
def next_token
|
58
58
|
@q.shift
|
59
59
|
end
|
60
|
-
|
61
|
-
def assign(val)
|
62
|
-
puts "Assigning: #{val}"
|
63
|
-
val
|
64
|
-
end
|
65
60
|
|
66
61
|
---- footer
|
67
62
|
end
|
data/lib/maths/version.rb
CHANGED
data/lib/maths.rb
CHANGED