rley 0.1.03 → 0.1.04

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDY5YjhjZjdmMGRlZTVhYzk4NWI1NjlkNTQ4N2MzMDMwZjEyMmRhYg==
4
+ MDA0YWZhMTI1Mzk3NDdlMTkyNTlmNzQ1ZDEzYzAwNWYxMzM3NjQwZA==
5
5
  data.tar.gz: !binary |-
6
- ZjM3OTdhY2VhMzhjYzA5ZDMwYzQyNDM5ZjIxZGJmNzMyMjljMGU1ZQ==
6
+ YzU1N2ZkZDQ2ZjRkMTVjZTc5YjE1NTViOGQ5NTgzNGM2YWExZDQxNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Mzg2MjBhOTllMWUwMjZiN2U0YWE3MGMwNzg5MGJmZmJhNzcyN2UyNDk5NDdh
10
- YjgwYmRlMDBhODQwZTAyYmU2ZWVkZTlhZTVlZjUxNzJmMzM4ZDYwOWUwNGM2
11
- ZjEzZDMwYjk2Y2Y5MGVhYTk2Mzg4MGY5NDNkOThiOTg2NmViMzM=
9
+ NjBjYWQ5MDk4NmMwMjlhNjEzOWI5ZWY2MzIwMmFiZDk2MTBmMWQ5YzBlOGZi
10
+ MjZhNDU1OWZmZWY0YjA4NjAyMmM5NDM4ZTA3ZTdmYTdmNTc3MjQ1YzQzNzZl
11
+ ZDk1M2RjNjQ1MDQ5NTViZTQ3NjY1OTVkZmRjZTVkNmVhMzU2ZjI=
12
12
  data.tar.gz: !binary |-
13
- NGZhM2RmYmQzYzZlMGMzZjQ3MWRlNGZmOGRlMzUyMGYwOWI2NjVkZWQzOThm
14
- NDg3OWU4MmMyNmVhNzBkMmZlZTEwYWU1MTE0YjA4YjQxZjJiOWJiNjc2ZTFk
15
- MGE2YWJlZDEzMDNkZDMxNTEyYzU5MDg0YTgzNGJjMGFmMDY2Y2Q=
13
+ ODExMjQ0NmUwMGQ2YmY1ZTY5NzZhOGQ4MGFmZmUxN2YwY2ZiN2I4MzY1ZDli
14
+ NTVhNmQ0YzI3MDA0NTE2N2Q2YjY4OTc2NzRlOTNiM2Q5ZTViMDE2ZmY5NTIx
15
+ Y2UyNTNmZDViNTFhOWQzM2E5OWQyOTYxY2ZmMzBmMTQ2ZDViZDI=
@@ -1,3 +1,7 @@
1
+ ### 0.1.04 / 2014-12-08
2
+ * [CHANGE] File `parse_tree_visitor_spec.rb`. Added step-by-step test of a parse tree visit.
3
+
4
+
1
5
  ### 0.1.03 / 2014-12-08
2
6
  * [NEW] `ParseTreeVisitor` class. A class that walks through a parse tree.
3
7
  * [NEW] Method `accept` added to `ParseTree`, `TerminalNode`, `NonTerminalNode` classes.
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Rley # Module used as a namespace
5
5
  # The version number of the gem.
6
- Version = '0.1.03'
6
+ Version = '0.1.04'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = "Ruby implementation of the Earley's parsing algorithm"
@@ -111,23 +111,23 @@ module Rley # Open this namespace to avoid module qualifier prefixes
111
111
  # Use doubles/mocks to simulate formatters
112
112
  let(:listener1) { double('fake-subscriber1') }
113
113
  let(:listener2) { double('fake-subscriber2') }
114
-
114
+
115
115
  # Sample non-terminal node
116
- let(:nterm_node) do
116
+ let(:nterm_node) do
117
117
  first_big_a = grm_abc_ptree1.root.children[0]
118
118
  second_big_a = first_big_a.children[1]
119
119
  second_big_a.children[1]
120
120
  end
121
-
121
+
122
122
  # Sample terminal node
123
- let(:term_node) { nterm_node.children[0] }
123
+ let(:term_node) { nterm_node.children[0] }
124
124
 
125
125
  it 'should react to the start_visit_ptree message' do
126
126
  # Notify subscribers when start the visit of the ptree
