rley 0.2.09 → 0.2.10

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
- MTgzNDQzMWNlYTAwMWNiZjIxZjYxYzBiY2YyZjYyMDE2MjA4NjJkZg==
4
+ YTA0ZWM0OGY5NTM0ZGJhYTYyMDMyOGEyMjk4Mzc0NTMxOWZkZmMxYw==
5
5
  data.tar.gz: !binary |-
6
- YTFjMDBmNWYzYmUwNjI4ZDNiNjczMjNhMTlhZjRjYzhlODUwMWM5Nw==
6
+ OGRhZDdiMzg5ZDA2YTA3YTZiZTBjYWYyOTFkOGJlNTVhNjk5YmVmZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjAwZjQ4YzdmMTMxOTAxY2IxMTQ0N2QzYzI0MWM1ZWIyOGJmNGZjMWE0YzVk
10
- MTZlOGZmZWU2YzhiZmFhN2I5YzU5NGFkNDk0MTY2NjFmNzk4MzBhZWM5NjUz
11
- NDgyODQxNTkzMWFkMGM2OTJhMDYyYWMxMjY1ZjQ0NjZlMjdhNTU=
9
+ NTA0MTBkNzU4ZDdkNmNmOTA5YjBmNTY3Njg4ZDVkZGU5MmMzNzFmZWVlY2Fm
10
+ YzUzZWI4MzU3NmZjYTBmYWQ0NjQzY2QxZjBlMTZlMGIxODY5ZDQ2NTM0ZDRk
11
+ NTdjODAxZjViZmU2MThiNDhkNDEzNGI3MjVkMDg3MDI3ZTIwNTU=
12
12
  data.tar.gz: !binary |-
