proinsias 0.2.0 → 0.3.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 +3 -3
- data/examples/assemblyline.rb +15 -0
- data/examples/director.rb +15 -0
- data/examples/scanner.rb +11 -0
- data/lib/proinsias/assembler.rb +21 -11
- data/lib/proinsias/assemblyline.rb +37 -0
- data/lib/proinsias/configurations.rb +30 -0
- data/lib/proinsias/director.rb +36 -0
- data/lib/proinsias/filter.rb +12 -0
- data/lib/proinsias/{operators.rb → particle.rb} +53 -31
- data/lib/proinsias/receiver.rb +39 -13
- data/lib/proinsias/scanner.rb +47 -0
- data/lib/proinsias/version.rb +1 -1
- data/lib/proinsias.rb +6 -4
- data/proinsias.gemspec +1 -1
- metadata +12 -8
- data/lib/proinsias/decoder.rb +0 -68
- data/lib/proinsias/sieve.rb +0 -31
- data/lib/proinsias/token.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2208cb49a3ee68ac0474a3f474f01ab0d58fc5467ab0c8738b50e7fa87338ba9
|
|
4
|
+
data.tar.gz: 651b290b3f896d025a330969db5106b6b1830a38e234371457311b416358094c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d02c436a089a259f9aafcf543044727d95e12fb893b60433cd1debbdef7344cf2ed42e6fa2595f020b04fb3f533f49e57bfa7285efe2387b3287ce92f448eff6
|
|
7
|
+
data.tar.gz: 816d069c3581138e49f694aca3e0b47ea579ddabbedd5e782dff5d95a2086a1b0ee9aa2c8e907b7859b2968be2ff218a170a339020303ebe63d410347b5c5915
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
proinsias (0.
|
|
5
|
-
moory (~> 1.
|
|
4
|
+
proinsias (0.3.0)
|
|
5
|
+
moory (~> 1.2.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
10
|
diff-lcs (1.3)
|
|
11
|
-
moory (1.
|
|
11
|
+
moory (1.2.0)
|
|
12
12
|
rake (10.5.0)
|
|
13
13
|
rspec (3.7.0)
|
|
14
14
|
rspec-core (~> 3.7.0)
|
|
@@ -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 ⇒ s".each_char do |c|
|
|
12
|
+
scanner.issue(c)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
pp assembly_line.product.to_ast
|
data/examples/scanner.rb
ADDED
data/lib/proinsias/assembler.rb
CHANGED
|
@@ -5,24 +5,34 @@ module Proinsias
|
|
|
5
5
|
def feed(incoming)
|
|
6
6
|
receiver ?
|
|
7
7
|
connect(incoming) :
|
|
8
|
-
|
|
8
|
+
establish(incoming)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
look_for_opening(incoming)
|
|
11
|
+
|
|
12
|
+
self
|
|
11
13
|
end
|
|
12
14
|
|
|
15
|
+
private
|
|
16
|
+
|
|
13
17
|
def connect(incoming)
|
|
18
|
+
@receiver = route(incoming)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def route(incoming)
|
|
14
22
|
if opening
|
|
15
23
|
opening.receive(incoming)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
incoming.receive(receiver)
|
|
20
|
-
return @receiver = incoming
|
|
21
|
-
end
|
|
22
|
-
if incoming < receiver
|
|
23
|
-
receiver.absorb(incoming)
|
|
24
|
-
return @receiver
|
|
24
|
+
receiver
|
|
25
|
+
else
|
|
26
|
+
receiver.integrate(incoming)
|
|
25
27
|
end
|
|
26
28
|
end
|
|
29
|
+
|
|
30
|
+
def look_for_opening(incoming)
|
|
31
|
+
@opening = incoming.expectant? ? incoming : nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def establish(incoming)
|
|
35
|
+
@receiver = incoming
|
|
36
|
+
end
|
|
27
37
|
end
|
|
28
38
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Proinsias
|
|
2
|
+
class AssemblyLine
|
|
3
|
+
attr_writer :active
|
|
4
|
+
|
|
5
|
+
def deferrals
|
|
6
|
+
@deferrals ||= []
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def active
|
|
10
|
+
@active ||= Proinsias::Assembler.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def issue(directive)
|
|
14
|
+
if incoming = directive.particle
|
|
15
|
+
active.feed(incoming)
|
|
16
|
+
directive.commands.each { |cmd| send(cmd) }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def defer
|
|
21
|
+
deferrals.push(active)
|
|
22
|
+
@active = nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def reconvene
|
|
26
|
+
tmp = deferrals.pop
|
|
27
|
+
|
|
28
|
+
@active = tmp.feed(active.receiver)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def product
|
|
32
|
+
deferrals.empty? ?
|
|
33
|
+
active.receiver :
|
|
34
|
+
nil
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
module Proinsias
|
|
2
2
|
module Configurations
|
|
3
|
+
FILTER = """
|
|
4
|
+
^ : p / p / produce : ^
|
|
5
|
+
^ : q / q / produce : ^
|
|
6
|
+
^ : r / r / produce : ^
|
|
7
|
+
^ : s / s / produce : ^
|
|
8
|
+
|
|
9
|
+
^ : ¬ / ¬ / produce : ^
|
|
10
|
+
|
|
11
|
+
^ : ≡ / ≡ / produce : ^
|
|
12
|
+
^ : ∧ / ∧ / produce : ^
|
|
13
|
+
^ : ∨ / ∨ / produce : ^
|
|
14
|
+
^ : ⇒ / ⇒ / produce : ^
|
|
15
|
+
^ : ⇐ / ⇐ / produce : ^
|
|
16
|
+
^ : = / = / produce : ^
|
|
17
|
+
|
|
18
|
+
^ : ( / ( / produce : ^
|
|
19
|
+
^ : ) / ) / produce : ^
|
|
20
|
+
|
|
21
|
+
^ : t : 0
|
|
22
|
+
0 : r : 1
|
|
23
|
+
1 : u : 2
|
|
24
|
+
2 : e / true / produce : ^
|
|
25
|
+
|
|
26
|
+
^ : f : 3
|
|
27
|
+
3 : a : 4
|
|
28
|
+
4 : l : 5
|
|
29
|
+
5 : s : 6
|
|
30
|
+
6 : e / false / produce : ^
|
|
31
|
+
"""
|
|
32
|
+
|
|
3
33
|
PIP = # PIP: Prefix Infix Parenthetical
|
|
4
34
|
{
|
|
5
35
|
basis: 'basis',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'moory'
|
|
2
|
+
|
|
3
|
+
module Proinsias
|
|
4
|
+
class Director
|
|
5
|
+
attr_accessor :consumer
|
|
6
|
+
|
|
7
|
+
def initialize(consumer:nil)
|
|
8
|
+
@consumer = consumer
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def controller
|
|
12
|
+
@controller ||= Moory::Logistic::Controller.new(
|
|
13
|
+
Configurations::PIP
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def issue(particle)
|
|
18
|
+
if result = controller.issue(particle.role)
|
|
19
|
+
forward(
|
|
20
|
+
Directive.new(
|
|
21
|
+
particle: particle,
|
|
22
|
+
commands: result
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def forward(directive)
|
|
31
|
+
consumer.call(directive) if consumer
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Directive = Struct.new(:particle, :commands, keyword_init: true)
|
|
36
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Proinsias
|
|
2
|
-
module
|
|
2
|
+
module Disposition
|
|
3
3
|
module Optimistic
|
|
4
4
|
attr_reader :strength
|
|
5
5
|
include Comparable
|
|
@@ -23,10 +23,12 @@ module Proinsias
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
module
|
|
26
|
+
module Particle
|
|
27
27
|
class Atom
|
|
28
28
|
include Receiver
|
|
29
|
-
include
|
|
29
|
+
include Disposition::Pessimistic
|
|
30
|
+
|
|
31
|
+
attr_reader :role
|
|
30
32
|
|
|
31
33
|
def initialize(glyph)
|
|
32
34
|
@glyph = glyph
|
|
@@ -39,12 +41,29 @@ module Proinsias
|
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
42
|
-
Constant
|
|
43
|
-
|
|
44
|
+
class Constant < Atom
|
|
45
|
+
def initialize(glyph)
|
|
46
|
+
super
|
|
47
|
+
@role = 'constant'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class Variable < Atom
|
|
52
|
+
def initialize(glyph)
|
|
53
|
+
super
|
|
54
|
+
@role = 'variable'
|
|
55
|
+
end
|
|
56
|
+
end
|
|
44
57
|
end
|
|
45
58
|
|
|
46
|
-
module
|
|
59
|
+
module Particle
|
|
47
60
|
class Operator
|
|
61
|
+
include Proinsias::Receiver
|
|
62
|
+
|
|
63
|
+
attr_reader :role
|
|
64
|
+
|
|
65
|
+
alias arguments received
|
|
66
|
+
|
|
48
67
|
def to_ast
|
|
49
68
|
{
|
|
50
69
|
@glyph => arguments.collect { |a| a.to_ast }
|
|
@@ -53,8 +72,6 @@ module Proinsias
|
|
|
53
72
|
end
|
|
54
73
|
|
|
55
74
|
class BinaryOperator < Operator
|
|
56
|
-
include Proinsias::Receiver
|
|
57
|
-
|
|
58
75
|
def initialize(glyph)
|
|
59
76
|
@glyph = glyph
|
|
60
77
|
@capacity = 2
|
|
@@ -62,8 +79,6 @@ module Proinsias
|
|
|
62
79
|
end
|
|
63
80
|
|
|
64
81
|
class UnaryOperator < Operator
|
|
65
|
-
include Proinsias::Receiver
|
|
66
|
-
|
|
67
82
|
def initialize(glyph)
|
|
68
83
|
@glyph = glyph
|
|
69
84
|
@capacity = 1
|
|
@@ -71,65 +86,72 @@ module Proinsias
|
|
|
71
86
|
end
|
|
72
87
|
|
|
73
88
|
class Negation < UnaryOperator
|
|
74
|
-
include
|
|
89
|
+
include Disposition::Pessimistic
|
|
75
90
|
|
|
76
|
-
def initialize
|
|
77
|
-
super
|
|
91
|
+
def initialize(glyph='¬')
|
|
92
|
+
super
|
|
78
93
|
@strength = 2
|
|
94
|
+
@role = 'prefix'
|
|
79
95
|
end
|
|
80
96
|
end
|
|
81
97
|
|
|
82
98
|
class Equivalence < BinaryOperator
|
|
83
|
-
include
|
|
99
|
+
include Disposition::Optimistic
|
|
84
100
|
|
|
85
|
-
def initialize
|
|
86
|
-
super
|
|
101
|
+
def initialize(glyph='≡')
|
|
102
|
+
super
|
|
87
103
|
@strength = 12
|
|
104
|
+
@role = 'infix'
|
|
88
105
|
end
|
|
89
106
|
end
|
|
90
107
|
|
|
91
108
|
class Consequence < BinaryOperator
|
|
92
|
-
include
|
|
109
|
+
include Disposition::Optimistic
|
|
93
110
|
|
|
94
|
-
def initialize
|
|
95
|
-
super
|
|
111
|
+
def initialize(glyph='⇐')
|
|
112
|
+
super
|
|
96
113
|
@strength = 11
|
|
114
|
+
@role = 'infix'
|
|
97
115
|
end
|
|
98
116
|
end
|
|
99
117
|
|
|
100
118
|
class Implication < BinaryOperator
|
|
101
|
-
include
|
|
119
|
+
include Disposition::Pessimistic
|
|
102
120
|
|
|
103
|
-
def initialize
|
|
104
|
-
super
|
|
121
|
+
def initialize(glyph='⇒')
|
|
122
|
+
super
|
|
105
123
|
@strength = 11
|
|
124
|
+
@role = 'infix'
|
|
106
125
|
end
|
|
107
126
|
end
|
|
108
127
|
|
|
109
128
|
class Equality < BinaryOperator
|
|
110
|
-
include
|
|
129
|
+
include Disposition::Optimistic
|
|
111
130
|
|
|
112
|
-
def initialize
|
|
113
|
-
super
|
|
131
|
+
def initialize(glyph='=')
|
|
132
|
+
super
|
|
114
133
|
@strength = 9
|
|
134
|
+
@role = 'infix'
|
|
115
135
|
end
|
|
116
136
|
end
|
|
117
137
|
|
|
118
138
|
class Disjunction < BinaryOperator
|
|
119
|
-
include
|
|
139
|
+
include Disposition::Optimistic
|
|
120
140
|
|
|
121
|
-
def initialize
|
|
122
|
-
super
|
|
141
|
+
def initialize(glyph='∨')
|
|
142
|
+
super
|
|
123
143
|
@strength = 10
|
|
144
|
+
@role = 'infix'
|
|
124
145
|
end
|
|
125
146
|
end
|
|
126
147
|
|
|
127
148
|
class Conjunction < BinaryOperator
|
|
128
|
-
include
|
|
149
|
+
include Disposition::Optimistic
|
|
129
150
|
|
|
130
|
-
def initialize
|
|
131
|
-
super
|
|
151
|
+
def initialize(glyph='∧')
|
|
152
|
+
super
|
|
132
153
|
@strength = 10
|
|
154
|
+
@role = 'infix'
|
|
133
155
|
end
|
|
134
156
|
end
|
|
135
157
|
end
|
data/lib/proinsias/receiver.rb
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
module Proinsias
|
|
2
2
|
module Receiver
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
alias nodes received
|
|
6
|
-
alias arguments received
|
|
3
|
+
attr_accessor :received, :capacity, :flexible
|
|
7
4
|
|
|
8
5
|
def received
|
|
9
6
|
@received ||= []
|
|
10
7
|
end
|
|
11
8
|
|
|
12
9
|
def receive(guest)
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
make_room if flexible
|
|
11
|
+
|
|
12
|
+
(
|
|
13
|
+
received << guest
|
|
14
|
+
guest
|
|
15
|
+
) unless full?
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
def capacity
|
|
19
|
+
@capacity ||= 0
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
def full?
|
|
18
23
|
! expectant?
|
|
19
24
|
end
|
|
@@ -22,23 +27,44 @@ module Proinsias
|
|
|
22
27
|
received.count < capacity
|
|
23
28
|
end
|
|
24
29
|
|
|
30
|
+
def make_room(count=1)
|
|
31
|
+
@capacity = expectant? ?
|
|
32
|
+
capacity :
|
|
33
|
+
capacity + count
|
|
34
|
+
end
|
|
35
|
+
|
|
25
36
|
def last
|
|
26
37
|
received.last
|
|
27
38
|
end
|
|
28
39
|
|
|
29
|
-
def
|
|
30
|
-
other >
|
|
40
|
+
def integrate(other)
|
|
41
|
+
if other > self
|
|
42
|
+
other.receive(self)
|
|
43
|
+
return other
|
|
44
|
+
end
|
|
45
|
+
if other < self
|
|
46
|
+
self.insert(other)
|
|
47
|
+
return self
|
|
48
|
+
end
|
|
31
49
|
end
|
|
32
|
-
|
|
33
|
-
def
|
|
50
|
+
|
|
51
|
+
def insert(other)
|
|
34
52
|
accommodates?(other) ?
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
splice(other) :
|
|
54
|
+
last.insert(other)
|
|
37
55
|
end
|
|
38
|
-
|
|
56
|
+
|
|
39
57
|
def splice(other)
|
|
40
58
|
other.receive(received.pop)
|
|
41
59
|
receive(other)
|
|
42
60
|
end
|
|
61
|
+
|
|
62
|
+
def superpose(other)
|
|
63
|
+
received.each { |r| other.receive(r) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def accommodates?(other)
|
|
67
|
+
other > last
|
|
68
|
+
end
|
|
43
69
|
end
|
|
44
70
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Proinsias
|
|
2
|
+
class Scanner
|
|
3
|
+
attr_accessor :consumer
|
|
4
|
+
|
|
5
|
+
def initialize(consumer:)
|
|
6
|
+
@consumer = consumer
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def issue(char)
|
|
10
|
+
filter.issue(char)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def filter
|
|
14
|
+
@filter ||= Proinsias::Filter.create(
|
|
15
|
+
consumer: method(:forward)
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def translate(glyph)
|
|
20
|
+
map = {
|
|
21
|
+
'p' => 'Variable',
|
|
22
|
+
'q' => 'Variable',
|
|
23
|
+
'r' => 'Variable',
|
|
24
|
+
's' => 'Variable',
|
|
25
|
+
'true' => 'Constant',
|
|
26
|
+
'false' => 'Constant',
|
|
27
|
+
'¬' => 'Negation',
|
|
28
|
+
'≡' => 'Equivalence',
|
|
29
|
+
'⇐' => 'Consequence',
|
|
30
|
+
'⇒' => 'Implication',
|
|
31
|
+
'=' => 'Equality',
|
|
32
|
+
'∨' => 'Disjunction',
|
|
33
|
+
'∧' => 'Conjunction',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Proinsias::Particle
|
|
37
|
+
.const_get(map[glyph])
|
|
38
|
+
.send(:new, glyph)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def forward(glyph)
|
|
42
|
+
consumer.call(
|
|
43
|
+
translate(glyph)
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/proinsias/version.rb
CHANGED
data/lib/proinsias.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
require "proinsias/version"
|
|
2
|
-
require "proinsias/
|
|
3
|
-
require "proinsias/decoder"
|
|
2
|
+
require "proinsias/filter"
|
|
4
3
|
require "proinsias/configurations"
|
|
5
|
-
require "proinsias/sieve"
|
|
6
4
|
require "proinsias/receiver"
|
|
7
|
-
require "proinsias/
|
|
5
|
+
require "proinsias/particle"
|
|
6
|
+
require "proinsias/scanner"
|
|
8
7
|
require "proinsias/assembler"
|
|
8
|
+
require "proinsias/director"
|
|
9
|
+
require "proinsias/assemblyline"
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
module Proinsias
|
|
11
13
|
# Your code goes here...
|
data/proinsias.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: proinsias
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam W. Grant
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-08-
|
|
11
|
+
date: 2018-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.
|
|
61
|
+
version: 1.2.0
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 1.
|
|
68
|
+
version: 1.2.0
|
|
69
69
|
description:
|
|
70
70
|
email:
|
|
71
71
|
- adam_grnt@yahoo.co.uk
|
|
@@ -83,14 +83,18 @@ files:
|
|
|
83
83
|
- Rakefile
|
|
84
84
|
- bin/console
|
|
85
85
|
- bin/setup
|
|
86
|
+
- examples/assemblyline.rb
|
|
87
|
+
- examples/director.rb
|
|
88
|
+
- examples/scanner.rb
|
|
86
89
|
- lib/proinsias.rb
|
|
87
90
|
- lib/proinsias/assembler.rb
|
|
91
|
+
- lib/proinsias/assemblyline.rb
|
|
88
92
|
- lib/proinsias/configurations.rb
|
|
89
|
-
- lib/proinsias/
|
|
90
|
-
- lib/proinsias/
|
|
93
|
+
- lib/proinsias/director.rb
|
|
94
|
+
- lib/proinsias/filter.rb
|
|
95
|
+
- lib/proinsias/particle.rb
|
|
91
96
|
- lib/proinsias/receiver.rb
|
|
92
|
-
- lib/proinsias/
|
|
93
|
-
- lib/proinsias/token.rb
|
|
97
|
+
- lib/proinsias/scanner.rb
|
|
94
98
|
- lib/proinsias/version.rb
|
|
95
99
|
- proinsias.gemspec
|
|
96
100
|
homepage: https://github.com/elclavijero/proinsias
|
data/lib/proinsias/decoder.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
require 'moory'
|
|
2
|
-
|
|
3
|
-
module Proinsias
|
|
4
|
-
module Decoder
|
|
5
|
-
RULES = """
|
|
6
|
-
^ : p / variable / produce : ^
|
|
7
|
-
^ : q / variable / produce : ^
|
|
8
|
-
^ : r / variable / produce : ^
|
|
9
|
-
^ : s / variable / produce : ^
|
|
10
|
-
|
|
11
|
-
^ : ¬ / prefix / produce : ^
|
|
12
|
-
|
|
13
|
-
^ : ≡ / infix / produce : ^
|
|
14
|
-
^ : ∧ / infix / produce : ^
|
|
15
|
-
^ : ∨ / infix / produce : ^
|
|
16
|
-
^ : ⇒ / infix / produce : ^
|
|
17
|
-
^ : ⇐ / infix / produce : ^
|
|
18
|
-
|
|
19
|
-
^ : ( / lparen / produce : ^
|
|
20
|
-
^ : ) / rparen / produce : ^
|
|
21
|
-
|
|
22
|
-
^ : t : 0
|
|
23
|
-
0 : r : 1
|
|
24
|
-
1 : u : 2
|
|
25
|
-
2 : e / constant / produce : ^
|
|
26
|
-
|
|
27
|
-
^ : f : 3
|
|
28
|
-
3 : a : 4
|
|
29
|
-
4 : l : 5
|
|
30
|
-
5 : s : 6
|
|
31
|
-
6 : e / constant / produce : ^
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
class Automaton < Moory::Logistic::Unit
|
|
35
|
-
IGNORE = [' ', "\t", "\n"]
|
|
36
|
-
|
|
37
|
-
def initialize(consumer)
|
|
38
|
-
@buffer = ""
|
|
39
|
-
@consumer = consumer
|
|
40
|
-
super(rules: RULES)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def configure(rules)
|
|
44
|
-
super
|
|
45
|
-
repertoire.learn(name: 'produce', item: method(:produce))
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def produce(output)
|
|
49
|
-
@consumer.call(
|
|
50
|
-
Token.new(
|
|
51
|
-
glyph: @buffer,
|
|
52
|
-
role: output
|
|
53
|
-
)
|
|
54
|
-
)
|
|
55
|
-
@buffer = ""
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def issue(stimulus)
|
|
59
|
-
return if IGNORE.include?(stimulus)
|
|
60
|
-
|
|
61
|
-
@buffer << stimulus
|
|
62
|
-
unless success = super(stimulus)
|
|
63
|
-
produce(nil)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
data/lib/proinsias/sieve.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'moory'
|
|
2
|
-
|
|
3
|
-
module Proinsias
|
|
4
|
-
class Sieve
|
|
5
|
-
def initialize(filter:, consumer:, quarantine:nil)
|
|
6
|
-
@consumer = consumer
|
|
7
|
-
@quarantine = quarantine
|
|
8
|
-
@filter = filter
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def issue(token)
|
|
12
|
-
fits?(token) ?
|
|
13
|
-
release(token) :
|
|
14
|
-
quarantine(token)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def fits?(token)
|
|
20
|
-
@filter.issue(token.role)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def release(token)
|
|
24
|
-
@consumer.call(token)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def quarantine(token)
|
|
28
|
-
@quarantine.call(token) if @quarantine
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
data/lib/proinsias/token.rb
DELETED