proinsias 1.0.1 → 1.1.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 +15 -15
- data/lib/proinsias/parser/director.rb +16 -11
- data/lib/proinsias/parser/parser.rb +32 -7
- data/lib/proinsias/parser/scanner.rb +6 -6
- data/lib/proinsias/version.rb +1 -1
- data/proinsias.gemspec +1 -1
- metadata +5 -8
- data/examples/assemblyline.rb +0 -15
- data/examples/director.rb +0 -15
- data/examples/parentheses.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b5403239c4f49400cae27fe6030b3f90537b58491f0a8ece5c10779d8144916
|
|
4
|
+
data.tar.gz: bdbad991e14a84d22be5eeec3011b02119d7e82e78ca7d6cb4e21934c3b5c3f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69f88b67b14ca92c9ce86ecd79a9c751dfa75582f30fd96cbf563ab334aa79a14d88ed4f7a518fffdc84f7260a6f98eadf589834cf91367cb12c3f712511a59d
|
|
7
|
+
data.tar.gz: cb7d80f469d43e72dc743f4ea84a7893cc43fc4e6be43dce644f16bf52055bb404cc9ad913fda44d2ce5a3a554f2d2a6a89c245b43a93d0c50c28b61eda59a13
|
data/Gemfile.lock
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
proinsias (1.0
|
|
5
|
-
moory (~> 1.2.
|
|
4
|
+
proinsias (1.1.0)
|
|
5
|
+
moory (~> 1.2.6)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
10
|
diff-lcs (1.3)
|
|
11
|
-
moory (1.2.
|
|
11
|
+
moory (1.2.6)
|
|
12
12
|
rake (10.5.0)
|
|
13
|
-
rspec (3.
|
|
14
|
-
rspec-core (~> 3.
|
|
15
|
-
rspec-expectations (~> 3.
|
|
16
|
-
rspec-mocks (~> 3.
|
|
17
|
-
rspec-core (3.
|
|
18
|
-
rspec-support (~> 3.
|
|
19
|
-
rspec-expectations (3.
|
|
13
|
+
rspec (3.8.0)
|
|
14
|
+
rspec-core (~> 3.8.0)
|
|
15
|
+
rspec-expectations (~> 3.8.0)
|
|
16
|
+
rspec-mocks (~> 3.8.0)
|
|
17
|
+
rspec-core (3.8.0)
|
|
18
|
+
rspec-support (~> 3.8.0)
|
|
19
|
+
rspec-expectations (3.8.1)
|
|
20
20
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
21
|
-
rspec-support (~> 3.
|
|
22
|
-
rspec-mocks (3.
|
|
21
|
+
rspec-support (~> 3.8.0)
|
|
22
|
+
rspec-mocks (3.8.0)
|
|
23
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
-
rspec-support (~> 3.
|
|
25
|
-
rspec-support (3.
|
|
24
|
+
rspec-support (~> 3.8.0)
|
|
25
|
+
rspec-support (3.8.0)
|
|
26
26
|
|
|
27
27
|
PLATFORMS
|
|
28
28
|
ruby
|
|
@@ -34,4 +34,4 @@ DEPENDENCIES
|
|
|
34
34
|
rspec (~> 3.0)
|
|
35
35
|
|
|
36
36
|
BUNDLED WITH
|
|
37
|
-
1.16.
|
|
37
|
+
1.16.3
|
|
@@ -4,11 +4,9 @@ module Proinsias
|
|
|
4
4
|
class Director
|
|
5
5
|
attr_accessor :consumer, :quarantine
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
fail "Received unexpected particle: #{particle}"
|
|
9
|
-
}
|
|
7
|
+
SKIP = proc {}
|
|
10
8
|
|
|
11
|
-
def initialize(consumer:, quarantine:
|
|
9
|
+
def initialize(consumer:, quarantine:SKIP)
|
|
12
10
|
@consumer = consumer
|
|
13
11
|
@quarantine = quarantine
|
|
14
12
|
end
|
|
@@ -20,24 +18,31 @@ module Proinsias
|
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
def issue(particle)
|
|
23
|
-
|
|
21
|
+
controller.understand?(particle.role) ?
|
|
22
|
+
distribute(particle) :
|
|
23
|
+
withdraw(particle)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def distribute(particle)
|
|
29
|
+
controller.issue(particle.role).tap do |result|
|
|
24
30
|
forward(
|
|
25
31
|
Directive.new(
|
|
26
|
-
particle:
|
|
32
|
+
particle: particle,
|
|
27
33
|
commands: result
|
|
28
34
|
)
|
|
29
35
|
)
|
|
30
|
-
else
|
|
31
|
-
quarantine ?
|
|
32
|
-
quarantine.call(particle) : nil
|
|
33
36
|
end
|
|
34
37
|
end
|
|
35
38
|
|
|
36
|
-
private
|
|
37
|
-
|
|
38
39
|
def forward(directive)
|
|
39
40
|
consumer.call(directive) if consumer
|
|
40
41
|
end
|
|
42
|
+
|
|
43
|
+
def withdraw(particle)
|
|
44
|
+
quarantine.call(particle)
|
|
45
|
+
end
|
|
41
46
|
end
|
|
42
47
|
|
|
43
48
|
Directive = Struct.new(:particle, :commands, keyword_init: true)
|
|
@@ -3,25 +3,49 @@ require_relative './scanner'
|
|
|
3
3
|
require_relative './director'
|
|
4
4
|
|
|
5
5
|
module Proinsias
|
|
6
|
+
module NilExtension
|
|
7
|
+
refine NilClass do
|
|
8
|
+
def to_ast;end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
6
12
|
class Parser
|
|
13
|
+
attr_accessor :consumer, :quarantine
|
|
14
|
+
|
|
15
|
+
using NilExtension
|
|
16
|
+
|
|
7
17
|
def Parser.one_shot(str)
|
|
8
18
|
new.tap { |psr| psr.analyse(str) }
|
|
9
19
|
end
|
|
10
20
|
|
|
21
|
+
SKIP = proc {}
|
|
22
|
+
|
|
23
|
+
def initialize(consumer:nil, quarantine:SKIP)
|
|
24
|
+
@consumer = consumer
|
|
25
|
+
@quarantine = quarantine
|
|
26
|
+
end
|
|
27
|
+
|
|
11
28
|
def analyse(str)
|
|
12
29
|
str.each_char { |c| issue(c) }
|
|
13
30
|
end
|
|
14
31
|
|
|
32
|
+
def issue(char)
|
|
33
|
+
scanner.issue(char)
|
|
34
|
+
forward
|
|
35
|
+
end
|
|
36
|
+
|
|
15
37
|
def ast
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
product.to_ast
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def product
|
|
42
|
+
assembly_line.product
|
|
19
43
|
end
|
|
20
|
-
|
|
44
|
+
|
|
21
45
|
private
|
|
22
46
|
|
|
23
|
-
def
|
|
24
|
-
|
|
47
|
+
def forward
|
|
48
|
+
consumer.call(product) if product && consumer
|
|
25
49
|
end
|
|
26
50
|
|
|
27
51
|
def scanner
|
|
@@ -32,7 +56,8 @@ module Proinsias
|
|
|
32
56
|
|
|
33
57
|
def director
|
|
34
58
|
@director ||= Proinsias::Director.new(
|
|
35
|
-
consumer:
|
|
59
|
+
consumer: assembly_line.method(:issue),
|
|
60
|
+
quarantine: quarantine
|
|
36
61
|
)
|
|
37
62
|
end
|
|
38
63
|
|
|
@@ -6,18 +6,14 @@ module Proinsias
|
|
|
6
6
|
@consumer = consumer
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
def issue(char)
|
|
10
|
-
filter.issue(char)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
9
|
def filter
|
|
14
10
|
@filter ||= Proinsias::Filter.create(
|
|
15
11
|
consumer: method(:forward)
|
|
16
12
|
)
|
|
17
13
|
end
|
|
18
14
|
|
|
19
|
-
def
|
|
20
|
-
|
|
15
|
+
def issue(char)
|
|
16
|
+
filter.issue(char)
|
|
21
17
|
end
|
|
22
18
|
|
|
23
19
|
def forward(glyph)
|
|
@@ -25,5 +21,9 @@ module Proinsias
|
|
|
25
21
|
translate(glyph)
|
|
26
22
|
)
|
|
27
23
|
end
|
|
24
|
+
|
|
25
|
+
def translate(glyph)
|
|
26
|
+
Proinsias::Particle.from_glyph(glyph)
|
|
27
|
+
end
|
|
28
28
|
end
|
|
29
29
|
end
|
data/lib/proinsias/version.rb
CHANGED
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: 1.0
|
|
4
|
+
version: 1.1.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-14 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.2.
|
|
61
|
+
version: 1.2.6
|
|
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.2.
|
|
68
|
+
version: 1.2.6
|
|
69
69
|
description:
|
|
70
70
|
email:
|
|
71
71
|
- adam_grnt@yahoo.co.uk
|
|
@@ -83,9 +83,6 @@ files:
|
|
|
83
83
|
- Rakefile
|
|
84
84
|
- bin/console
|
|
85
85
|
- bin/setup
|
|
86
|
-
- examples/assemblyline.rb
|
|
87
|
-
- examples/director.rb
|
|
88
|
-
- examples/parentheses.rb
|
|
89
86
|
- examples/parser.rb
|
|
90
87
|
- examples/scanner.rb
|
|
91
88
|
- lib/proinsias.rb
|
|
@@ -126,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
123
|
version: '0'
|
|
127
124
|
requirements: []
|
|
128
125
|
rubyforge_project:
|
|
129
|
-
rubygems_version: 2.7.
|
|
126
|
+
rubygems_version: 2.7.7
|
|
130
127
|
signing_key:
|
|
131
128
|
specification_version: 4
|
|
132
129
|
summary: Manipulate formulae of the Propositional Calculus.
|
data/examples/assemblyline.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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/director.rb
DELETED
data/examples/parentheses.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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) ≡ (p ⇒ r)".each_char do |c|
|
|
12
|
-
scanner.issue(c)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
pp assembly_line.product.to_ast
|