13
- ZmZlMGNlY2Q1M2E1MzkwMThlNmI0NTEwOTEzNTcxNzZjYWU2MGE0MDQ3ODUz
14
- MjhjYjZjMjQxMGQzZjJkMTYwZDNhNWViMjhmZDk4ZGM1MjFkYjIxNTJkYjBm
15
- MjZkMTE2YzdhYjg0NTRiMzhkZjMzOWVlY2VlMGFlMWU4ZDAxOGM=
13
+ NTFiZGZlZWI2NTU0ZjNmMzlhZjVmZTlkNmM3ZTFmZGFhYmNhYjcwNDQ5Zjdi
14
+ NGRlMjkwZGJjZjMzNDMxOGM3NTIyYTdjNmQzYjQyMGI3ZjdiMDdjMmE5MDkz
15
+ NzI5ZDRmZTQ1Zjg2YjFjYmVhMTJmNGYxZTViNTQzNTRlNjhiNjI=
data/.rubocop.yml CHANGED
@@ -1,83 +1,87 @@
1
- AllCops:
2
- Exclude:
3
- - 'examples/**/*'
4
- - 'features/**/*'
5
- - 'gems/**/*'
6
- - 'refs/**/*'
7
-
8
- AbcSize:
9
- Max: 45
10
- Enabled: true
11
-
12
- # This is disabled because some demos use UTF-8
13
- AsciiComments:
14
- Enabled: false
15
-
16
- BlockComments:
17
- Enabled: false
18
-
19
- CaseIndentation:
20
- IndentWhenRelativeTo: end
21
- IndentOneStep: true
22
-
23
- # Rubocop enforces the use of is_a? instead of kind_of?
24
- # Which is contrary to modelling practice.
25
- ClassCheck:
26
- Enabled: false
27
-
28
- ClassLength:
29
- Max: 250
30
- CountComments: false
31
-
32
- ConstantName:
33
- Enabled: false
34
-
35
- CyclomaticComplexity:
36
- Enabled: false
37
-
38
- DefWithParentheses:
39
- Enabled: false
40
-
41
- Documentation:
42
- Enabled: false
43
-
44
- EmptyLines:
45
- Enabled: false
46
-
47
-
48
- Encoding:
49
- Enabled: false
50
-
51
- FileName:
52
- Enabled: false
53
-
54
- IndentationWidth :
55
- Enabled: false
56
-
57
-
58
- # Avoid methods longer than 50 lines of code
59
- MethodLength:
60
- Max: 50
61
- CountComments: false
62
-
63
- NonNilCheck:
64
- Enabled: false
65
-
66
- NumericLiterals:
67
- Enabled: false
68
-
69
- RaiseArgs:
70
- Enabled: false
71
-
72
- RedundantReturn:
73
- Enabled: false
74
-
75
- SpaceInsideBrackets:
76
- Enabled: false
77
-
78
- TrailingWhitespace:
79
- Enabled: false
80
-
81
- VariableName:
82
- Enabled: false
83
-
1
+ AllCops:
2
+ Exclude:
3
+ - 'examples/**/*'
4
+ - 'features/**/*'
5
+ - 'gems/**/*'
6
+ - 'lab/**/*'
7
+
8
+ AbcSize:
9
+ Max: 35
10
+
11
+ # This is disabled because some demos use UTF-8
12
+ AsciiComments:
13
+ Enabled: false
14
+
15
+ Attr:
16
+ Enabled: false
17
+
18
+ BlockComments:
19
+ Enabled: false
20
+
21
+ CaseIndentation:
22
+ IndentWhenRelativeTo: end
23
+ IndentOneStep: true
24
+
25
+ # Rubocop enforces the use of is_a? instead of kind_of?
26
+ # Which is contrary to modelling practice.
27
+ ClassCheck:
28
+ Enabled: false
29
+
30
+ ClassLength:
31
+ Max: 250
32
+ CountComments: false
33
+
34
+ ConstantName:
35
+ Enabled: false
36
+
37
+ CyclomaticComplexity:
38
+ Enabled: false
39
+
40
+ DefWithParentheses:
41
+ Enabled: false
42
+
43
+ Documentation:
44
+ Enabled: false
45
+
46
+ EmptyLines:
47
+ Enabled: false
48
+
49
+ Encoding:
50
+ Enabled: false
51
+
52
+ IndentationWidth :
53
+ Enabled: false
54
+
55
+
56
+ # Avoid methods longer than 50 lines of code
57
+ MethodLength:
58
+ Max: 50
59
+ CountComments: false
60
+
61
+ # Avoid modules longer than 500 lines of code
62
+ ModuleLength:
63
+ Max: 500
64
+
65
+ NonNilCheck:
66
+ Enabled: false
67
+
68
+ NumericLiterals:
69
+ Enabled: false
70
+
71
+ PerceivedComplexity:
72
+ Max: 10
73
+
74
+ RaiseArgs:
75
+ Enabled: false
76
+
77
+ RedundantReturn:
78
+ Enabled: false
79
+
80
+ SpaceInsideBrackets:
81
+ Enabled: false
82
+
83
+ TrailingWhitespace:
84
+ Enabled: false
85
+
86
+ VariableName:
87
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.2.10 / 2015-06-16
2
+ * [CHANGE] Code re-formatted to please Rubocop 0.32.0
3
+ * [FIX] File `.rubocop.yml`: disable some cop settings that were too loud.
4
+
1
5
  ### 0.2.08 / 2015-04-28
2
6
  * [NEW] Added folder with JSON demo parser under `examples\parsers\demo-JSON`.
3
7
 
@@ -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.2.09'
6
+ Version = '0.2.10'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = "Ruby implementation of the Earley's parsing algorithm"
@@ -1,17 +1,22 @@
1
1
  module Rley # This module is used as a namespace
2
- # A visitor class dedicated in the visit of ParseTree objects.
2
+ # A visitor class dedicated in the visit of a parse tree.
3
+ # It combines the Visitor and Observer patterns.
3
4
  class ParseTreeVisitor
4
5
  # Link to the parse tree to visit
5
6
  attr_reader(:ptree)
6
7
 
7
8
  # List of objects that subscribed to the visit event notification.
8
9
  attr_reader(:subscribers)
10
+
11
+ # Indicates the kind of tree traversal to perform: :post_order, :pre-order
12
+ attr_reader(:traversal)
9
13
 
10
14
  # Build a visitor for the given ptree.
11
15
  # @param aParseTree [ParseTree] the parse tree to visit.