127
127
  expect(listener1).to receive(:before_ptree).with(grm_abc_ptree1)
128
128
  subject.start_visit_ptree(grm_abc_ptree1)
129
129
  end
130
-
130
+
131
131
  it 'should react to the start_visit_nonterminal message' do
132
132
  # Notify subscribers when start the visit of a non-terminal node
133
133
  expect(listener1).to receive(:before_non_terminal).with(nterm_node)
@@ -143,27 +143,76 @@ module Rley # Open this namespace to avoid module qualifier prefixes
143
143
  expect(listener1).to receive(:after_children).with(nterm_node, children)
144
144
  subject.visit_children(nterm_node)
145
145
  end
146
-
146
+
147
147
  it 'should react to the end_visit_nonterminal message' do
148
148
  # Notify subscribers when ending the visit of a non-terminal node
149
149
  expect(listener1).to receive(:after_non_terminal).with(nterm_node)
150
150
  subject.end_visit_nonterminal(nterm_node)
151
151
  end
152
-
152
+
153
153
  it 'should react to the visit_terminal message' do
154
154
  # Notify subscribers when start & ending the visit of a terminal node
155
155
  expect(listener1).to receive(:before_terminal).with(term_node)
156
156
  expect(listener1).to receive(:after_terminal).with(term_node)
157
157
  subject.visit_terminal(term_node)
158
158
  end
159
-
159
+
160
160
  it 'should react to the end_visit_ptree message' do
161
161
  # Notify subscribers when ending the visit of the ptree
162
162
  expect(listener1).to receive(:after_ptree).with(grm_abc_ptree1)
163
163
  subject.end_visit_ptree(grm_abc_ptree1)
164
164
  end
165
-
165
+
166
166
  it 'should begin the visit when requested' do
167
+ # Reminder: parse tree structure is
168
+ # S[0,5]
169
+ # +- A[0,5]
170
+ # +- a[0,0]
171
+ # +- A[1,4]
172
+ # | +- a[1,1]
173
+ # | +- A[2,3]
174
+ # | | +- b[2,3]
175
+ # | +- c[3,4]
176
+ # +- c[4,5]
177
+ root = grm_abc_ptree1.root
178
+ children = root.children
179
+ big_a_1 = children[0]
180
+ big_a_1_children = big_a_1.children
181
+ big_a_2 = big_a_1_children[1]
182
+ big_a_2_children = big_a_2.children
183
+ big_a_3 = big_a_2_children[1]
184
+ big_a_3_children = big_a_3.children
185
+ expectations = [
186
+ [:before_ptree, [grm_abc_ptree1]],
187
+ [:before_non_terminal, [root]],
188
+ [:before_children, [root, children]],
189
+ [:before_non_terminal , [big_a_1]],
190
+ [:before_children, [big_a_1, big_a_1_children]],
191
+ [:before_terminal, [big_a_1_children[0]]],
192
+ [:after_terminal, [big_a_1_children[0]]],
193
+ [:before_non_terminal, [big_a_2]],
194
+ [:before_children, [big_a_2, big_a_2_children]],
195
+ [:before_terminal, [big_a_2_children[0]]],
196
+ [:after_terminal, [big_a_2_children[0]]],
197
+ [:before_non_terminal, [big_a_3]],
198
+ [:before_children, [big_a_3, big_a_3_children]],
199
+ [:before_terminal, [big_a_3_children[0]]],
200
+ [:after_terminal, [big_a_3_children[0]]],
201
+ [:after_children, [big_a_3, big_a_3_children]],
202
+ [:before_terminal, [big_a_2_children[2]]],
203
+ [:after_terminal, [big_a_2_children[2]]],
204
+ [:after_children, [big_a_2, big_a_2_children]],
205
+ [:before_terminal, [big_a_1_children[2]]],
206
+ [:after_terminal, [big_a_1_children[2]]],
207
+ [:after_children, [big_a_1, big_a_1_children]],
208
+ [:after_children , [root, children]],
209
+ [:after_ptree , [grm_abc_ptree1]]
210
+ ]
211
+ expectations.each do |(msg, args)|
212
+ allow(listener1).to receive(msg).with(*args).ordered
213
+ end
214
+
215
+ # Here we go...
167
216
  subject.start
168
217
  end
169
218
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.03
4
+ version: 0.1.04
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef