hilbert 0.0.2700320 → 0.0.2700400

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e087bccd022bed9dc89823afeeb86a298dcf2aad
4
- data.tar.gz: 7879c3558a6d2f44ce2ac09c8f3bee9df656ee3c
3
+ metadata.gz: aaae59caf189918270514b0f61b45b2a6fd58205
4
+ data.tar.gz: accc47c0dba81a2cd05232171b1d30720c57e16f
5
5
  SHA512:
6
- metadata.gz: f2fa68a1d6aab887c5c746c60273f23571ea539f32a82d15dc0c3484874728d0aabeac4e3d6b66d72f9117b5b8e5274250a86046a8cdddd8547340e4d08bc7bd
7
- data.tar.gz: 41ccc9ffd79d860803743bb4ec8adff3acf97d9a782212e70b576e6b1128483c09dd969468e5fcafd4e186aed13eb7533f9a0b95d85a068146180bc5868e1a8f
6
+ metadata.gz: fff4fc11e9d6afefd44c05e5f10b28e6d150bd37427e7eaea3ab56175e1c06a4960c1ed8fd5d50c9489900728d0b29be672027fa73182b2b37c9c57e7de6dcab
7
+ data.tar.gz: b262a9666e12a6f86e05eaaaad9cf948695219f445502b2dbaf54ad74a29fe1c1cc7e0d206eacdbed229ffdcf280eee13acd9a12410fe43d11227707a58c53c5
@@ -6,11 +6,11 @@ module Hilbert
6
6
  rule(/paradox\?/) { :P_PARAD }
7
7
  rule(/\A.*[A-RT-Z].*\?.*\z/m) { :EVALOGIC }
8
8
  rule(/\A.*[A-RT-Z].*\z/m) { :DEFLOGIC }
