rley 0.5.07 → 0.5.08

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/examples/NLP/{benchmark_mini_en.rb → benchmark_pico_en.rb} +0 -0
  4. data/examples/NLP/nano_eng/nano_en_demo.rb +118 -0
  5. data/examples/NLP/nano_eng/nano_grammar.rb +59 -0
  6. data/examples/NLP/{mini_en_demo.rb → pico_en_demo.rb} +2 -2
  7. data/examples/general/SRL/lib/ast_builder.rb +176 -0
  8. data/examples/general/SRL/lib/ast_building.rb +20 -0
  9. data/examples/general/SRL/lib/grammar.rb +32 -0
  10. data/examples/general/SRL/lib/parser.rb +26 -0
  11. data/examples/general/SRL/lib/regex/multiplicity.rb +94 -0
  12. data/examples/general/SRL/lib/regex_repr.rb +1 -0
  13. data/examples/general/SRL/lib/srl_demo.rb +67 -0
  14. data/examples/general/SRL/lib/tokenizer.rb +101 -0
  15. data/examples/general/SRL/spec/integration_spec.rb +103 -0
  16. data/examples/general/SRL/spec/regex/multiplicity_spec.rb +83 -0
  17. data/examples/general/SRL/spec/spec_helper.rb +25 -0
  18. data/examples/general/SRL/spec/tokenizer_spec.rb +125 -0
  19. data/examples/general/SRL/srl_demo.rb +57 -0
  20. data/examples/general/calc_iter1/calc_demo.rb +1 -1
  21. data/examples/general/calc_iter2/ast_building.rb +20 -0
  22. data/examples/general/calc_iter2/calc_ast_builder.rb +3 -23
  23. data/examples/general/calc_iter2/calc_demo.rb +1 -1
  24. data/lib/rley/base/base_parser.rb +1 -1
  25. data/lib/rley/base/grm_items_builder.rb +1 -1
  26. data/lib/rley/constants.rb +1 -1
  27. data/lib/rley/gfg/non_terminal_vertex.rb +1 -1
  28. data/lib/rley/parser/gfg_chart.rb +8 -3
  29. data/lib/rley/parser/gfg_earley_parser.rb +5 -2
  30. data/lib/rley/parser/gfg_parsing.rb +5 -1
  31. data/lib/rley/parser/parse_tree_builder.rb +16 -5
  32. data/lib/rley/ptree/terminal_node.rb +3 -2
  33. data/spec/rley/parser/ast_builder_spec.rb +2 -2
  34. data/spec/rley/parser/cst_builder_spec.rb +2 -3
  35. metadata +20 -4
@@ -3,10 +3,11 @@ require_relative 'parse_tree_node' # Load superclass
3
3
  module Rley # This module is used as a namespace
4
4
  module PTree # This module is used as a namespace
5
5
  class TerminalNode < ParseTreeNode
6
- # Link to the input token
6
+ # @return [Lexical::Token] the input token
7
7
  attr_reader(:token)
8
8
 
9
- # aPosition is the position of the token in the input stream.
9
+ # @param aToken [Lexical::Token] Input Token object
10
+ # @param aPos [Integer] position of the token in the input stream.
10
11
  def initialize(aToken, aPos)
11
12
  # (major, minor) =
12
13
 
@@ -253,7 +253,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
253
253
 
254
254
  next_event('visit P => arr . | 0 7')
255
255
  # stack: [P[0, 7]]
256
- expect(stack.last.children).to eq([nil])
256
+ expect(stack.last.children.size).to eq(1)
257
257
 
258
258
  next_event('visit arr. | 0 7')
259
259
  expect(stack.size).to eq(2)
@@ -276,7 +276,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
276
276
  expect(stack.last.children).to be_nil
277
277
 
278
278
  next_event('visit sequence => list . | 1 6')
279
- expect(stack.last.children).to eq([nil])
279
+ expect(stack.last.children.size).to eq(1)
280
280
 