12
- def initialize(aParseTree)
16
+ def initialize(aParseTree, aTraversalStrategy = :post_order)
13
17
  @ptree = aParseTree
14
18
  @subscribers = []
19
+ @traversal = aTraversalStrategy
15
20
  end
16
21
 
17
22
  public
@@ -44,21 +49,15 @@ module Rley # This module is used as a namespace
44
49
 
45
50
  # Visit event. The visitor is about to visit the given non terminal node.
46
51
  # @param aNonTerminalNode [NonTerminalNode] the node to visit.
47
- def start_visit_nonterminal(aNonTerminalNode)
48
- broadcast(:before_non_terminal, aNonTerminalNode)
49
- end
50
-
51
- # Visit event. The visitor is about to visit the children of a non
52
- # terminal node.
53
- # @param aParentNode [NonTeminalNode] the (non-terminal) parent node.
54
- def visit_children(aParentNode)
55
- children = aParentNode.children
56
- broadcast(:before_children, aParentNode, children)
57
-
58
- # Let's proceed with the visit of children
59
- children.each { |a_node| a_node.accept(self) }
60
-
61
- broadcast(:after_children, aParentNode, children)
52
+ def visit_nonterminal(aNonTerminalNode)
53
+ if @traversal == :post_order
54
+ broadcast(:before_non_terminal, aNonTerminalNode)
55
+ traverse_children(aNonTerminalNode)
56
+ else
57
+ traverse_children(aNonTerminalNode)
58
+ broadcast(:before_non_terminal, aNonTerminalNode)
59
+ end
60
+ broadcast(:after_non_terminal, aNonTerminalNode)
62
61
  end
63
62
 
64
63
  # Visit event. The visitor is visiting the
@@ -84,6 +83,19 @@ module Rley # This module is used as a namespace
84
83
  end
85
84
 
86
85
  private
86
+
87
+ # Visit event. The visitor is about to visit the children of a non
88
+ # terminal node.
89
+ # @param aParentNode [NonTeminalNode] the (non-terminal) parent node.
90
+ def traverse_children(aParentNode)
91
+ children = aParentNode.children
92
+ broadcast(:before_children, aParentNode, children)
93
+
94
+ # Let's proceed with the visit of children
95
+ children.each { |a_node| a_node.accept(self) }
96
+
97
+ broadcast(:after_children, aParentNode, children)
98
+ end
87
99
 
88
100
  # Send a notification to all subscribers.
89
101
  # @param msg [Symbol] event to notify
@@ -61,7 +61,7 @@ module Rley # This module is used as a namespace
61
61
  when :completion
62
62
  tracer.trace_completion(anIndex, new_state)
63
63
  else
64
- raise NotImplementedError, "Unknown push_state mode #{aReason}"
64
+ fail NotImplementedError, "Unknown push_state mode #{aReason}"
65
65
  end
66
66
  end
67
67
  end
@@ -216,8 +216,8 @@ module Rley # This module is used as a namespace
216
216
  else
217
217
  err_msg << ": #{term_names[0]},"
218
218
  end
219
- err_msg << " found a '#{aParsing.tokens[pos-1].terminal.name}' instead."
220
- fail StandardError, err_msg
219
+ err_msg << " found a '#{aParsing.tokens[pos - 1].terminal.name}'"
220
+ fail StandardError, err_msg + ' instead.'
221
221
  end
222
222
  end # class
223
223
  end # module
@@ -25,7 +25,7 @@ module Rley # This module is used as a namespace
25
25
 
26
26
  # Write accessor. Set the given parse state as the current one.
27
27
  def parse_state=(aParseState)
28
- fail StandardError, "Nil parse state" if aParseState.nil?
28
+ fail StandardError, 'Nil parse state' if aParseState.nil?
29
29
  @parse_state = aParseState
30
30
  processed_states[parse_state] = true
31
31
  end
@@ -34,9 +34,9 @@ module Rley # This module is used as a namespace
34
34
  def trace_scanning(aStatesetIndex, aParseState)
35
35
  return unless level
36
36
 