9
- rule(/[ \t\f]/)
9
+ rule(/#{SPC}/)
10
10
 
11
- rule(/(\r|\n)+/) { :NULL }
11
+ rule(/#{NLIN}+/) { :NULL }
12
12
 
13
- rule(/[^\(\)\{\}(\n\n)]+/) { :CONT }
13
+ rule(/[^\(\)\{\}(\n\n)]+/) { :UNKNOW }
14
14
  class << self
15
15
  include Tokens
16
16
  def zfc_analysis!
@@ -68,7 +68,7 @@ module Hilbert
68
68
  LSARW = '<-'
69
69
  RDARW = '=>'
70
70
  LDARW = '<='
71
- SPC = / /
71
+ SPC = /[ \t\f\v]/
72
72
  SPCS = / +/
73
73
  NLIN = /(\r|\n)/
74
74
 
@@ -88,6 +88,8 @@ module Hilbert
88
88
 
89
89
  when /:CONT(\d+)/
90
90
  lexed.parsed!(lexed.get_value($1), $1)
91
+ when /:UNKNOW(\d+)/
92
+ raise "#{lexed.get_value($1)} can not be parsed ;("
91
93
  end
92
94
  lexed.squash!(($1.to_i)..($1.to_i+1)) if lexed.token_str =~ /:(?:CONT|R)(\d+):(?:CONT|R)(\d+)/
93
95
  end
@@ -1,3 +1,3 @@
1
1
  module Hilbert
2
- VERSION = '0.0.2700320'
2
+ VERSION = '0.0.2700400'
3
3
  end
data/lib/hilbert/world.rb CHANGED
@@ -8,29 +8,25 @@ module Hilbert
8
8
  class << self
9
9
  def <<(logic_str)
10
10
  @@propositions << to_rb_obj(logic_str)
11
- %|"Defined: #{logic_str} is TRUE"|
11
+ Messanger.define(logic_str)
12
12
  end
13
13
 
14
14
  def impl(logic_str)
15
15
  # HOTFIX: we need to ..
16
- return eval_rslt(logic_str, 'UNDEFINED') if @@propositions.empty?
16
+ return Messanger.evaluate(logic_str, 'UNDEFINED') if @@propositions.empty?
17
+
17
18
  logic = (@@propositions.inject(:*) >= to_rb_obj(logic_str))
18
19
  str = logic.dpll!.to_s
19
20
  case str
20
- when 'TRUE'
21
- eval_rslt(logic_str, 'TRUE')
22
- when 'FALSE'
23
- eval_rslt(logic_str, 'FALSE')
21
+ when 'TRUE' then Messanger.evaluate(logic_str, 'TRUE')
22
+ when 'FALSE' then Messanger.evaluate(logic_str, 'FALSE')
24
23
  else
25
24
  logic = (@@propositions.inject(:*) >= (~to_rb_obj(logic_str)))
26
25
  str = logic.dpll!.to_s
27
26
  case str
28
- when 'TRUE'
29
- eval_rslt(logic_str, 'FALSE')
30
- when 'FALSE'
31
- eval_rslt(logic_str, 'TRUE')
32
- else
33
- eval_rslt(logic_str, 'UNDEFINED')
27
+ when 'TRUE' then Messanger.evaluate(logic_str, 'FALSE')
28
+ when 'FALSE' then Messanger.evaluate(logic_str, 'TRUE')
29
+ else Messanger.evaluate(logic_str, 'UNDEFINED')
34
30
  end
35
31
  end
36
32
  end
@@ -47,13 +43,11 @@ module Hilbert
47
43
  end
48
44
 
49
45
  def paradox?
50
- return %|"FALSE"| if @@propositions.empty?
51
- str = (!!!!!!!(@@propositions.inject(:*) >= (atom(:P) * ~atom(:P)))).to_s
52
- case str
53
- when 'TRUE'
54
- %|"TRUE"|
55
- else
56
- %|"FALSE"|
46
+ return Messanger.tell_false if @@propositions.empty?
47
+
48
+ case (!!!!!!!(@@propositions.inject(:*) >= (atom(:P) * ~atom(:P)))).to_s
49
+ when 'TRUE' then Messanger.tell_true
50
+ else Messanger.tell_false
57
51
  end
58
52
  end
59
53
 
@@ -63,11 +57,26 @@ module Hilbert
63
57
  Parser::WorldParser.execute(lexeds)
64
58
  eval Parser::WorldParser.parsed_srt
65
59
  end
60
+ end
66
61
 
67
- def eval_rslt(logic_str, rslt)
68
- %|"Evaluate: #{logic_str} is #{rslt}"|
69
- end
62
+ module Messanger
63
+ class << self
64
+ def define(logic_str)
65
+ %|"Defined: #{logic_str} is TRUE"|
66
+ end
70
67
 
68
+ def evaluate(logic_str, rslt)
69
+ %|"Evaluate: #{logic_str} is #{rslt}"|
70
+ end
71
+
72
+ def tell_true
73
+ %|"TRUE"|
74
+ end
75
+
76
+ def tell_false
77
+ %|"FALSE"|
78
+ end
79
+ end
71
80
  end
72
81
  end
73
82
  end
data/lib/hilbert.rb CHANGED
@@ -31,5 +31,4 @@ module Hilbert
31
31
  end
32
32
  end
33
33
  end
34
-
35
34
  end
@@ -10,6 +10,9 @@ class TestGeneral < TestInterpreterBase
10
10
  end
11
11
 
12
12
  def test_general
13
+ assert_iq_equal('2', '1 + 1')
14
+ assert_iq_equal('3 / 2', '1 + 1/2')
15
+ assert_iq_equal('1', '1/2 + 1/2')
13
16
  assert_iq_equal('2x', '2x')
14
17
  assert_iq_equal('2x', 'x + x')
15
18
  # assert_iq_equal('xy', 'xy')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hilbert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2700320
4
+ version: 0.0.2700400
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
11
+ date: 2014-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dydx