rley 0.7.03 → 0.7.08
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +362 -62
- data/.travis.yml +6 -7
- data/CHANGELOG.md +20 -1
- data/LICENSE.txt +1 -1
- data/README.md +6 -7
- data/Rakefile +2 -0
- data/appveyor.yml +2 -4
- data/examples/NLP/benchmark_pico_en.rb +2 -0
- data/examples/NLP/engtagger.rb +193 -188
- data/examples/NLP/nano_eng/nano_en_demo.rb +2 -0
- data/examples/NLP/nano_eng/nano_grammar.rb +7 -5
- data/examples/NLP/pico_en_demo.rb +2 -0
- data/examples/data_formats/JSON/cli_options.rb +3 -1
- data/examples/data_formats/JSON/json_ast_builder.rb +14 -9
- data/examples/data_formats/JSON/json_ast_nodes.rb +14 -21
- data/examples/data_formats/JSON/json_demo.rb +2 -0
- data/examples/data_formats/JSON/json_grammar.rb +4 -2
- data/examples/data_formats/JSON/json_lexer.rb +10 -8
- data/examples/data_formats/JSON/json_minifier.rb +3 -1
- data/examples/general/calc_iter1/calc_ast_builder.rb +15 -10
- data/examples/general/calc_iter1/calc_ast_nodes.rb +25 -37
- data/examples/general/calc_iter1/calc_demo.rb +2 -0
- data/examples/general/calc_iter1/calc_grammar.rb +4 -2
- data/examples/general/calc_iter1/calc_lexer.rb +8 -4
- data/examples/general/calc_iter1/spec/calculator_spec.rb +7 -5
- data/examples/general/calc_iter2/calc_ast_builder.rb +7 -3
- data/examples/general/calc_iter2/calc_ast_nodes.rb +29 -43
- data/examples/general/calc_iter2/calc_demo.rb +2 -0
- data/examples/general/calc_iter2/calc_grammar.rb +5 -3
- data/examples/general/calc_iter2/calc_lexer.rb +13 -10
- data/examples/general/calc_iter2/spec/calculator_spec.rb +28 -26
- data/examples/general/left.rb +4 -2
- data/examples/general/right.rb +4 -2
- data/lib/rley.rb +2 -0
- data/lib/rley/base/base_parser.rb +2 -0
- data/lib/rley/base/dotted_item.rb +38 -41
- data/lib/rley/base/grm_items_builder.rb +2 -0
- data/lib/rley/constants.rb +5 -3
- data/lib/rley/engine.rb +22 -24
- data/lib/rley/formatter/asciitree.rb +6 -4
- data/lib/rley/formatter/base_formatter.rb +2 -0
- data/lib/rley/formatter/bracket_notation.rb +3 -8
- data/lib/rley/formatter/debug.rb +8 -6
- data/lib/rley/formatter/json.rb +4 -2
- data/lib/rley/gfg/call_edge.rb +3 -1
- data/lib/rley/gfg/edge.rb +7 -5
- data/lib/rley/gfg/end_vertex.rb +4 -6
- data/lib/rley/gfg/epsilon_edge.rb +3 -5
- data/lib/rley/gfg/grm_flow_graph.rb +31 -25
- data/lib/rley/gfg/item_vertex.rb +12 -22
- data/lib/rley/gfg/non_terminal_vertex.rb +6 -4
- data/lib/rley/gfg/return_edge.rb +2 -0
- data/lib/rley/gfg/scan_edge.rb +3 -1
- data/lib/rley/gfg/shortcut_edge.rb +4 -2
- data/lib/rley/gfg/start_vertex.rb +6 -8
- data/lib/rley/gfg/vertex.rb +47 -41
- data/lib/rley/lexical/token.rb +3 -1
- data/lib/rley/lexical/token_range.rb +8 -6
- data/lib/rley/parse_forest_visitor.rb +7 -5
- data/lib/rley/parse_rep/ast_base_builder.rb +11 -11
- data/lib/rley/parse_rep/cst_builder.rb +7 -4
- data/lib/rley/parse_rep/parse_forest_builder.rb +36 -25
- data/lib/rley/parse_rep/parse_forest_factory.rb +5 -3
- data/lib/rley/parse_rep/parse_rep_creator.rb +18 -13
- data/lib/rley/parse_rep/parse_tree_builder.rb +15 -15
- data/lib/rley/parse_rep/parse_tree_factory.rb +27 -25
- data/lib/rley/parse_tree_visitor.rb +3 -1
- data/lib/rley/parser/error_reason.rb +9 -8
- data/lib/rley/parser/gfg_chart.rb +54 -22
- data/lib/rley/parser/gfg_earley_parser.rb +3 -1
- data/lib/rley/parser/gfg_parsing.rb +51 -31
- data/lib/rley/parser/parse_entry.rb +29 -33
- data/lib/rley/parser/parse_entry_set.rb +32 -27
- data/lib/rley/parser/parse_entry_tracker.rb +6 -4
- data/lib/rley/parser/parse_state.rb +18 -21
- data/lib/rley/parser/parse_state_tracker.rb +6 -4
- data/lib/rley/parser/parse_tracer.rb +15 -13
- data/lib/rley/parser/parse_walker_factory.rb +28 -29
- data/lib/rley/parser/state_set.rb +11 -10
- data/lib/rley/ptree/non_terminal_node.rb +10 -6
- data/lib/rley/ptree/parse_tree.rb +6 -4
- data/lib/rley/ptree/parse_tree_node.rb +7 -5
- data/lib/rley/ptree/terminal_node.rb +9 -7
- data/lib/rley/rley_error.rb +12 -10
- data/lib/rley/sppf/alternative_node.rb +8 -6
- data/lib/rley/sppf/composite_node.rb +9 -7
- data/lib/rley/sppf/epsilon_node.rb +5 -3
- data/lib/rley/sppf/leaf_node.rb +5 -3
- data/lib/rley/sppf/non_terminal_node.rb +2 -0
- data/lib/rley/sppf/parse_forest.rb +19 -17
- data/lib/rley/sppf/sppf_node.rb +9 -8
- data/lib/rley/sppf/token_node.rb +5 -3
- data/lib/rley/syntax/grammar.rb +7 -5
- data/lib/rley/syntax/grammar_builder.rb +11 -9
- data/lib/rley/syntax/grm_symbol.rb +8 -6
- data/lib/rley/syntax/literal.rb +2 -0
- data/lib/rley/syntax/non_terminal.rb +11 -15
- data/lib/rley/syntax/production.rb +13 -11
- data/lib/rley/syntax/symbol_seq.rb +10 -10
- data/lib/rley/syntax/terminal.rb +6 -5
- data/lib/rley/syntax/verbatim_symbol.rb +5 -3
- data/lib/support/base_tokenizer.rb +23 -20
- data/spec/rley/base/dotted_item_spec.rb +4 -2
- data/spec/rley/base/grm_items_builder_spec.rb +2 -0
- data/spec/rley/engine_spec.rb +47 -9
- data/spec/rley/formatter/asciitree_spec.rb +11 -9
- data/spec/rley/formatter/bracket_notation_spec.rb +16 -14
- data/spec/rley/formatter/debug_spec.rb +4 -2
- data/spec/rley/formatter/json_spec.rb +5 -3
- data/spec/rley/gfg/call_edge_spec.rb +2 -0
- data/spec/rley/gfg/edge_spec.rb +2 -0
- data/spec/rley/gfg/end_vertex_spec.rb +7 -5
- data/spec/rley/gfg/epsilon_edge_spec.rb +2 -0
- data/spec/rley/gfg/grm_flow_graph_spec.rb +2 -0
- data/spec/rley/gfg/item_vertex_spec.rb +12 -10
- data/spec/rley/gfg/non_terminal_vertex_spec.rb +5 -3
- data/spec/rley/gfg/return_edge_spec.rb +2 -0
- data/spec/rley/gfg/scan_edge_spec.rb +2 -0
- data/spec/rley/gfg/shortcut_edge_spec.rb +3 -1
- data/spec/rley/gfg/start_vertex_spec.rb +7 -5
- data/spec/rley/gfg/vertex_spec.rb +5 -3
- data/spec/rley/lexical/token_range_spec.rb +18 -16
- data/spec/rley/lexical/token_spec.rb +4 -2
- data/spec/rley/parse_forest_visitor_spec.rb +167 -163
- data/spec/rley/parse_rep/ambiguous_parse_spec.rb +46 -44
- data/spec/rley/parse_rep/ast_builder_spec.rb +8 -6
- data/spec/rley/parse_rep/cst_builder_spec.rb +7 -5
- data/spec/rley/parse_rep/groucho_spec.rb +25 -25
- data/spec/rley/parse_rep/parse_forest_builder_spec.rb +28 -26
- data/spec/rley/parse_rep/parse_forest_factory_spec.rb +8 -6
- data/spec/rley/parse_rep/parse_tree_factory_spec.rb +4 -2
- data/spec/rley/parse_tree_visitor_spec.rb +12 -8
- data/spec/rley/parser/error_reason_spec.rb +8 -6
- data/spec/rley/parser/gfg_chart_spec.rb +17 -4
- data/spec/rley/parser/gfg_earley_parser_spec.rb +16 -11
- data/spec/rley/parser/gfg_parsing_spec.rb +41 -252
- data/spec/rley/parser/parse_entry_set_spec.rb +2 -0
- data/spec/rley/parser/parse_entry_spec.rb +21 -19
- data/spec/rley/parser/parse_state_spec.rb +7 -5
- data/spec/rley/parser/parse_tracer_spec.rb +16 -14
- data/spec/rley/parser/parse_walker_factory_spec.rb +10 -8
- data/spec/rley/parser/state_set_spec.rb +24 -22
- data/spec/rley/ptree/non_terminal_node_spec.rb +7 -3
- data/spec/rley/ptree/parse_tree_node_spec.rb +6 -4
- data/spec/rley/ptree/parse_tree_spec.rb +2 -0
- data/spec/rley/ptree/terminal_node_spec.rb +8 -6
- data/spec/rley/sppf/alternative_node_spec.rb +8 -6
- data/spec/rley/sppf/non_terminal_node_spec.rb +5 -3
- data/spec/rley/sppf/token_node_spec.rb +6 -4
- data/spec/rley/support/ambiguous_grammar_helper.rb +5 -4
- data/spec/rley/support/expectation_helper.rb +2 -0
- data/spec/rley/support/grammar_abc_helper.rb +4 -4
- data/spec/rley/support/grammar_ambig01_helper.rb +6 -5
- data/spec/rley/support/grammar_arr_int_helper.rb +6 -5
- data/spec/rley/support/grammar_b_expr_helper.rb +6 -5
- data/spec/rley/support/grammar_helper.rb +2 -0
- data/spec/rley/support/grammar_l0_helper.rb +15 -16
- data/spec/rley/support/grammar_pb_helper.rb +8 -5
- data/spec/rley/support/grammar_sppf_helper.rb +3 -1
- data/spec/rley/syntax/grammar_builder_spec.rb +7 -5
- data/spec/rley/syntax/grammar_spec.rb +8 -6
- data/spec/rley/syntax/grm_symbol_spec.rb +3 -1
- data/spec/rley/syntax/literal_spec.rb +2 -0
- data/spec/rley/syntax/non_terminal_spec.rb +10 -8
- data/spec/rley/syntax/production_spec.rb +15 -13
- data/spec/rley/syntax/symbol_seq_spec.rb +4 -2
- data/spec/rley/syntax/terminal_spec.rb +7 -5
- data/spec/rley/syntax/verbatim_symbol_spec.rb +3 -1
- data/spec/spec_helper.rb +2 -12
- data/spec/support/base_tokenizer_spec.rb +9 -2
- metadata +21 -63
- data/.simplecov +0 -7
- data/Gemfile +0 -8
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
require_relative '../../../lib/rley/syntax/non_terminal'
|
3
5
|
|
@@ -25,7 +27,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
25
27
|
it 'should know the successor vertex' do
|
26
28
|
expect(vertex1).to receive(:shortcut=)
|
27
29
|
expect(vertex1).to receive(:next_symbol).and_return(nt_b_sequence)
|
28
|
-
|
30
|
+
|
29
31
|
expect(subject.successor).to eq(vertex2)
|
30
32
|
end
|
31
33
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
require_relative '../../../lib/rley/syntax/non_terminal'
|
3
5
|
|
@@ -20,12 +22,12 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
20
22
|
expect(subject.label).to eq('.NT')
|
21
23
|
end
|
22
24
|
end # context
|
23
|
-
|
24
|
-
context 'Provided services:' do
|
25
|
+
|
26
|
+
context 'Provided services:' do
|
25
27
|
it 'should provide human-readable representation of itself' do
|
26
|
-
pattern = /^#<Rley::GFG::StartVertex:\d+ label="\.NT"/
|
27
|
-
expect(subject.inspect).to match(pattern)
|
28
|
-
end
|
28
|
+
pattern = /^#<Rley::GFG::StartVertex:\d+ label="\.NT"/
|
29
|
+
expect(subject.inspect).to match(pattern)
|
30
|
+
end
|
29
31
|
end # context
|
30
32
|
end # describe
|
31
33
|
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
|
3
5
|
# Load the class under test
|
@@ -22,10 +24,10 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
22
24
|
it 'should know whether it has a dot at the end of the rhs' do
|
23
25
|
expect(subject).not_to be_complete
|
24
26
|
end
|
25
|
-
|
27
|
+
|
26
28
|
it 'should know the previous symbol (if any) in the rhs' do
|
27
29
|
expect(subject.prev_symbol).to be_nil
|
28
|
-
end
|
30
|
+
end
|
29
31
|
|
30
32
|
it 'should know the next symbol (if any) in the rhs' do
|
31
33
|
expect(subject.next_symbol).to be_nil
|
@@ -38,7 +40,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
38
40
|
expect { subject.add_edge(edge1) }.not_to raise_error
|
39
41
|
expect(subject.edges.size).to eq(1)
|
40
42
|
expect(subject.edges.last).to eq(edge1)
|
41
|
-
|
43
|
+
|
42
44
|
err = StandardError
|
43
45
|
msg = 'At most one edge accepted'
|
44
46
|
expect { subject.add_edge(edge2) }.to raise_error err, msg
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
|
3
5
|
# Load the class under test
|
@@ -25,7 +27,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
25
27
|
# Both bounds provided
|
26
28
|
expect { TokenRange.new(low: 0, high: 5) }.not_to raise_error
|
27
29
|
end
|
28
|
-
|
30
|
+
|
29
31
|
it 'could be created with another TokenRange' do
|
30
32
|
# Low bound provided
|
31
33
|
instance = TokenRange.new(low: 0)
|
@@ -59,7 +61,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
59
61
|
expect(subject == [0, 5]).to eq(true)
|
60
62
|
end
|
61
63
|
|
62
|
-
|
64
|
+
|
63
65
|
it 'should know whether it is bounded or not' do
|
64
66
|
expect(subject).to be_bounded
|
65
67
|
|
@@ -117,50 +119,50 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
117
119
|
expect(instance.low).to eq(1)
|
118
120
|
expect(instance.high).to eq(4)
|
119
121
|
end
|
120
|
-
|
122
|
+
|
121
123
|
it 'should tell whether an index value lies outside the range' do
|
122
124
|
# Out of range...
|
123
125
|
expect(subject.out_of_range?(-1)).to eq(true)
|
124
126
|
expect(subject.out_of_range?(6)).to eq(true)
|
125
|
-
|
127
|
+
|
126
128
|
# On boundaries...
|
127
129
|
expect(subject.out_of_range?(0)).to eq(false)
|
128
130
|
expect(subject.out_of_range?(5)).to eq(false)
|
129
|
-
|
131
|
+
|
130
132
|
# Inside boundaries
|
131
133
|
expect(subject.out_of_range?(2)).to eq(false)
|
132
134
|
|
133
135
|
instance = TokenRange.new(low: nil, high: 5)
|
134
|
-
|
136
|
+
|
135
137
|
# Lower bound is nil
|
136
138
|
expect(instance.out_of_range?(-1)).to eq(false)
|
137
139
|
expect(instance.out_of_range?(5)).to eq(false)
|
138
140
|
expect(instance.out_of_range?(6)).to eq(true)
|
139
|
-
|
141
|
+
|
140
142
|
instance = TokenRange.new(low: 0, high: nil)
|
141
|
-
|
143
|
+
|
142
144
|
# Upper bound is nil
|
143
145
|
expect(instance.out_of_range?(-1)).to eq(true)
|
144
146
|
expect(instance.out_of_range?(0)).to eq(false)
|
145
147
|
expect(instance.out_of_range?(6)).to eq(false)
|
146
148
|
end
|
147
|
-
|
149
|
+
|
148
150
|
it 'should provide a text representation of itself' do
|
149
151
|
# Case 1: not bound is set
|
150
152
|
instance = TokenRange.new({})
|
151
|
-
expect(instance.to_string(0)).to eq('[?, ?]')
|
152
|
-
|
153
|
+
expect(instance.to_string(0)).to eq('[?, ?]')
|
154
|
+
|
153
155
|
# Case: only low bound is set
|
154
156
|
instance = TokenRange.new(low: 0)
|
155
|
-
expect(instance.to_string(0)).to eq('[0, ?]')
|
157
|
+
expect(instance.to_string(0)).to eq('[0, ?]')
|
156
158
|
|
157
159
|
# Case: only upper bound is set
|
158
|
-
instance = TokenRange.new(high: 5)
|
159
|
-
expect(instance.to_string(0)).to eq('[?, 5]')
|
160
|
+
instance = TokenRange.new(high: 5)
|
161
|
+
expect(instance.to_string(0)).to eq('[?, 5]')
|
160
162
|
|
161
163
|
# Case: both bounds are set
|
162
|
-
instance = TokenRange.new(low: 0, high: 5)
|
163
|
-
expect(instance.to_string(0)).to eq('[0, 5]')
|
164
|
+
instance = TokenRange.new(low: 0, high: 5)
|
165
|
+
expect(instance.to_string(0)).to eq('[0, 5]')
|
164
166
|
end
|
165
167
|
end
|
166
168
|
end # describe
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
|
3
5
|
require_relative '../../../lib/rley/syntax/terminal'
|
@@ -27,10 +29,10 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
27
29
|
it 'should know its terminal' do
|
28
30
|
expect(subject.terminal).to eq(a_terminal)
|
29
31
|
end
|
30
|
-
|
32
|
+
|
31
33
|
it 'should know its terminal' do
|
32
34
|
expect(subject.position).to eq(a_pos)
|
33
|
-
end
|
35
|
+
end
|
34
36
|
end # context
|
35
37
|
end # describe
|
36
38
|
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../spec_helper'
|
2
4
|
|
3
5
|
require_relative './support/grammar_helper'
|
@@ -96,6 +98,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
96
98
|
end
|
97
99
|
end # context
|
98
100
|
|
101
|
+
# rubocop: disable Lint/ConstantDefinitionInBlock
|
99
102
|
class EventDispatcher
|
100
103
|
# return [Array<Proc>]
|
101
104
|
attr_accessor(:expectations)
|
@@ -123,6 +126,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
123
126
|
@event_count += 1
|
124
127
|
end
|
125
128
|
end # class
|
129
|
+
# rubocop: enable Lint/ConstantDefinitionInBlock
|
126
130
|
|
127
131
|
context 'Notifying visit events:' do
|
128
132
|
# expectations [Array<Array<Symbol, String>>]
|
@@ -159,329 +163,329 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
159
163
|
# Notify subscribers when start the visit of the pforest
|
160
164
|
# expect(listener1).to receive(:before_pforest).with(forest_root)
|
161
165
|
checker.expectations = [
|
162
|
-
|
166
|
+
lambda do |event, item|
|
163
167
|
check_event(event, item, [:before_pforest, grm_sppf_pforest1])
|
164
|
-
|
165
|
-
|
168
|
+
end,
|
169
|
+
lambda do |event, item|
|
166
170
|
check_event(event, item, [:before_non_terminal, 'Phi[0, 4]'])
|
167
|
-
|
168
|
-
|
171
|
+
end,
|
172
|
+
lambda do |event, parent, children|
|
169
173
|
check_event(event, parent, [:before_subnodes, 'Phi[0, 4]'])
|
170
174
|
expect(children.size).to eq(1)
|
171
|
-
|
172
|
-
|
175
|
+
end,
|
176
|
+
lambda do |event, item|
|
173
177
|
check_event(event, item, [:before_non_terminal, 'S[0, 4]'])
|
174
178
|
check_legs(['S[0, 4]', 2]) # 2
|
175
179
|
check_node_accesses(item, [2])
|
176
|
-
|
177
|
-
|
180
|
+
end,
|
181
|
+
lambda do |event, parent, children|
|
178
182
|
check_event(event, parent, [:before_subnodes, 'S[0, 4]'])
|
179
183
|
expect(children.size).to eq(2)
|
180
|
-
|
181
|
-
|
184
|
+
end,
|
185
|
+
lambda do |event, item|
|
182
186
|
prediction = 'Alt(S => a T .)[0, 4]'
|
183
187
|
check_event(event, item, [:before_alternative, prediction])
|
184
188
|
check_legs(['Alt(S => a T .)[0, 4]', 6]) # 2 * 3
|
185
189
|
check_node_accesses(item, [6])
|
186
|
-
|
187
|
-
|
190
|
+
end,
|
191
|
+
lambda do |event, parent, children|
|
188
192
|
prediction = 'Alt(S => a T .)[0, 4]'
|
189
193
|
check_event(event, parent, [:before_subnodes, prediction])
|
190
194
|
expect(children.size).to eq(2)
|
191
|
-
|
192
|
-
|
195
|
+
end,
|
196
|
+
lambda do |event, item|
|
193
197
|
check_event(event, item, [:before_terminal, 'a[0, 1]'])
|
194
|
-
|
195
|
-
|
198
|
+
end,
|
199
|
+
lambda do |event, item|
|
196
200
|
check_event(event, item, [:after_terminal, 'a[0, 1]'])
|
197
|
-
|
198
|
-
|
201
|
+
end,
|
202
|
+
lambda do |event, item|
|
199
203
|
check_event(event, item, [:before_non_terminal, 'T[1, 4]'])
|
200
204
|
check_legs(['T[1, 4]', 66]) # 2 * 3 * 11
|
201
205
|
check_node_accesses(item, [66])
|
202
|
-
|
203
|
-
|
206
|
+
end,
|
207
|
+
lambda do |event, parent, children|
|
204
208
|
check_event(event, parent, [:before_subnodes, 'T[1, 4]'])
|
205
209
|
expect(children.size).to eq(3)
|
206
|
-
|
207
|
-
|
210
|
+
end,
|
211
|
+
lambda do |event, item|
|
208
212
|
check_event(event, item, [:before_terminal, 'b[1, 2]'])
|
209
|
-
|
210
|
-
|
213
|
+
end,
|
214
|
+
lambda do |event, item|
|
211
215
|
check_event(event, item, [:after_terminal, 'b[1, 2]'])
|
212
|
-
|
213
|
-
|
216
|
+
end,
|
217
|
+
lambda do |event, item|
|
214
218
|
check_event(event, item, [:before_terminal, 'b[2, 3]'])
|
215
|
-
|
216
|
-
|
219
|
+
end,
|
220
|
+
lambda do |event, item|
|
217
221
|
check_event(event, item, [:after_terminal, 'b[2, 3]'])
|
218
|
-
|
219
|
-
|
222
|
+
end,
|
223
|
+
lambda do |event, item|
|
220
224
|
check_event(event, item, [:before_terminal, 'b[3, 4]'])
|
221
|
-
|
222
|
-
|
225
|
+
end,
|
226
|
+
lambda do |event, item|
|
223
227
|
check_event(event, item, [:after_terminal, 'b[3, 4]'])
|
224
|
-
|
225
|
-
|
228
|
+
end,
|
229
|
+
lambda do |event, parent, _children|
|
226
230
|
check_event(event, parent, [:after_subnodes, 'T[1, 4]'])
|
227
|
-
|
228
|
-
|
231
|
+
end,
|
232
|
+
lambda do |event, item|
|
229
233
|
check_event(event, item, [:after_non_terminal, 'T[1, 4]'])
|
230
|
-
|
231
|
-
|
234
|
+
end,
|
235
|
+
lambda do |event, parent, children|
|
232
236
|
prediction = 'Alt(S => a T .)[0, 4]'
|
233
237
|
check_event(event, parent, [:after_subnodes, prediction])
|
234
238
|
expect(children.size).to eq(2)
|
235
239
|
check_legs(['Alt(S => a T .)[0, 4]', 6]) # 2 * 3
|
236
|
-
|
237
|
-
|
240
|
+
end,
|
241
|
+
lambda do |event, item|
|
238
242
|
prediction = 'Alt(S => a T .)[0, 4]'
|
239
243
|
check_event(event, item, [:after_alternative, prediction])
|
240
|
-
|
241
|
-
|
244
|
+
end,
|
245
|
+
lambda do |event, item|
|
242
246
|
prediction = 'Alt(S => A T .)[0, 4]'
|
243
247
|
check_event(event, item, [:before_alternative, prediction])
|
244
248
|
check_legs(['Alt(S => A T .)[0, 4]', 10]) # 2 * 5
|
245
249
|
check_node_accesses(item, [10])
|
246
|
-
|
247
|
-
|
250
|
+
end,
|
251
|
+
lambda do |event, parent, children|
|
248
252
|
prediction = 'Alt(S => A T .)[0, 4]'
|
249
253
|
check_event(event, parent, [:before_subnodes, prediction])
|
250
254
|
expect(children.size).to eq(2)
|
251
|
-
|
252
|
-
|
255
|
+
end,
|
256
|
+
lambda do |event, item|
|
253
257
|
check_event(event, item, [:before_non_terminal, 'A[0, 1]'])
|
254
258
|
check_legs(['A[0, 1]', 230]) # 2 * 5 * 23
|
255
259
|
check_node_accesses(item, [230])
|
256
|
-
|
257
|
-
|
260
|
+
end,
|
261
|
+
lambda do |event, parent, children|
|
258
262
|
check_event(event, parent, [:before_subnodes, 'A[0, 1]'])
|
259
263
|
expect(children.size).to eq(2)
|
260
|
-
|
261
|
-
|
264
|
+
end,
|
265
|
+
lambda do |event, item|
|
262
266
|
prediction = 'Alt(A => a .)[0, 1]'
|
263
267
|
check_event(event, item, [:before_alternative, prediction])
|
264
268
|
check_legs(['Alt(A => a .)[0, 1]', 7130]) # 2 * 5 * 23 * 31
|
265
269
|
check_node_accesses(item, [7130])
|
266
270
|
# p(subject.legs)
|
267
|
-
|
268
|
-
|
271
|
+
end,
|
272
|
+
lambda do |event, parent, children|
|
269
273
|
prediction = 'Alt(A => a .)[0, 1]'
|
270
274
|
check_event(event, parent, [:before_subnodes, prediction])
|
271
275
|
expect(children.size).to eq(1)
|
272
|
-
|
273
|
-
|
276
|
+
end,
|
277
|
+
lambda do |event, item|
|
274
278
|
check_event(event, item, [:before_terminal, 'a[0, 1]'])
|
275
|
-
|
276
|
-
|
279
|
+
end,
|
280
|
+
lambda do |event, item|
|
277
281
|
check_event(event, item, [:after_terminal, 'a[0, 1]'])
|
278
|
-
|
279
|
-
|
282
|
+
end,
|
283
|
+
lambda do |event, parent, _children|
|
280
284
|
prediction = 'Alt(A => a .)[0, 1]'
|
281
285
|
check_event(event, parent, [:after_subnodes, prediction])
|
282
286
|
check_legs(['Alt(A => a .)[0, 1]', 7130]) # 2 * 5 * 23 * 31
|
283
|
-
|
284
|
-
|
287
|
+
end,
|
288
|
+
lambda do |event, item|
|
285
289
|
prediction = 'Alt(A => a .)[0, 1]'
|
286
290
|
check_event(event, item, [:after_alternative, prediction])
|
287
|
-
|
288
|
-
|
291
|
+
end,
|
292
|
+
lambda do |event, item|
|
289
293
|
prediction = 'Alt(A => B A .)[0, 1]'
|
290
294
|
check_event(event, item, [:before_alternative, prediction])
|
291
295
|
check_legs(['Alt(A => B A .)[0, 1]', 8510]) # 2 * 5 * 23 * 37
|
292
296
|
check_node_accesses(item, [8510])
|
293
|
-
|
294
|
-
|
297
|
+
end,
|
298
|
+
lambda do |event, parent, children|
|
295
299
|
prediction = 'Alt(A => B A .)[0, 1]'
|
296
300
|
check_event(event, parent, [:before_subnodes, prediction])
|
297
301
|
expect(children.size).to eq(2)
|
298
|
-
|
299
|
-
|
302
|
+
end,
|
303
|
+
lambda do |event, item|
|
300
304
|
check_event(event, item, [:before_non_terminal, 'B[0, 0]'])
|
301
305
|
check_legs(['B[0, 0]', 365930]) # 2 * 5 * 23 * 37 * 43
|
302
306
|
check_node_accesses(item, [365930])
|
303
|
-
|
304
|
-
|
307
|
+
end,
|
308
|
+
lambda do |event, parent, children|
|
305
309
|
check_event(event, parent, [:before_subnodes, 'B[0, 0]'])
|
306
310
|
expect(children.size).to eq(1)
|
307
|
-
|
308
|
-
|
311
|
+
end,
|
312
|
+
lambda do |event, item|
|
309
313
|
check_event(event, item, [:before_epsilon, '_[0, 0]'])
|
310
|
-
|
311
|
-
|
314
|
+
end,
|
315
|
+
lambda do |event, item|
|
312
316
|
check_event(event, item, [:after_epsilon, '_[0, 0]'])
|
313
|
-
|
314
|
-
|
317
|
+
end,
|
318
|
+
lambda do |event, parent, _children|
|
315
319
|
check_event(event, parent, [:after_subnodes, 'B[0, 0]'])
|
316
320
|
check_legs(['B[0, 0]', 365930]) # 2 * 5 * 23 * 37 * 43
|
317
|
-
|
318
|
-
|
321
|
+
end,
|
322
|
+
lambda do |event, item|
|
319
323
|
check_event(event, item, [:after_non_terminal, 'B[0, 0]'])
|
320
|
-
|
321
|
-
|
324
|
+
end,
|
325
|
+
lambda do |event, item|
|
322
326
|
check_event(event, item, [:before_non_terminal, 'A[0, 1]'])
|
323
327
|
check_legs(['A[0, 1]', 399970]) # 2 * 5 * 23 * 37 * 47
|
324
328
|
check_node_accesses(item, [230, 399970])
|
325
|
-
|
326
|
-
|
329
|
+
end,
|
330
|
+
lambda do |event, parent, children|
|
327
331
|
check_event(event, parent, [:before_subnodes, 'A[0, 1]'])
|
328
332
|
expect(children.size).to eq(2)
|
329
|
-
|
330
|
-
|
333
|
+
end,
|
334
|
+
lambda do |event, item|
|
331
335
|
prediction = 'Alt(A => a .)[0, 1]'
|
332
336
|
check_event(event, item, [:before_alternative, prediction])
|
333
337
|
# 12399070 = 2 * 5 * 23 * 37 * 47 * 31
|
334
338
|
check_legs(['Alt(A => a .)[0, 1]', 12399070])
|
335
339
|
check_node_accesses(item, [7130, 12399070])
|
336
|
-
|
337
|
-
|
340
|
+
end,
|
341
|
+
lambda do |event, parent, children|
|
338
342
|
prediction = 'Alt(A => a .)[0, 1]'
|
339
343
|
check_event(event, parent, [:before_subnodes, prediction])
|
340
344
|
expect(children.size).to eq(1)
|
341
|
-
|
342
|
-
|
345
|
+
end,
|
346
|
+
lambda do |event, item|
|
343
347
|
check_event(event, item, [:before_terminal, 'a[0, 1]'])
|
344
|
-
|
345
|
-
|
348
|
+
end,
|
349
|
+
lambda do |event, item|
|
346
350
|
check_event(event, item, [:after_terminal, 'a[0, 1]'])
|
347
|
-
|
348
|
-
|
351
|
+
end,
|
352
|
+
lambda do |event, parent, _children|
|
349
353
|
check_event(event, parent, [:after_subnodes, 'Alt(A => a .)[0, 1]'])
|
350
354
|
# 12399070 = 2 * 5 * 23 * 37 * 47 * 31
|
351
|
-
check_legs(['Alt(A => a .)[0, 1]', 12399070])
|
352
|
-
|
353
|
-
|
355
|
+
check_legs(['Alt(A => a .)[0, 1]', 12399070])
|
356
|
+
end,
|
357
|
+
lambda do |event, item|
|
354
358
|
prediction = 'Alt(A => a .)[0, 1]'
|
355
359
|
check_event(event, item, [:after_alternative, prediction])
|
356
|
-
|
357
|
-
|
360
|
+
end,
|
361
|
+
lambda do |event, item|
|
358
362
|
prediction = 'Alt(A => B A .)[0, 1]'
|
359
363
|
check_event(event, item, [:before_alternative, prediction])
|
360
|
-
# For prime factoring:
|
364
|
+
# For prime factoring:
|
361
365
|
# https://www.calculatorsoup.com/calculators/math/prime-factors.php
|
362
366
|
check_legs(['Alt(A => B A .)[0, 1]', 399970]) # 2 * 5 * 23 * 37 * 47
|
363
367
|
check_node_accesses(item, [8510, 399970])
|
364
|
-
|
365
|
-
|
368
|
+
end,
|
369
|
+
lambda do |event, parent, children|
|
366
370
|
prediction = 'Alt(A => B A .)[0, 1]'
|
367
371
|
check_event(event, parent, [:before_subnodes, prediction])
|
368
372
|
expect(children.size).to eq(2)
|
369
|
-
|
370
|
-
|
373
|
+
end,
|
374
|
+
lambda do |event, item|
|
371
375
|
check_event(event, item, [:before_non_terminal, 'B[0, 0]'])
|
372
376
|
check_legs(['B[0, 0]', 17198710]) # 2 * 5 * 23 * 37 * 47 * 43
|
373
377
|
check_node_accesses(item, [365930, 17198710])
|
374
|
-
|
375
|
-
|
378
|
+
end,
|
379
|
+
lambda do |event, parent, children|
|
376
380
|
check_event(event, parent, [:before_subnodes, 'B[0, 0]'])
|
377
381
|
expect(children.size).to eq(1)
|
378
|
-
|
379
|
-
|
382
|
+
end,
|
383
|
+
lambda do |event, item|
|
380
384
|
check_event(event, item, [:before_epsilon, '_[0, 0]'])
|
381
|
-
|
382
|
-
|
385
|
+
end,
|
386
|
+
lambda do |event, item|
|
383
387
|
check_event(event, item, [:after_epsilon, '_[0, 0]'])
|
384
|
-
|
385
|
-
|
388
|
+
end,
|
389
|
+
lambda do |event, parent, _children|
|
386
390
|
check_event(event, parent, [:after_subnodes, 'B[0, 0]'])
|
387
391
|
check_legs(['B[0, 0]', 17198710]) # 2 * 5 * 23 * 37 * 43 * 47
|
388
|
-
|
389
|
-
|
392
|
+
end,
|
393
|
+
lambda do |event, item|
|
390
394
|
check_event(event, item, [:after_non_terminal, 'B[0, 0]'])
|
391
|
-
|
392
|
-
|
395
|
+
end,
|
396
|
+
lambda do |event, parent, _children|
|
393
397
|
prediction = 'Alt(A => B A .)[0, 1]'
|
394
398
|
check_event(event, parent, [:after_subnodes, prediction])
|
395
399
|
check_legs(['Alt(A => B A .)[0, 1]', 399970]) # 2 * 5 * 23 * 37 * 47
|
396
400
|
check_node_accesses(parent, [8510, 399970])
|
397
|
-
|
398
|
-
|
401
|
+
end,
|
402
|
+
lambda do |event, item|
|
399
403
|
prediction = 'Alt(A => B A .)[0, 1]'
|
400
404
|
check_event(event, item, [:after_alternative, prediction])
|
401
|
-
|
402
|
-
|
405
|
+
end,
|
406
|
+
lambda do |event, parent, _children|
|
403
407
|
check_event(event, parent, [:after_subnodes, 'A[0, 1]'])
|
404
408
|
check_legs(['A[0, 1]', 399970]) # 2 * 5 * 23 * 37 * 47
|
405
|
-
|
406
|
-
|
409
|
+
end,
|
410
|
+
lambda do |event, item|
|
407
411
|
check_event(event, item, [:after_non_terminal, 'A[0, 1]'])
|
408
|
-
|
409
|
-
|
412
|
+
end,
|
413
|
+
lambda do |event, parent, _children|
|
410
414
|
prediction = 'Alt(A => B A .)[0, 1]'
|
411
415
|
check_event(event, parent, [:after_subnodes, prediction])
|
412
416
|
check_legs(['Alt(A => B A .)[0, 1]', 8510]) # 2 * 5 * 23 * 37
|
413
|
-
|
414
|
-
|
417
|
+
end,
|
418
|
+
lambda do |event, item|
|
415
419
|
prediction = 'Alt(A => B A .)[0, 1]'
|
416
420
|
check_event(event, item, [:after_alternative, prediction])
|
417
|
-
|
418
|
-
|
421
|
+
end,
|
422
|
+
lambda do |event, parent, _children|
|
419
423
|
check_event(event, parent, [:after_subnodes, 'A[0, 1]'])
|
420
424
|
check_legs(['A[0, 1]', 230]) # 2 * 5 * 23
|
421
|
-
|
422
|
-
|
425
|
+
end,
|
426
|
+
lambda do |event, item|
|
423
427
|
check_event(event, item, [:after_non_terminal, 'A[0, 1]'])
|
424
|
-
|
425
|
-
|
428
|
+
end,
|
429
|
+
lambda do |event, item|
|
426
430
|
check_event(event, item, [:before_non_terminal, 'T[1, 4]'])
|
427
431
|
check_legs(['T[1, 4]', 290]) # 2 * 5 * 29
|
428
432
|
check_node_accesses(item, [66, 290])
|
429
|
-
|
430
|
-
|
433
|
+
end,
|
434
|
+
lambda do |event, parent, children|
|
431
435
|
check_event(event, parent, [:before_subnodes, 'T[1, 4]'])
|
432
436
|
expect(children.size).to eq(3)
|
433
|
-
|
434
|
-
|
437
|
+
end,
|
438
|
+
lambda do |event, item|
|
435
439
|
check_event(event, item, [:before_terminal, 'b[1, 2]'])
|
436
|
-
|
437
|
-
|
440
|
+
end,
|
441
|
+
lambda do |event, item|
|
438
442
|
check_event(event, item, [:after_terminal, 'b[1, 2]'])
|
439
|
-
|
440
|
-
|
443
|
+
end,
|
444
|
+
lambda do |event, item|
|
441
445
|
check_event(event, item, [:before_terminal, 'b[2, 3]'])
|
442
|
-
|
443
|
-
|
446
|
+
end,
|
447
|
+
lambda do |event, item|
|
444
448
|
check_event(event, item, [:after_terminal, 'b[2, 3]'])
|
445
|
-
|
446
|
-
|
449
|
+
end,
|
450
|
+
lambda do |event, item|
|
447
451
|
check_event(event, item, [:before_terminal, 'b[3, 4]'])
|
448
|
-
|
449
|
-
|
452
|
+
end,
|
453
|
+
lambda do |event, item|
|
450
454
|
check_event(event, item, [:after_terminal, 'b[3, 4]'])
|
451
|
-
|
452
|
-
|
455
|
+
end,
|
456
|
+
lambda do |event, parent, _children|
|
453
457
|
check_event(event, parent, [:after_subnodes, 'T[1, 4]'])
|
454
|
-
|
455
|
-
|
458
|
+
end,
|
459
|
+
lambda do |event, item|
|
456
460
|
check_event(event, item, [:after_non_terminal, 'T[1, 4]'])
|
457
|
-
|
458
|
-
|
461
|
+
end,
|
462
|
+
lambda do |event, parent, children|
|
459
463
|
prediction = 'Alt(S => A T .)[0, 4]'
|
460
464
|
check_event(event, parent, [:after_subnodes, prediction])
|
461
465
|
expect(children.size).to eq(2)
|
462
466
|
check_legs(['Alt(S => A T .)[0, 4]', 10]) # 2 * 5
|
463
|
-
|
464
|
-
|
465
|
-
check_event(
|
466
|
-
|
467
|
-
|
467
|
+
end,
|
468
|
+
lambda do |event, item|
|
469
|
+
check_event(event, item, [:after_alternative, 'Alt(S => A T .)[0, 4]'])
|
470
|
+
end,
|
471
|
+
lambda do |event, parent, children|
|
468
472
|
check_event(event, parent, [:after_subnodes, 'S[0, 4]'])
|
469
473
|
expect(children.size).to eq(2)
|
470
474
|
check_legs(['S[0, 4]', 2]) # 2
|
471
|
-
|
472
|
-
|
475
|
+
end,
|
476
|
+
lambda do |event, item|
|
473
477
|
check_event(event, item, [:after_non_terminal, 'S[0, 4]'])
|
474
|
-
|
475
|
-
|
478
|
+
end,
|
479
|
+
lambda do |event, parent, children|
|
476
480
|
check_event(event, parent, [:after_subnodes, 'Phi[0, 4]'])
|
477
481
|
expect(children.size).to eq(1)
|
478
|
-
|
479
|
-
|
482
|
+
end,
|
483
|
+
lambda do |event, item|
|
480
484
|
check_event(event, item, [:after_non_terminal, 'Phi[0, 4]'])
|
481
|
-
|
482
|
-
|
485
|
+
end,
|
486
|
+
lambda do |event, item|
|
483
487
|
check_event(event, item, [:after_pforest, grm_sppf_pforest1])
|
484
|
-
|
488
|
+
end
|
485
489
|
]
|
486
490
|
subject.start
|
487
491
|
end
|