37
- scan_picture = '[' + '-' * (col_width-1) + ']'
37
+ scan_picture = '[' + '-' * (col_width - 1) + ']'
38
38
  org = OpenStruct.new(origin: aStatesetIndex - 1,
39
- dotted_rule: aParseState.dotted_rule)
39
+ dotted_rule: aParseState.dotted_rule)
40
40
  trace_diagram(aStatesetIndex, org, scan_picture)
41
41
  end
42
42
 
@@ -49,7 +49,8 @@ module Rley # This module is used as a namespace
49
49
  def trace_completion(aStatesetIndex, aParseState)
50
50
  return unless level
51
51
 
52
- if aStatesetIndex == lexemes.size && aParseState.origin == 0 && aParseState.complete?
52
+ if aStatesetIndex == lexemes.size && aParseState.origin == 0 &&
53
+ aParseState.complete?
53
54
  picture = '=' * (col_width * lexemes.size - 1)
54
55
  else
55
56
  count = col_width * (aStatesetIndex - aParseState.origin) - 1
@@ -69,14 +70,14 @@ module Rley # This module is used as a namespace
69
70
  def emit_heading()
70
71
  longest = lexemes.map(&:length).max
71
72
  @col_width = longest + 3
72
- headers = lexemes.map { |l| "#{l.center(col_width-1, ' ')}" }
73
+ headers = lexemes.map { |l| "#{l.center(col_width - 1, ' ')}" }
73
74
  print_if 1, '|.' + headers.join('.') + ".|\n"
74
75
  end
75
76
 
76
77
  def padding(aStatesetIndex, aParseState, aPicture)
77
- l_pad_pattern = '.' + ' ' * (col_width-1)
78
+ l_pad_pattern = '.' + ' ' * (col_width - 1)
78
79
  left_padding = l_pad_pattern * ([0, aParseState.origin].max)
79
- r_pad_pattern = ' ' * (col_width-1) + '.'
80
+ r_pad_pattern = ' ' * (col_width - 1) + '.'
80
81
  right_padding = r_pad_pattern * (lexemes.size - aStatesetIndex)
81
82
  return left_padding + aPicture + right_padding
82
83
  end
@@ -97,4 +98,4 @@ module Rley # This module is used as a namespace
97
98
  end # module
98
99
  end # module
99
100
 
100
- # End of file
101
+ # End of file
@@ -41,7 +41,8 @@ module Rley # This module is used as a namespace
41
41
  builder = tree_builder(state_tracker.state_set_index)
42
42
 
43
43
  loop do
44
- match_symbol = state_tracker.symbol_on_left
44
+ state_tracker.symbol_on_left
45
+ # match_symbol = state_tracker.symbol_on_left
45
46
  # puts '--------------------'
46
47
  # puts "Active parse state: #{state_tracker.parse_state}"
47
48
  # puts "Matching symbol: #{match_symbol}"
@@ -60,8 +60,8 @@ module Rley # This module is used as a namespace
60
60
  return candidate
61
61
  end
62
62
 
63
- # The list of distinct expected terminal symbols. An expected symbol is on the
64
- # left of a dot in a parse state of the parse set.
63
+ # The list of distinct expected terminal symbols. An expected symbol
64
+ # is on the left of a dot in a parse state of the parse set.
65
65
  def expected_terminals()
66
66
  expecting_terminals = states.select do |s|
67
67
  s.dotted_rule.next_symbol.kind_of?(Rley::Syntax::Terminal)
@@ -32,9 +32,7 @@ module Rley # This module is used as a namespace
32
32
  # Part of the 'visitee' role in Visitor design pattern.
33
33
  # @param aVisitor[ParseTreeVisitor] the visitor
34
34
  def accept(aVisitor)
35
- aVisitor.start_visit_nonterminal(self)
36
- aVisitor.visit_children(self)
37
- aVisitor.end_visit_nonterminal(self)
35
+ aVisitor.visit_nonterminal(self)
38
36
  end
39
37
  end # class
40
38
  end # module
@@ -3,6 +3,14 @@ require_relative 'non_terminal_node'
3
3
 
4
4
  module Rley # This module is used as a namespace
