sequitur 0.1.18 → 0.1.19
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 +4 -4
- data/.rubocop.yml +163 -49
- data/.travis.yml +13 -10
- data/CHANGELOG.md +9 -0
- data/Gemfile +2 -3
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/appveyor.yml +13 -10
- data/examples/integer_sample.rb +5 -6
- data/examples/porridge.rb +4 -6
- data/examples/simple_case.rb +5 -6
- data/examples/symbol_sample.rb +5 -8
- data/examples/word_sample.rb +1 -2
- data/lib/sequitur/constants.rb +1 -1
- data/lib/sequitur/digram.rb +38 -38
- data/lib/sequitur/dynamic_grammar.rb +91 -95
- data/lib/sequitur/formatter/base_text.rb +1 -1
- data/lib/sequitur/formatter/debug.rb +2 -2
- data/lib/sequitur/grammar_visitor.rb +96 -98
- data/lib/sequitur/production.rb +10 -19
- data/lib/sequitur/production_ref.rb +104 -105
- data/lib/sequitur/sequitur_grammar.rb +3 -3
- data/lib/sequitur/symbol_sequence.rb +7 -11
- data/spec/sequitur/digram_spec.rb +8 -8
- data/spec/sequitur/production_spec.rb +7 -7
- data/spec/sequitur/sequitur_grammar_spec.rb +10 -10
- data/spec/sequitur/symbol_sequence_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -4
- metadata +44 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5c6dfc81b67a8d8d53a1e33717bd32d187697aa
|
4
|
+
data.tar.gz: 92e35b2c2bdaa0978066d7606e8d0306aae9f648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5c93785c161cddeafc8dcf580ad16653558664b0c7f78c2c24a9e441db2ca27341059cf78b8e32c64659eafb3dac41d47af27e8253de138500e7422ab571c8
|
7
|
+
data.tar.gz: 8c7d05b82b0e8a6a5d71138cfdadda049f5284c7ea1da04d033040acb6bb90c931808fa9dcfbaf1ae2df6ceee534eb65ff388f8031300f1efe7f1cd7ea61c2f0
|
data/.rubocop.yml
CHANGED
@@ -1,82 +1,196 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
|
-
- '
|
4
|
-
- 'features/**/*'
|
5
|
-
- 'gems/**/*'
|
3
|
+
- 'exp/**/*'
|
6
4
|
- 'lab/**/*'
|
7
5
|
|
8
|
-
|
9
|
-
Max: 20
|
10
|
-
|
11
|
-
# This is disabled because some demos use UTF-8
|
12
|
-
AsciiComments:
|
6
|
+
Layout/CaseIndentation:
|
13
7
|
Enabled: false
|
14
|
-
|
15
|
-
|
8
|
+
|
9
|
+
Layout/CommentIndentation:
|
16
10
|
Enabled: false
|
17
|
-
|
18
|
-
CaseIndentation:
|
19
|
-
IndentWhenRelativeTo: end
|
20
|
-
IndentOneStep: true
|
21
11
|
|
22
|
-
|
23
|
-
# Which is contrary to modelling practice.
|
24
|
-
ClassCheck:
|
12
|
+
Layout/ElseAlignment:
|
25
13
|
Enabled: false
|
26
|
-
|
27
|
-
ClassLength:
|
28
|
-
Max: 250
|
29
|
-
CountComments: false
|
30
14
|
|
31
|
-
|
15
|
+
Layout/EmptyLines:
|
32
16
|
Enabled: false
|
33
17
|
|
34
|
-
|
18
|
+
Layout/EndAlignment:
|
35
19
|
Enabled: false
|
36
|
-
|
37
|
-
|
20
|
+
|
21
|
+
Layout/EndOfLine:
|
22
|
+
Enabled: true
|
23
|
+
EnforcedStyle: lf
|
24
|
+
|
25
|
+
Layout/IndentationWidth:
|
38
26
|
Enabled: false
|
27
|
+
|
28
|
+
Layout/IndentationConsistency:
|
29
|
+
Enabled: true
|
39
30
|
|
40
|
-
|
31
|
+
Layout/IndentHeredoc:
|
41
32
|
Enabled: false
|
42
33
|
|
43
|
-
|
44
|
-
Enabled:
|
34
|
+
Layout/MultilineHashBraceLayout:
|
35
|
+
Enabled: true
|
45
36
|
|
46
|
-
|
47
|
-
Enabled:
|
37
|
+
Layout/SpaceAroundOperators:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
Layout/SpaceInsideParens:
|
41
|
+
Enabled: true
|
48
42
|
|
49
|
-
|
43
|
+
Layout/Tab:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
Layout/TrailingBlankLines:
|
47
|
+
Enabled: true
|
48
|
+
|
49
|
+
Layout/TrailingWhitespace:
|
50
|
+
Enabled: true
|
51
|
+
|
52
|
+
Lint/Loop:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
Lint/RescueException:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Lint/UnusedMethodArgument:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Lint/UselessAccessModifier:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Lint/Void:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Lint/UselessAssignment:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Metrics/AbcSize:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Metrics/BlockLength:
|
74
|
+
Enabled: true
|
75
|
+
Max: 350
|
76
|
+
|
77
|
+
Metrics/ClassLength:
|
78
|
+
Enabled: true
|
79
|
+
Max: 350
|
80
|
+
|
81
|
+
Metrics/CyclomaticComplexity:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Metrics/LineLength:
|
85
|
+
Enabled: false
|
86
|
+
Max: 90
|
87
|
+
|
88
|
+
Metrics/MethodLength:
|
89
|
+
Enabled: true
|
90
|
+
Max: 40
|
91
|
+
|
92
|
+
Metrics/ModuleLength:
|
93
|
+
Enabled: true
|
94
|
+
Max: 500
|
95
|
+
|
96
|
+
Metrics/PerceivedComplexity:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
Naming/ConstantName:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
Naming/ClassAndModuleCamelCase:
|
50
103
|
Enabled: false
|
51
104
|
|
105
|
+
Naming/UncommunicativeBlockParamName:
|
106
|
+
Enabled: true
|
52
107
|
|
53
|
-
|
54
|
-
MethodLength:
|
55
|
-
Max: 50
|
56
|
-
CountComments: false
|
57
|
-
|
58
|
-
# Avoid modules longer than 400 lines of code
|
59
|
-
ModuleLength:
|
60
|
-
Max: 400
|
61
|
-
|
62
|
-
NonNilCheck:
|
108
|
+
Naming/UncommunicativeMethodParamName:
|
63
109
|
Enabled: false
|
64
110
|
|
65
|
-
|
111
|
+
Naming/VariableName:
|
66
112
|
Enabled: false
|
67
|
-
|
68
|
-
|
113
|
+
|
114
|
+
Style/Alias:
|
115
|
+
Enabled: true
|
116
|
+
|
117
|
+
Layout/AlignHash:
|
69
118
|
Enabled: false
|
70
|
-
|
71
|
-
|
119
|
+
|
120
|
+
Style/AsciiComments:
|
121
|
+
Enabled: false
|
122
|
+
|
123
|
+
Style/BarePercentLiterals:
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
Style/BlockComments:
|
72
127
|
Enabled: false
|
73
128
|
|
74
|
-
|
129
|
+
Style/CharacterLiteral:
|
75
130
|
Enabled: false
|
76
131
|
|
77
|
-
|
132
|
+
Style/ClassCheck:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Style/ClassVars:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
Style/ColonMethodCall:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
Style/CommentAnnotation:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
Style/CommentedKeyword:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
Style/ConditionalAssignment:
|
148
|
+
Enabled: false
|
149
|
+
|
150
|
+
Style/DefWithParentheses:
|
151
|
+
Enabled: true
|
152
|
+
|
153
|
+
Style/Documentation:
|
154
|
+
Enabled: false
|
155
|
+
|
156
|
+
Style/ExpandPathArguments:
|
157
|
+
Enabled: false
|
158
|
+
|
159
|
+
Style/GuardClause:
|
160
|
+
Enabled: false
|
161
|
+
|
162
|
+
Style/IfUnlessModifier:
|
163
|
+
Enabled: false
|
164
|
+
|
165
|
+
Style/InverseMethods:
|
166
|
+
Enabled: true
|
167
|
+
|
168
|
+
Style/Next:
|
169
|
+
Enabled: false
|
170
|
+
|
171
|
+
Style/RaiseArgs:
|
172
|
+
Enabled: true
|
173
|
+
|
174
|
+
Style/RedundantReturn:
|
78
175
|
Enabled: false
|
79
176
|
|
80
|
-
|
177
|
+
Style/RedundantSelf:
|
178
|
+
Enabled: true
|
179
|
+
|
180
|
+
Style/RegexpLiteral:
|
181
|
+
Enabled: false
|
182
|
+
|
183
|
+
Style/PercentLiteralDelimiters:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
Style/StderrPuts:
|
187
|
+
Enabled: false
|
188
|
+
|
189
|
+
Style/StringLiterals:
|
190
|
+
Enabled: true
|
191
|
+
|
192
|
+
Style/TernaryParentheses:
|
81
193
|
Enabled: false
|
82
194
|
|
195
|
+
Style/UnlessElse:
|
196
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- ruby-head
|
4
|
-
- jruby-head
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
-
|
4
|
+
- jruby-head
|
5
|
+
- 2.5.1
|
6
|
+
- 2.4.4
|
7
|
+
- 2.3.7
|
8
|
+
- 2.2.10
|
9
|
+
- 2.1.10
|
10
|
+
- 2.0.0
|
11
|
+
- jruby
|
10
12
|
|
11
13
|
matrix:
|
12
14
|
allow_failures:
|
13
|
-
- rvm: jruby
|
15
|
+
- rvm: jruby
|
14
16
|
- rvm: ruby-head
|
15
17
|
- rvm: jruby-head
|
18
|
+
fast_finish: true
|
16
19
|
|
17
20
|
gemfile:
|
18
21
|
- Gemfile
|
19
|
-
|
22
|
+
|
20
23
|
# whitelist
|
21
|
-
branches:
|
24
|
+
branches:
|
22
25
|
only:
|
23
|
-
- master
|
26
|
+
- master
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 0.1.19 / 2018-05-16
|
2
|
+
Maintenance release.
|
3
|
+
* [CHANGE] File `.travis.yml`: updated Ruby versions.
|
4
|
+
* [CHANGE] File `appveyor.yml` updated Ruby versions, updated for syntax changes.
|
5
|
+
* [CHANGE] File 'sequitur.gemspec' Updated versions in dependencies.
|
6
|
+
* [CHANGE] File 'Gemfile' Updated versions in dependencies.
|
7
|
+
* [CHANGE] File 'Gemfile' Code re-styling to please Rubocop 0.55.0.
|
8
|
+
|
9
|
+
|
1
10
|
### 0.1.18 / 2016-12-21
|
2
11
|
* [NEW] Added AppVeyor CI to Github commits. AppVeyor allows to build and test commits on Windows servers.
|
3
12
|
This is complementary to Travis CI which does Linux builds.
|
data/Gemfile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
# Prevent Bundler to load the dependencies from our .gemspec file
|
3
3
|
|
4
|
-
|
5
4
|
group :development do
|
6
5
|
gem 'coveralls', '>= 0.7.0'
|
7
|
-
gem 'rake', '>= 10.0.0'
|
8
|
-
gem 'rspec', '>=
|
6
|
+
gem 'rake', '>= 10.0.0'
|
7
|
+
gem 'rspec', '>= 3.0.0'
|
9
8
|
gem 'simplecov', '>= 0.8.0'
|
10
9
|
end
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -248,4 +248,4 @@ More examples are available in the examples folder.
|
|
248
248
|
|
249
249
|
Copyright
|
250
250
|
---------
|
251
|
-
Copyright (c) 2014-
|
251
|
+
Copyright (c) 2014-2018, Dimitri Geshef. Sequitur is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Sequitur/blob/master/LICENSE.txt) for details.
|
data/appveyor.yml
CHANGED
@@ -2,19 +2,22 @@ version: '{build}'
|
|
2
2
|
max_jobs: 3
|
3
3
|
environment:
|
4
4
|
matrix:
|
5
|
-
- Ruby_version:
|
6
|
-
- Ruby_version:
|
7
|
-
- Ruby_version: 21
|
8
|
-
- Ruby_version: 21-x64
|
9
|
-
- Ruby_version: 22
|
10
|
-
- Ruby_version: 22-x64
|
5
|
+
- Ruby_version: 24
|
6
|
+
- Ruby_version: 24-x64
|
11
7
|
- Ruby_version: 23
|
12
8
|
- Ruby_version: 23-x64
|
9
|
+
- Ruby_version: 22
|
10
|
+
- Ruby_version: 22-x64
|
11
|
+
- Ruby_version: 21
|
12
|
+
- Ruby_version: 21-x64
|
13
|
+
- Ruby_version: 200
|
14
|
+
- Ruby_version: 200-x64
|
15
|
+
|
13
16
|
install:
|
14
|
-
-
|
15
|
-
|
17
|
+
- set PATH=C:\Ruby%Ruby_version%\bin;%PATH%
|
18
|
+
- bundle install --retry=3 --clean --force
|
16
19
|
|
17
|
-
bundle install --retry=3 --clean
|
18
20
|
build: off
|
21
|
+
|
19
22
|
test_script:
|
20
|
-
-
|
23
|
+
- bundle exec rake
|
data/examples/integer_sample.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'sequitur'
|
1
|
+
require 'sequitur' # Load the Sequitur library
|
2
2
|
|
3
3
|
#
|
4
4
|
# Purpose: show how to apply Sequitur on a stream of integer values
|
5
5
|
#
|
6
|
-
input_sequence =
|
6
|
+
input_sequence = [1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5]
|
7
7
|
|
8
8
|
# Generate the grammar from the sequence
|
9
9
|
grammar = Sequitur.build_from(input_sequence)
|
@@ -23,11 +23,10 @@ formatter.render(grammar.visitor)
|
|
23
23
|
|
24
24
|
# Playing a bit with the API
|
25
25
|
# Access last symbol from rhs of start production:
|
26
|
-
last_symbol_p0 = grammar.start.rhs.symbols[-1]
|
27
|
-
puts last_symbol_p0
|
26
|
+
last_symbol_p0 = grammar.start.rhs.symbols[-1]
|
27
|
+
puts last_symbol_p0 # => 5
|
28
28
|
|
29
29
|
# Access first symbol from rhs of P1 production:
|
30
30
|
first_symbol_p1 = grammar.productions[1].rhs.symbols[0]
|
31
31
|
|
32
|
-
puts first_symbol_p1
|
33
|
-
|
32
|
+
puts first_symbol_p1 # => 1
|
data/examples/porridge.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'sequitur'
|
2
|
-
|
1
|
+
require 'sequitur' # Load the Sequitur library
|
3
2
|
|
4
3
|
# Purpose: demo to show that sequitur gem works on example from sequitur.info website
|
5
|
-
input_sequence =
|
6
|
-
input = <<-SNIPPET
|
4
|
+
input_sequence = <<-SNIPPET
|
7
5
|
pease porridge hot,
|
8
6
|
pease porridge cold,
|
9
7
|
pease porridge in the pot,
|
@@ -21,7 +19,7 @@ grammar = Sequitur.build_from(input_sequence)
|
|
21
19
|
# We use a formatter
|
22
20
|
formatter = Sequitur::Formatter::BaseText.new(STDOUT)
|
23
21
|
|
24
|
-
# Now render the rules.
|
22
|
+
# Now render the rules.
|
25
23
|
formatter.render(grammar.visitor)
|
26
24
|
|
27
25
|
# Rendered output is:
|
@@ -38,4 +36,4 @@ formatter.render(grammar.visitor)
|
|
38
36
|
# P9 : s o m P1 l i k P1 i t .
|
39
37
|
# P10 : c P7.
|
40
38
|
# P11 : P5 P9.
|
41
|
-
# P12 : P6 t h P4 t P5 n P6 P1 d a y s
|
39
|
+
# P12 : P6 t h P4 t P5 n P6 P1 d a y s P7 .
|
data/examples/simple_case.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require 'sequitur'
|
2
|
-
|
1
|
+
require 'sequitur' # Load the Sequitur library
|
3
2
|
|
4
3
|
# Purpose: show how to apply Sequitur on a stream of single characters
|
5
|
-
input_sequence =
|
4
|
+
input_sequence = 'ababcabcdabcde' # Let's analyze this string
|
6
5
|
|
7
6
|
# The SEQUITUR algorithm will detect the repeated 'ab' pattern
|
8
7
|
# and will generate a context-free grammar that represents the input string
|
@@ -14,9 +13,9 @@ formatter = Sequitur::Formatter::BaseText.new(STDOUT)
|
|
14
13
|
|
15
14
|
# Now render the rules. Each rule is displayed with the format:
|
16
15
|
# rule_id : a_sequence_grammar_symbols.
|
17
|
-
# Where:
|
16
|
+
# Where:
|
18
17
|
# - rule_id is either 'start' or a name like 'Pxxxx' (xxxx is a sequential number)
|
19
|
-
# - a grammar symbol is either a terminal symbol
|
18
|
+
# - a grammar symbol is either a terminal symbol
|
20
19
|
# (i.e. a character from the input) or a rule id
|
21
20
|
formatter.render(grammar.visitor)
|
22
21
|
|
@@ -24,4 +23,4 @@ formatter.render(grammar.visitor)
|
|
24
23
|
# start : P1 P2 P3 P3 e.
|
25
24
|
# P1 : a b.
|
26
25
|
# P2 : P1 c.
|
27
|
-
# P3 : P2 d.
|
26
|
+
# P3 : P2 d.
|