rley 0.0.04 → 0.0.05
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 +8 -8
- data/lib/rley/constants.rb +1 -1
- data/lib/rley/parser/chart.rb +2 -4
- data/lib/rley/parser/dotted_item.rb +2 -4
- data/lib/rley/parser/earley_parser.rb +13 -16
- data/lib/rley/parser/parse_state.rb +2 -5
- data/lib/rley/parser/parsing.rb +17 -20
- data/lib/rley/parser/state_set.rb +1 -5
- data/lib/rley/parser/token.rb +0 -4
- data/lib/rley/syntax/grammar.rb +1 -4
- data/lib/rley/syntax/grm_symbol.rb +0 -2
- data/lib/rley/syntax/literal.rb +0 -2
- data/lib/rley/syntax/non_terminal.rb +0 -4
- data/lib/rley/syntax/production.rb +3 -7
- data/lib/rley/syntax/symbol_seq.rb +7 -8
- data/lib/rley/syntax/verbatim_symbol.rb +0 -2
- data/spec/rley/parser/chart_spec.rb +24 -26
- data/spec/rley/parser/dotted_item_spec.rb +83 -88
- data/spec/rley/parser/earley_parser_spec.rb +277 -241
- data/spec/rley/parser/parse_state_spec.rb +66 -66
- data/spec/rley/parser/parsing_spec.rb +89 -90
- data/spec/rley/parser/state_set_spec.rb +54 -56
- data/spec/rley/parser/token_spec.rb +18 -20
- data/spec/rley/syntax/grammar_spec.rb +118 -120
- data/spec/rley/syntax/grm_symbol_spec.rb +12 -15
- data/spec/rley/syntax/literal_spec.rb +16 -18
- data/spec/rley/syntax/non_terminal_spec.rb +12 -15
- data/spec/rley/syntax/production_spec.rb +33 -35
- data/spec/rley/syntax/symbol_seq_spec.rb +51 -52
- data/spec/rley/syntax/terminal_spec.rb +12 -15
- data/spec/rley/syntax/verbatim_symbol_spec.rb +16 -18
- metadata +2 -2
@@ -7,58 +7,57 @@ require_relative '../../../lib/rley/syntax/symbol_seq'
|
|
7
7
|
|
8
8
|
module Rley # Open this namespace to avoid module qualifier prefixes
|
9
9
|
module Syntax # Open this namespace to avoid module qualifier prefixes
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
10
|
+
describe SymbolSeq do
|
11
|
+
let(:verb) { NonTerminal.new('Verb') }
|
12
|
+
let(:np) { NonTerminal.new('NP') }
|
13
|
+
let(:pp) { NonTerminal.new('PP') }
|
14
|
+
|
15
|
+
# Default instantiation rule
|
16
|
+
subject { SymbolSeq.new([verb, np, pp]) }
|
17
|
+
|
18
|
+
context 'Initialization:' do
|
19
|
+
it 'should be created with a list of symbols' do
|
20
|
+
# Case of non-empty sequence
|
21
|
+
expect { SymbolSeq.new([verb, np, pp]) }.not_to raise_error
|
22
|
+
|
23
|
+
# Case of empty sequence
|
24
|
+
expect { SymbolSeq.new([]) }.not_to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should know its members' do
|
28
|
+
expect(subject.members).to eq([verb, np, pp])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should know whether it is empty' do
|
32
|
+
expect(subject).not_to be_empty
|
33
|
+
instance = SymbolSeq.new([])
|
34
|
+
expect(instance).to be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should the count of its members' do
|
38
|
+
expect(subject.size).to eq(3)
|
39
|
+
end
|
40
|
+
end # context
|
41
|
+
|
42
|
+
context 'Provided services:' do
|
43
|
+
it 'should compare compare with itself' do
|
44
|
+
me = subject
|
45
|
+
expect(subject == me).to eq(true)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should compare with another instance' do
|
49
|
+
empty_one = SymbolSeq.new([])
|
50
|
+
expect(subject == empty_one).not_to eq(true)
|
51
|
+
|
52
|
+
equal_one = SymbolSeq.new([verb, np, pp])
|
53
|
+
expect(subject == equal_one).to eq(true)
|
54
|
+
|
55
|
+
unequal_one = SymbolSeq.new([verb, pp, np])
|
56
|
+
expect(subject == unequal_one).not_to eq(true)
|
57
|
+
end
|
58
|
+
end # context
|
59
|
+
|
60
|
+
end # describe
|
62
61
|
end # module
|
63
62
|
end # module
|
64
63
|
|
@@ -5,25 +5,22 @@ require_relative '../../../lib/rley/syntax/terminal'
|
|
5
5
|
|
6
6
|
module Rley # Open this namespace to avoid module qualifier prefixes
|
7
7
|
module Syntax # Open this namespace to avoid module qualifier prefixes
|
8
|
+
describe Terminal do
|
9
|
+
let(:sample_name) { 'noun' }
|
10
|
+
subject { Terminal.new(sample_name) }
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
context 'Initialization:' do
|
13
|
+
it 'should be created with a name' do
|
14
|
+
expect { Terminal.new('noun') }.not_to raise_error
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should know its name' do
|
19
|
-
expect(subject.name).to eq(sample_name)
|
20
|
-
end
|
21
|
-
end # context
|
22
|
-
|
23
|
-
end # describe
|
17
|
+
it 'should know its name' do
|
18
|
+
expect(subject.name).to eq(sample_name)
|
19
|
+
end
|
20
|
+
end # context
|
24
21
|
|
22
|
+
end # describe
|
25
23
|
end # module
|
26
24
|
end # module
|
27
25
|
|
28
26
|
# End of file
|
29
|
-
|
@@ -5,28 +5,26 @@ require_relative '../../../lib/rley/syntax/verbatim_symbol'
|
|
5
5
|
|
6
6
|
module Rley # Open this namespace to avoid module qualifier prefixes
|
7
7
|
module Syntax # Open this namespace to avoid module qualifier prefixes
|
8
|
+
describe VerbatimSymbol do
|
9
|
+
let(:sample_name) { 'cheapest' }
|
10
|
+
subject { VerbatimSymbol.new(sample_name) }
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
context 'Initialization:' do
|
13
|
+
it 'should be created with a word' do
|
14
|
+
expect { VerbatimSymbol.new('cheapest') }.not_to raise_error
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
+
it 'should know its name' do
|
18
|
+
expect(subject.name).to eq(sample_name)
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
it 'should know its text representation' do
|
23
|
-
expect(subject.text).to eq(sample_name)
|
24
|
-
end
|
25
|
-
end # context
|
26
|
-
|
27
|
-
end # describe
|
21
|
+
it 'should know its text representation' do
|
22
|
+
expect(subject.text).to eq(sample_name)
|
23
|
+
end
|
24
|
+
end # context
|
28
25
|
|
26
|
+
end # describe
|
29
27
|
end # module
|
30
28
|
end # module
|
31
29
|
|
32
|
-
# End of file
|
30
|
+
# End of file
|
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.0.
|
4
|
+
version: 0.0.05
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|