5
5
  module PTree # This module is used as a namespace
6
+ # A parse tree (a.k.a. concrete syntax tree) is a tree-based representation
7
+ # for the parse that corresponds to the input text. In a parse tree,
8
+ # a node corresponds to a grammar symbol used during the parsing:
9
+ # - a leaf node maps to a terminal symbol occurring in
10
+ # the input, and
11
+ # - a intermediate node maps to a non-terminal node reduced
12
+ # during the parse.
13
+ # The root node corresponds to the main/start symbol of the grammar.
6
14
  class ParseTree
7
15
  # The root node of the tree
8
16
  attr_reader(:root)
@@ -128,7 +128,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
128
128
  it 'should react to the start_visit_nonterminal message' do
129
129
  # Notify subscribers when start the visit of a non-terminal node
130
130
  expect(listener1).to receive(:before_non_terminal).with(nterm_node)
131
- subject.start_visit_nonterminal(nterm_node)
131
+ subject.visit_nonterminal(nterm_node)
132
132
  end
133
133
 
134
134
  it 'should react to the visit_children message' do
@@ -139,7 +139,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
139
139
  expect(listener1).to receive(:before_terminal).with(children[0])
140
140
  expect(listener1).to receive(:after_terminal).with(children[0])
141
141
  expect(listener1).to receive(:after_children).with(nterm_node, children)
142
- subject.visit_children(nterm_node)
142
+ subject.send(:traverse_children, nterm_node)
143
143
  end
144
144
 
145
145
  it 'should react to the end_visit_nonterminal message' do
@@ -21,8 +21,8 @@ module Rley # Open this namespace to avoid module qualifier prefixes
21
21
  let(:output) { StringIO.new('', 'w') }
22
22
 
23
23
  let(:token_seq) do
24
- literals = ['I', 'saw', 'John', 'with', 'a', 'dog']
25
- literals.map {|lexeme| Token.new(lexeme, nil)}
24
+ literals = %w(I saw John with a dog)
25
+ literals.map { |lexeme| Token.new(lexeme, nil) }
26
26
  end
27
27
 
28
28
  let(:sample_tracer) { ParseTracer.new(0, output, token_seq) }
@@ -32,7 +32,8 @@ module Rley # Open this namespace to avoid module qualifier prefixes
32
32
  subject { Chart.new(dotted_rule, count_token, sample_tracer) }
33
33
 
34
34
  it 'should be created with start dotted rule, token count, tracer' do
35
- expect { Chart.new(dotted_rule, count_token, sample_tracer) }.not_to raise_error
35
+ expect { Chart.new(dotted_rule, count_token, sample_tracer) }
36
+ .not_to raise_error
36
37
  end
37
38
 
38
39
  it 'should have a seed state in first state_set' do
@@ -91,7 +92,6 @@ module Rley # Open this namespace to avoid module qualifier prefixes
91
92
  |> . . . . . .| [0:0] sentence => A B . C
92
93
  SNIPPET
93
94
  expect(output.string).to eq(expectation)
94
-
95
95
  end
96
96
 
97
97
  it 'should trace parse state pushing' do
@@ -233,7 +233,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
233
233
  $stdout = StringIO.new('', 'w')
234
234
 
235
235
  trace_level = 1
236
- parse_result = subject.parse(grm1_tokens, trace_level)
236
+ subject.parse(grm1_tokens, trace_level)
237
237
  expectations = <<-SNIPPET
238
238
  ['a', 'a', 'b', 'c', 'c']
239
239
  |. a . a . b . c . c .|
@@ -562,7 +562,8 @@ Syntax error at or near token 3>>>c<<<:
562
562
  Expected one of: ['a', 'b'], found a 'c' instead.
563
563
  MSG
564
564
  err = StandardError
565
- expect { subject.parse(wrong)}.to raise_error(err, err_msg.chomp)
565
+ expect { subject.parse(wrong) }
566
+ .to raise_error(err, err_msg.chomp)
566
567
  =begin
567
568
  expect(parse_result.success?).to eq(false)
568
569
 