281
281
  next_event('visit list. | 1 6')
282
282
  expect(stack.size).to eq(4)
@@ -133,7 +133,6 @@ module Rley # Open this namespace to avoid module qualifier prefixes
133
133
  expect { subject.receive_event(*event) }.not_to raise_error
134
134
  stack = get_stack(subject)
135
135
  expect(stack.size).to eq(1)
136
- expect(stack.last.children).to eq([nil])
137
136
  end
138
137
 
139
138
  it 'should react to a second end event' do
@@ -152,7 +151,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
152
151
  expect { subject.receive_event(*event) }.not_to raise_error
153
152
  stack = get_stack(subject)
154
153
  expect(stack.size).to eq(2)
155
- expect(stack.last.children).to eq([nil, nil, nil])
154
+ expect(stack.last.children.size).to eq(3)
156
155
  end
157
156
 
158
157
  it 'should react to an exit event that creates a terminal node' do
@@ -370,7 +369,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
370
369
  expect(stack.last.children).to be_nil
371
370
 
372
371
  next_event('visit P => arr . | 0 2')
373
- expect(stack.last.children).to eq([nil])
372
+ expect(stack.last.children.size).to eq(1)
374
373
 
375
374
  next_event('visit arr. | 0 2')
376
375
  expect(stack.size).to eq(2)
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.5.07
4
+ version: 0.5.08
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-11 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -130,8 +130,10 @@ files:
130
130
  - README.md
131
131
  - Rakefile
132
132
  - appveyor.yml
133
- - examples/NLP/benchmark_mini_en.rb
134
- - examples/NLP/mini_en_demo.rb
133
+ - examples/NLP/benchmark_pico_en.rb
134
+ - examples/NLP/nano_eng/nano_en_demo.rb
135
+ - examples/NLP/nano_eng/nano_grammar.rb
136
+ - examples/NLP/pico_en_demo.rb
135
137
  - examples/data_formats/JSON/cli_options.rb
136
138
  - examples/data_formats/JSON/json_ast_builder.rb
137
139
  - examples/data_formats/JSON/json_ast_nodes.rb
@@ -140,6 +142,19 @@ files:
140
142
  - examples/data_formats/JSON/json_lexer.rb
141
143
  - examples/data_formats/JSON/json_minifier.rb
142
144
  - examples/data_formats/JSON/json_parser.rb
145
+ - examples/general/SRL/lib/ast_builder.rb
146
+ - examples/general/SRL/lib/ast_building.rb
147
+ - examples/general/SRL/lib/grammar.rb
148
+ - examples/general/SRL/lib/parser.rb
149
+ - examples/general/SRL/lib/regex/multiplicity.rb
150
+ - examples/general/SRL/lib/regex_repr.rb
151
+ - examples/general/SRL/lib/srl_demo.rb
152
+ - examples/general/SRL/lib/tokenizer.rb
153
+ - examples/general/SRL/spec/integration_spec.rb
154
+ - examples/general/SRL/spec/regex/multiplicity_spec.rb
155
+ - examples/general/SRL/spec/spec_helper.rb
156
+ - examples/general/SRL/spec/tokenizer_spec.rb
157
+ - examples/general/SRL/srl_demo.rb
143
158
  - examples/general/calc_iter1/calc_ast_builder.rb
144
159
  - examples/general/calc_iter1/calc_ast_nodes.rb
145
160
  - examples/general/calc_iter1/calc_demo.rb
@@ -147,6 +162,7 @@ files:
147
162
  - examples/general/calc_iter1/calc_lexer.rb
148
163
  - examples/general/calc_iter1/calc_parser.rb
149
164
  - examples/general/calc_iter1/spec/calculator_spec.rb
165
+ - examples/general/calc_iter2/ast_building.rb
150
166
  - examples/general/calc_iter2/calc_ast_builder.rb
151
167
  - examples/general/calc_iter2/calc_ast_nodes.rb
152
168
  - examples/general/calc_iter2/calc_demo.rb