proinsias 0.4.0 → 0.5.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/examples/parentheses.rb +15 -0
- data/lib/proinsias/director.rb +11 -3
- data/lib/proinsias/particle.rb +33 -0
- data/lib/proinsias/scanner.rb +2 -0
- data/lib/proinsias/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0a4bf173e6cda40f59c1ea516b7b692b364814ba4e99a166a7347ef39abaf0b
|
|
4
|
+
data.tar.gz: bc3e5f35b892ccd4f11b45c6313e27299f1a52a8bf7eb4cdf8b3544e613f094e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52bb28ebce936f928e6d33eabcfb738d085e3b7f41d20e2ee83c47f9d4382905fa2f239348ceeba2242c95e998eaf249c9cabb1650103ddfff1ffa20af5ad7db
|
|
7
|
+
data.tar.gz: 350ab68ec3615c8ff092a02d05d1e97303d1a6163588fe7e3f9a466017b91bb74fb9713d6656f2b64d618f1b668d3bdf2c85dc35b07ab26ed9498b8c43ed2160
|
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
assembly_line = Proinsias::AssemblyLine.new
|
|
2
|
+
|
|
3
|
+
director = Proinsias::Director.new(
|
|
4
|
+
consumer: assembly_line.method(:issue)
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
scanner = Proinsias::Scanner.new(
|
|
8
|
+
consumer: director.method(:issue)
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
"((p ≡ q) ≡ r) ≡ (p ≡ (q ≡ r))".each_char do |c|
|
|
12
|
+
scanner.issue(c)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
pp assembly_line.product.to_ast
|
data/lib/proinsias/director.rb
CHANGED
|
@@ -2,10 +2,15 @@ require 'moory'
|
|
|
2
2
|
|
|
3
3
|
module Proinsias
|
|
4
4
|
class Director
|
|
5
|
-
attr_accessor :consumer
|
|
5
|
+
attr_accessor :consumer, :quarantine
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
DEFAULT_QUARANTINE = proc { |particle|
|
|
8
|
+
fail "Received unexpected particle: #{particle}"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
def initialize(consumer:, quarantine:DEFAULT_QUARANTINE)
|
|
12
|
+
@consumer = consumer
|
|
13
|
+
@quarantine = quarantine
|
|
9
14
|
end
|
|
10
15
|
|
|
11
16
|
def controller
|
|
@@ -22,6 +27,9 @@ module Proinsias
|
|
|
22
27
|
commands: result
|
|
23
28
|
)
|
|
24
29
|
)
|
|
30
|
+
else
|
|
31
|
+
quarantine ?
|
|
32
|
+
quarantine.call(particle) : nil
|
|
25
33
|
end
|
|
26
34
|
end
|
|
27
35
|
|
data/lib/proinsias/particle.rb
CHANGED
|
@@ -85,6 +85,39 @@ module Proinsias
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
class LParen < UnaryOperator
|
|
89
|
+
include Disposition::Pessimistic
|
|
90
|
+
|
|
91
|
+
def initialize(glyph='(')
|
|
92
|
+
super
|
|
93
|
+
@strength = 0
|
|
94
|
+
@role = 'lparen'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def to_ast
|
|
98
|
+
arguments.collect { |a| a.to_ast }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def receive(rparen)
|
|
102
|
+
if rparen.is_a?(Proinsias::Particle::RParen)
|
|
103
|
+
@glyph = '()'
|
|
104
|
+
@received = rparen.received
|
|
105
|
+
else
|
|
106
|
+
fail "Argument is not an RParen" unless rparen.is_a?(Proinsias::Particle::RParen)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
class RParen < UnaryOperator
|
|
112
|
+
include Disposition::Optimistic
|
|
113
|
+
|
|
114
|
+
def initialize(glyph=')')
|
|
115
|
+
super
|
|
116
|
+
@strength = 12
|
|
117
|
+
@role = 'rparen'
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
88
121
|
class Negation < UnaryOperator
|
|
89
122
|
include Disposition::Pessimistic
|
|
90
123
|
|
data/lib/proinsias/scanner.rb
CHANGED
data/lib/proinsias/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: proinsias
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam W. Grant
|
|
@@ -85,6 +85,7 @@ files:
|
|
|
85
85
|
- bin/setup
|
|
86
86
|
- examples/assemblyline.rb
|
|
87
87
|
- examples/director.rb
|
|
88
|
+
- examples/parentheses.rb
|
|
88
89
|
- examples/scanner.rb
|
|
89
90
|
- lib/proinsias.rb
|
|
90
91
|
- lib/proinsias/assembler.rb
|