@@ -17,20 +17,19 @@ module Rley # Open this namespace to avoid module qualifier prefixes
17
17
  let(:output) { StringIO.new('', 'w') }
18
18
 
19
19
  let(:token_seq) do
20
- literals = ['I', 'saw', 'John', 'with', 'a', 'dog']
21
- literals.map {|lexeme| Token.new(lexeme, nil)}
20
+ literals = %w(I saw John with a dog)
21
+ literals.map { |lexeme| Token.new(lexeme, nil) }
22
22
  end
23
-
24
- subject { ParseTracer.new(1, output, token_seq) }
23
+
24
+ subject { ParseTracer.new(1, output, token_seq) }
25
25
 
26
26
  context 'Creation & initialization:' do
27
27
  it 'should accept trace level 0' do
28
28
  expect { ParseTracer.new(0, output, token_seq) }.not_to raise_error
29
29
  expect(output.string).to eq('')
30
30
  end
31
-
32
- # |. I . saw . John . with . a . dog .|
33
-
31
+
32
+
34
33
  it 'should accept trace level 1' do
35
34
  expect { ParseTracer.new(1, output, token_seq) }.not_to raise_error
36
35
  expectations = <<-SNIPPET
@@ -39,7 +38,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
39
38
  SNIPPET
40
39
  expect(output.string).to eq(expectations)
41
40
  end
42
-
41
+
43
42
  it 'should accept trace level 2' do
44
43
  expect { ParseTracer.new(2, output, token_seq) }.not_to raise_error
45
44
  expectations = <<-SNIPPET
@@ -48,16 +47,16 @@ SNIPPET
48
47
  SNIPPET
49
48
  expect(output.string).to eq(expectations)
50
49
  end
51
-
50
+
52
51
  it 'should know the trace level' do
53
52
  expect(subject.level).to eq(1)
54
53
  end
55
-
54
+
56
55
  it 'should know the output stream' do
57
56
  expect(subject.ostream).to eq(output)
58
- end
57
+ end
59
58
  end # context
60
-
59
+
61
60
  context 'Provided services:' do
62
61
  let(:t_a) { Syntax::Terminal.new('A') }
63
62
  let(:t_b) { Syntax::Terminal.new('B') }
@@ -72,7 +71,7 @@ SNIPPET
72
71
  let(:dotted_rule) { DottedItem.new(sample_prod, 2) }
73
72
  let(:complete_rule) { DottedItem.new(sample_prod, 3) }
74
73
  let(:sample_parse_state) { ParseState.new(dotted_rule, origin_val) }
75
-
74
+
76
75
  # Factory method.
77
76
  def parse_state(origin, aDottedRule)
78
77
  ParseState.new(aDottedRule, origin)
@@ -85,6 +84,7 @@ SNIPPET
85
84
  expectations = <<-SNIPPET
86
85
  |[------] . . . . .| [0:1] sentence => A B . C
87
86
  SNIPPET
87
+ expect(output.string).to eq(expectations)
88
88
 
89
89
  # Case: token in the middle
90
90
  subject.ostream.string = ''
@@ -92,13 +92,15 @@ SNIPPET
92
92
  expectations = <<-SNIPPET
93
93
  |. . . [------] . .| [3:4] sentence => A B . C
94
94
  SNIPPET
95
-
95
+ expect(output.string).to eq(expectations)
96
+
96
97
  # Case: token at the end
97
98
  subject.ostream.string = ''
98
99
  subject.trace_scanning(6, parse_state(5, dotted_rule))
99
100
  expectations = <<-SNIPPET
100
101
  |. . . . . [------]| [5:6] sentence => A B . C
101
102
  SNIPPET
103
+ expect(output.string).to eq(expectations)
102
104
  end
103
105
 
104
106
 
@@ -109,8 +111,8 @@ SNIPPET
109
111
  expectations = <<-SNIPPET
110
112
  |> . . . . . .| [0:0] sentence => A B . C
111
113
  SNIPPET
112
- expect(output.string).to eq(expectations)
113
-
114
+ expect(output.string).to eq(expectations)
115
+
114
116
  # Case: stateset in the middle
