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