115
117
  subject.ostream.string = ''
116
118
  subject.trace_prediction(3, sample_parse_state)
@@ -118,7 +120,7 @@ SNIPPET
118
120
  |. . . > . . .| [3:3] sentence => A B . C
119
121
  SNIPPET
120
122
  expect(output.string).to eq(expectations)
121
-
123
+
122
124
  # Case: final stateset
123
125
  subject.ostream.string = ''
124
126
  subject.trace_prediction(6, parse_state(6, dotted_rule))
@@ -136,7 +138,7 @@ SNIPPET
136
138
  |[=========================================]| [0:6] sentence => A B C .
137
139
  SNIPPET
138
140
  expect(output.string).to eq(expectations)
139
-
141
+
140
142
  # Case: step at the start (complete)
141
143
  subject.ostream.string = ''
142
144
  subject.trace_completion(1, parse_state(0, complete_rule))
@@ -144,7 +146,7 @@ SNIPPET
144
146
  |[------] . . . . .| [0:1] sentence => A B C .
145
147
  SNIPPET
146
148
  expect(output.string).to eq(expectations)
147
-
149
+
148
150
  # Case: step at the start (not complete)
149
151
  subject.ostream.string = ''
150
152
  subject.trace_completion(1, parse_state(0, dotted_rule))
@@ -152,7 +154,7 @@ SNIPPET
152
154
  |[------> . . . . .| [0:1] sentence => A B . C
153
155
  SNIPPET
154
156
  expect(output.string).to eq(expectations)
155
-
157
+
156
158
  # Case: step at the middle (complete)
157
159
  subject.ostream.string = ''
158
160
  subject.trace_completion(4, parse_state(2, complete_rule))
@@ -160,7 +162,7 @@ SNIPPET
160
162
  |. . [-------------] . .| [2:4] sentence => A B C .
161
163
  SNIPPET
162
164
  expect(output.string).to eq(expectations)
163
-
165
+
164
166
  # Case: step at the middle (not complete)
165
167
  subject.ostream.string = ''
166
168
  subject.trace_completion(4, parse_state(2, dotted_rule))
@@ -168,7 +170,7 @@ SNIPPET
168
170
  |. . [-------------> . .| [2:4] sentence => A B . C
169
171
  SNIPPET
170
172
  expect(output.string).to eq(expectations)
171
-
173
+
172
174
  # Case: step at the end (complete)
173
175
  subject.ostream.string = ''
174
176
  subject.trace_completion(6, parse_state(3, complete_rule))
@@ -176,7 +178,7 @@ SNIPPET
176
178
  |. . . [--------------------]| [3:6] sentence => A B C .
177
179
  SNIPPET
178
180
  expect(output.string).to eq(expectations)
179
-
181
+
180
182
  # Case: step at the end (not complete)
181
183
  subject.ostream.string = ''
182
184
  subject.trace_completion(6, parse_state(3, dotted_rule))
@@ -190,4 +192,4 @@ SNIPPET
190
192
  end # module
191
193
  end # module
192
194
 
193
- # End of file
195
+ # End of file
@@ -74,7 +74,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
74
74
 
75
75
  it 'should emit trace level 1 info' do
76
76
  tracer = ParseTracer.new(1, output, grm1_tokens)
77
- instance = Parsing.new(start_dotted_rule, grm1_tokens, tracer)
77
+ Parsing.new(start_dotted_rule, grm1_tokens, tracer)
78
78
  expectations = <<-SNIPPET
79
79
  ['a', 'a', 'b', 'c', 'c']
80
80
  |. a . a . b . c . c .|
@@ -101,7 +101,8 @@ SNIPPET
101
101
  it 'should complain when trying to push a nil dotted item' do
102
102
  err = StandardError
103
103
  msg = 'Dotted item may not be nil'
104
- expect{ subject.push_state(nil, 1, 1, :prediction) }.to raise_error(err, msg)
104
+ expect { subject.push_state(nil, 1, 1, :prediction) }
105
+ .to raise_error(err, msg)
105
106
  end
106
107
 
107
108
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.09
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-28 00:00:00.000000000 Z
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake