srl_ruby 0.4.6 → 0.4.7
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 +276 -23
- data/CHANGELOG.md +8 -1
- data/Rakefile +1 -0
- data/bin/srl2ruby +8 -6
- data/bin/srl2ruby_cli_parser.rb +1 -3
- data/lib/regex/alternation.rb +1 -3
- data/lib/regex/anchor.rb +1 -0
- data/lib/regex/capturing_group.rb +6 -3
- data/lib/regex/char_class.rb +1 -1
- data/lib/regex/char_range.rb +1 -3
- data/lib/regex/char_shorthand.rb +1 -0
- data/lib/regex/character.rb +1 -0
- data/lib/regex/expression.rb +3 -0
- data/lib/regex/lookaround.rb +1 -1
- data/lib/regex/multiplicity.rb +6 -9
- data/lib/regex/non_capturing_group.rb +1 -1
- data/lib/regex/quantifiable.rb +1 -1
- data/lib/regex/wildcard.rb +0 -5
- data/lib/srl_ruby/ast_builder.rb +3 -0
- data/lib/srl_ruby/grammar.rb +46 -46
- data/lib/srl_ruby/tokenizer.rb +6 -2
- data/lib/srl_ruby/version.rb +1 -1
- data/spec/acceptance/support/rule_file_grammar.rb +5 -5
- data/spec/acceptance/support/rule_file_tokenizer.rb +6 -1
- data/spec/regex/character_spec.rb +10 -6
- data/spec/regex/multiplicity_spec.rb +2 -0
- data/spec/srl_ruby_spec.rb +6 -6
- data/srl_ruby.gemspec +3 -3
- metadata +11 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0ad4df7433bb3c5e88e03e5670c306d1a70b6ec43f831c3d6d376e1776856e5
|
|
4
|
+
data.tar.gz: 57d9791c96e46524e08d21606d17d4757bea2d9d9cd4e1322276733e5cf1642c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 151d3cdfd98bc907c2c4c3b63e317852fec743dc12b27f509b32285a8bd100242cc745c422a3c81641f4152453d3acc713246d8b907b532f635db5f99e83d2f2
|
|
7
|
+
data.tar.gz: 00b946261c11af9e9b64b460664a33498d1cd57685f3a6fc884c238c67c163b1c7a26efce508c3a9bd6e830bae82c1420697923e8889783b432c00333fffb2c7
|
data/.rubocop.yml
CHANGED
|
@@ -2,9 +2,19 @@ AllCops:
|
|
|
2
2
|
Exclude:
|
|
3
3
|
- 'exp/**/*'
|
|
4
4
|
|
|
5
|
+
Gemspec/DateAssignment:
|
|
6
|
+
Enabled: true
|
|
7
|
+
|
|
8
|
+
Layout/ArgumentAlignment:
|
|
9
|
+
Enabled: false
|
|
10
|
+
|
|
11
|
+
Layout/ArrayAlignment:
|
|
12
|
+
Enabled: true
|
|
13
|
+
EnforcedStyle: with_fixed_indentation
|
|
14
|
+
|
|
5
15
|
Layout/CaseIndentation:
|
|
6
16
|
Enabled: false
|
|
7
|
-
|
|
17
|
+
|
|
8
18
|
Layout/ClosingHeredocIndentation:
|
|
9
19
|
Enabled: false
|
|
10
20
|
|
|
@@ -16,7 +26,7 @@ Layout/ElseAlignment:
|
|
|
16
26
|
|
|
17
27
|
Layout/EmptyLines:
|
|
18
28
|
Enabled: false
|
|
19
|
-
|
|
29
|
+
|
|
20
30
|
Layout/EndAlignment:
|
|
21
31
|
Enabled: false
|
|
22
32
|
|
|
@@ -24,39 +34,118 @@ Layout/EndOfLine:
|
|
|
24
34
|
Enabled: true
|
|
25
35
|
EnforcedStyle: lf
|
|
26
36
|
|
|
37
|
+
Layout/FirstArgumentIndentation:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
Layout/HashAlignment:
|
|
41
|
+
Enabled: false
|
|
42
|
+
|
|
27
43
|
Layout/IndentationWidth:
|
|
28
44
|
Enabled: false
|
|
29
45
|
|
|
30
46
|
Layout/IndentationConsistency:
|
|
31
47
|
Enabled: true
|
|
32
|
-
|
|
33
|
-
Layout/
|
|
48
|
+
|
|
49
|
+
Layout/HeredocIndentation:
|
|
34
50
|
Enabled: false
|
|
35
|
-
|
|
51
|
+
|
|
52
|
+
Layout/LineEndStringConcatenationIndentation:
|
|
53
|
+
Enabled: true
|
|
54
|
+
|
|
36
55
|
Layout/MultilineHashBraceLayout:
|
|
37
56
|
Enabled: true
|
|
38
57
|
|
|
58
|
+
Layout/MultilineMethodCallBraceLayout:
|
|
59
|
+
Enabled: true
|
|
60
|
+
EnforcedStyle: same_line
|
|
61
|
+
|
|
39
62
|
Layout/SpaceAroundOperators:
|
|
40
63
|
Enabled: true
|
|
41
64
|
|
|
65
|
+
Layout/SpaceBeforeBrackets:
|
|
66
|
+
Enabled: true
|
|
67
|
+
|
|
42
68
|
Layout/SpaceInsideParens:
|
|
43
69
|
Enabled: true
|
|
44
|
-
|
|
45
|
-
Layout/
|
|
70
|
+
|
|
71
|
+
Layout/IndentationStyle:
|
|
72
|
+
Enabled: true
|
|
73
|
+
|
|
74
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
46
75
|
Enabled: true
|
|
47
|
-
|
|
48
|
-
Layout/
|
|
76
|
+
|
|
77
|
+
Layout/TrailingEmptyLines:
|
|
49
78
|
Enabled: true
|
|
50
79
|
|
|
51
80
|
Layout/TrailingWhitespace:
|
|
52
81
|
Enabled: true
|
|
53
82
|
|
|
83
|
+
Lint/AmbiguousAssignment:
|
|
84
|
+
Enabled: true
|
|
85
|
+
|
|
86
|
+
Lint/AmbiguousRange:
|
|
87
|
+
Enabled: true
|
|
88
|
+
|
|
89
|
+
Lint/DeprecatedConstants:
|
|
90
|
+
Enabled: true
|
|
91
|
+
|
|
92
|
+
Lint/DuplicateBranch:
|
|
93
|
+
Enabled: true
|
|
94
|
+
|
|
95
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
|
96
|
+
Enabled: true
|
|
97
|
+
|
|
98
|
+
Lint/EmptyBlock:
|
|
99
|
+
Enabled: true
|
|
100
|
+
|
|
101
|
+
Lint/EmptyClass:
|
|
102
|
+
Enabled: false
|
|
103
|
+
|
|
104
|
+
Lint/EmptyInPattern:
|
|
105
|
+
Enabled: true
|
|
106
|
+
|
|
107
|
+
Lint/LambdaWithoutLiteralBlock:
|
|
108
|
+
Enabled: true
|
|
109
|
+
|
|
54
110
|
Lint/Loop:
|
|
55
111
|
Enabled: true
|
|
56
112
|
|
|
113
|
+
Lint/NoReturnInBeginEndBlocks:
|
|
114
|
+
Enabled: true
|
|
115
|
+
|
|
116
|
+
Lint/NumberedParameterAssignment:
|
|
117
|
+
Enabled: true
|
|
118
|
+
|
|
119
|
+
Lint/OrAssignmentToConstant:
|
|
120
|
+
Enabled: true
|
|
121
|
+
|
|
122
|
+
Lint/RaiseException:
|
|
123
|
+
Enabled: true
|
|
124
|
+
|
|
125
|
+
Lint/RedundantDirGlobSort:
|
|
126
|
+
Enabled: true
|
|
127
|
+
|
|
57
128
|
Lint/RescueException:
|
|
58
129
|
Enabled: true
|
|
59
130
|
|
|
131
|
+
Lint/StructNewOverride:
|
|
132
|
+
Enabled: true
|
|
133
|
+
|
|
134
|
+
Lint/SymbolConversion:
|
|
135
|
+
Enabled: true
|
|
136
|
+
|
|
137
|
+
Lint/ToEnumArguments:
|
|
138
|
+
Enabled: true
|
|
139
|
+
|
|
140
|
+
Lint/TripleQuotes:
|
|
141
|
+
Enabled: true
|
|
142
|
+
|
|
143
|
+
Lint/UnexpectedBlockArity:
|
|
144
|
+
Enabled: true
|
|
145
|
+
|
|
146
|
+
Lint/UnmodifiedReduceAccumulator:
|
|
147
|
+
Enabled: true
|
|
148
|
+
|
|
60
149
|
Lint/UnusedMethodArgument:
|
|
61
150
|
Enabled: true
|
|
62
151
|
|
|
@@ -76,20 +165,24 @@ Metrics/BlockLength:
|
|
|
76
165
|
Enabled: true
|
|
77
166
|
Max: 350
|
|
78
167
|
|
|
168
|
+
Metrics/BlockNesting:
|
|
169
|
+
Enabled: true
|
|
170
|
+
Max: 5
|
|
171
|
+
|
|
79
172
|
Metrics/ClassLength:
|
|
80
173
|
Enabled: true
|
|
81
|
-
Max:
|
|
174
|
+
Max: 450
|
|
82
175
|
|
|
83
176
|
Metrics/CyclomaticComplexity:
|
|
84
177
|
Enabled: false
|
|
85
178
|
|
|
86
|
-
|
|
179
|
+
Layout/LineLength:
|
|
87
180
|
Enabled: false
|
|
88
181
|
Max: 90
|
|
89
182
|
|
|
90
183
|
Metrics/MethodLength:
|
|
91
184
|
Enabled: true
|
|
92
|
-
Max:
|
|
185
|
+
Max: 60
|
|
93
186
|
|
|
94
187
|
Metrics/ModuleLength:
|
|
95
188
|
Enabled: true
|
|
@@ -103,11 +196,17 @@ Naming/ConstantName:
|
|
|
103
196
|
|
|
104
197
|
Naming/ClassAndModuleCamelCase:
|
|
105
198
|
Enabled: false
|
|
106
|
-
|
|
107
|
-
Naming/
|
|
199
|
+
|
|
200
|
+
Naming/BlockParameterName:
|
|
108
201
|
Enabled: true
|
|
109
|
-
|
|
110
|
-
Naming/
|
|
202
|
+
|
|
203
|
+
Naming/InclusiveLanguage:
|
|
204
|
+
Enabled: true
|
|
205
|
+
|
|
206
|
+
Naming/MethodParameterName:
|
|
207
|
+
Enabled: false
|
|
208
|
+
|
|
209
|
+
Naming/MethodName:
|
|
111
210
|
Enabled: false
|
|
112
211
|
|
|
113
212
|
Naming/VariableName:
|
|
@@ -116,8 +215,8 @@ Naming/VariableName:
|
|
|
116
215
|
Style/Alias:
|
|
117
216
|
Enabled: true
|
|
118
217
|
|
|
119
|
-
|
|
120
|
-
Enabled:
|
|
218
|
+
Style/ArgumentsForwarding:
|
|
219
|
+
Enabled: true
|
|
121
220
|
|
|
122
221
|
Style/AsciiComments:
|
|
123
222
|
Enabled: false
|
|
@@ -137,6 +236,9 @@ Style/ClassCheck:
|
|
|
137
236
|
Style/ClassVars:
|
|
138
237
|
Enabled: false
|
|
139
238
|
|
|
239
|
+
Style/CollectionCompact:
|
|
240
|
+
Enabled: true
|
|
241
|
+
|
|
140
242
|
Style/ColonMethodCall:
|
|
141
243
|
Enabled: false
|
|
142
244
|
|
|
@@ -155,44 +257,195 @@ Style/DefWithParentheses:
|
|
|
155
257
|
Style/Documentation:
|
|
156
258
|
Enabled: false
|
|
157
259
|
|
|
260
|
+
Style/DocumentDynamicEvalDefinition:
|
|
261
|
+
Enabled: false
|
|
262
|
+
|
|
158
263
|
Style/ExpandPathArguments:
|
|
159
264
|
Enabled: false
|
|
160
265
|
|
|
266
|
+
Style/ExponentialNotation:
|
|
267
|
+
Enabled: true
|
|
268
|
+
|
|
161
269
|
Style/GuardClause:
|
|
162
270
|
Enabled: false
|
|
163
271
|
|
|
272
|
+
Style/HashEachMethods:
|
|
273
|
+
Enabled: true
|
|
274
|
+
|
|
275
|
+
Style/HashExcept:
|
|
276
|
+
Enabled: true
|
|
277
|
+
|
|
278
|
+
Style/HashTransformKeys:
|
|
279
|
+
Enabled: true
|
|
280
|
+
|
|
281
|
+
Style/HashTransformValues:
|
|
282
|
+
Enabled: true
|
|
283
|
+
|
|
164
284
|
Style/IfUnlessModifier:
|
|
165
285
|
Enabled: false
|
|
166
286
|
|
|
287
|
+
Style/InPatternThen:
|
|
288
|
+
Enabled: true
|
|
289
|
+
|
|
167
290
|
Style/InverseMethods:
|
|
291
|
+
Enabled: false
|
|
292
|
+
|
|
293
|
+
Style/MissingRespondToMissing:
|
|
294
|
+
Enabled: false
|
|
295
|
+
|
|
296
|
+
Style/MultilineInPatternThen:
|
|
297
|
+
Enabled: true
|
|
298
|
+
|
|
299
|
+
Style/NegatedIfElseCondition:
|
|
168
300
|
Enabled: true
|
|
169
301
|
|
|
170
302
|
Style/Next:
|
|
171
303
|
Enabled: false
|
|
172
304
|
|
|
305
|
+
Style/NilLambda:
|
|
306
|
+
Enabled: true
|
|
307
|
+
|
|
308
|
+
Style/NumericLiterals:
|
|
309
|
+
Enabled: false
|
|
310
|
+
|
|
311
|
+
Style/QuotedSymbols:
|
|
312
|
+
Enabled: true
|
|
313
|
+
|
|
173
314
|
Style/RaiseArgs:
|
|
174
315
|
Enabled: true
|
|
175
316
|
|
|
317
|
+
Style/RedundantArgument:
|
|
318
|
+
Enabled: true
|
|
319
|
+
|
|
176
320
|
Style/RedundantReturn:
|
|
177
321
|
Enabled: false
|
|
178
|
-
|
|
322
|
+
|
|
179
323
|
Style/RedundantSelf:
|
|
180
324
|
Enabled: true
|
|
181
325
|
|
|
326
|
+
Style/RedundantSelfAssignmentBranch:
|
|
327
|
+
Enabled: true
|
|
328
|
+
|
|
182
329
|
Style/RegexpLiteral:
|
|
183
330
|
Enabled: false
|
|
184
331
|
|
|
185
332
|
Style/PercentLiteralDelimiters:
|
|
186
333
|
Enabled: false
|
|
187
|
-
|
|
334
|
+
|
|
188
335
|
Style/StderrPuts:
|
|
189
|
-
Enabled: false
|
|
336
|
+
Enabled: false
|
|
190
337
|
|
|
191
338
|
Style/StringLiterals:
|
|
192
339
|
Enabled: true
|
|
193
340
|
|
|
341
|
+
Style/SwapValues:
|
|
342
|
+
Enabled: true
|
|
343
|
+
|
|
194
344
|
Style/TernaryParentheses:
|
|
195
345
|
Enabled: false
|
|
196
|
-
|
|
346
|
+
|
|
197
347
|
Style/UnlessElse:
|
|
198
|
-
Enabled: false
|
|
348
|
+
Enabled: false
|
|
349
|
+
|
|
350
|
+
# Rubocop complains when it doesn't find an explicit setting for the following cops:
|
|
351
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
352
|
+
Enabled: true
|
|
353
|
+
|
|
354
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
|
355
|
+
Enabled: true
|
|
356
|
+
|
|
357
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
358
|
+
Enabled: true
|
|
359
|
+
|
|
360
|
+
Lint/DuplicateElsifCondition:
|
|
361
|
+
Enabled: true
|
|
362
|
+
|
|
363
|
+
Lint/DuplicateRescueException:
|
|
364
|
+
Enabled: true
|
|
365
|
+
|
|
366
|
+
Lint/EmptyConditionalBody:
|
|
367
|
+
Enabled: true
|
|
368
|
+
|
|
369
|
+
Lint/FloatComparison:
|
|
370
|
+
Enabled: true
|
|
371
|
+
|
|
372
|
+
Lint/MissingSuper:
|
|
373
|
+
Enabled: true
|
|
374
|
+
|
|
375
|
+
Lint/MixedRegexpCaptureTypes:
|
|
376
|
+
Enabled: true
|
|
377
|
+
|
|
378
|
+
Lint/OutOfRangeRegexpRef:
|
|
379
|
+
Enabled: true
|
|
380
|
+
|
|
381
|
+
Lint/SelfAssignment:
|
|
382
|
+
Enabled: true
|
|
383
|
+
|
|
384
|
+
Lint/TopLevelReturnWithArgument:
|
|
385
|
+
Enabled: true
|
|
386
|
+
|
|
387
|
+
Lint/UnreachableLoop:
|
|
388
|
+
Enabled: true
|
|
389
|
+
|
|
390
|
+
Style/AccessorGrouping:
|
|
391
|
+
Enabled: true
|
|
392
|
+
|
|
393
|
+
Style/ArrayCoercion:
|
|
394
|
+
Enabled: true
|
|
395
|
+
|
|
396
|
+
Style/BisectedAttrAccessor:
|
|
397
|
+
Enabled: true
|
|
398
|
+
|
|
399
|
+
Style/CaseLikeIf:
|
|
400
|
+
Enabled: true
|
|
401
|
+
|
|
402
|
+
Style/EndlessMethod:
|
|
403
|
+
Enabled: true
|
|
404
|
+
|
|
405
|
+
Style/ExplicitBlockArgument:
|
|
406
|
+
Enabled: true
|
|
407
|
+
|
|
408
|
+
Style/GlobalStdStream:
|
|
409
|
+
Enabled: true
|
|
410
|
+
|
|
411
|
+
Style/HashAsLastArrayItem:
|
|
412
|
+
Enabled: true
|
|
413
|
+
|
|
414
|
+
Style/HashConversion:
|
|
415
|
+
Enabled: true
|
|
416
|
+
|
|
417
|
+
Style/HashLikeCase:
|
|
418
|
+
Enabled: true
|
|
419
|
+
|
|
420
|
+
Style/IfWithBooleanLiteralBranches:
|
|
421
|
+
Enabled: true
|
|
422
|
+
|
|
423
|
+
Style/OptionalBooleanParameter:
|
|
424
|
+
Enabled: true
|
|
425
|
+
|
|
426
|
+
Style/RedundantAssignment:
|
|
427
|
+
Enabled: true
|
|
428
|
+
|
|
429
|
+
Style/RedundantFetchBlock:
|
|
430
|
+
Enabled: true
|
|
431
|
+
|
|
432
|
+
Style/RedundantFileExtensionInRequire:
|
|
433
|
+
Enabled: true
|
|
434
|
+
|
|
435
|
+
Style/RedundantRegexpCharacterClass:
|
|
436
|
+
Enabled: true
|
|
437
|
+
|
|
438
|
+
Style/RedundantRegexpEscape:
|
|
439
|
+
Enabled: true
|
|
440
|
+
|
|
441
|
+
Style/SingleArgumentDig:
|
|
442
|
+
Enabled: true
|
|
443
|
+
|
|
444
|
+
Style/SlicingWithRange:
|
|
445
|
+
Enabled: true
|
|
446
|
+
|
|
447
|
+
Style/StringChars:
|
|
448
|
+
Enabled: true
|
|
449
|
+
|
|
450
|
+
Style/StringConcatenation:
|
|
451
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
## [0.4.7] - 2021-08-24
|
|
2
|
+
- Updated dependencies (Ruby >= 2.5), (Rley >= 0.8.02)
|
|
3
|
+
- Code restyling to please rubocop 1.19.1.
|
|
4
|
+
### Changed
|
|
5
|
+
- File `srl_ruby.gemspec` Updated the dependencies
|
|
6
|
+
- File `.rubocop.yml` Added configuration for newest cops
|
|
7
|
+
|
|
1
8
|
## [0.4.6] - 2019-08-17
|
|
2
|
-
- Code refactoring to use string frozen magic comments (as a consequence,
|
|
9
|
+
- Code refactoring to use string frozen magic comments (as a consequence, skeem runs only on Rubies 2.3 or newer).
|
|
3
10
|
- Code restyling to please rubocop 0.7.40.
|
|
4
11
|
### Changed
|
|
5
12
|
- File `README.md` updated note on compatibility with Rubies
|
data/Rakefile
CHANGED
data/bin/srl2ruby
CHANGED
|
@@ -12,7 +12,11 @@ class Srl2RubyProg
|
|
|
12
12
|
DefaultSRLExtension = 'srl'
|
|
13
13
|
DefDirname = '/templates'
|
|
14
14
|
DefTemplate = 'base.erb'
|
|
15
|
+
|
|
16
|
+
# @return [Hash]
|
|
15
17
|
attr_reader(:cli_options)
|
|
18
|
+
|
|
19
|
+
# @return [ERB]
|
|
16
20
|
attr_reader(:template)
|
|
17
21
|
|
|
18
22
|
def initialize(prog_name, args)
|
|
@@ -49,18 +53,16 @@ class Srl2RubyProg
|
|
|
49
53
|
fname = cli_options[:template]
|
|
50
54
|
exists = File.exist?(fname)
|
|
51
55
|
if exists
|
|
52
|
-
t_filepath = Dir.getwd
|
|
56
|
+
t_filepath = "#{Dir.getwd}/#{fname}"
|
|
53
57
|
else
|
|
54
|
-
t_filepath = def_template_dir
|
|
58
|
+
t_filepath = "#{def_template_dir}/#{fname}"
|
|
55
59
|
exit(1) unless file_exist?(t_filepath)
|
|
56
60
|
end
|
|
57
61
|
else
|
|
58
|
-
t_filepath = def_template_dir
|
|
62
|
+
t_filepath = "#{def_template_dir}/#{DefTemplate}"
|
|
59
63
|
end
|
|
60
64
|
path = Pathname.new(t_filepath)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
erb_template
|
|
65
|
+
ERB.new(path.read, nil, '<>')
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
def validate_filename(raw_fname)
|
data/bin/srl2ruby_cli_parser.rb
CHANGED
|
@@ -37,7 +37,7 @@ class Srl2RubyCLIParser < OptionParser
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def description
|
|
40
|
-
|
|
40
|
+
<<-DESCR
|
|
41
41
|
Description:
|
|
42
42
|
Parses a SRL file and compiles it into a Ruby Regexp literal.
|
|
43
43
|
Simple Regex Language (SRL) website: https://simple-regex.com
|
|
@@ -47,8 +47,6 @@ Examples:
|
|
|
47
47
|
#{program_name} -p 'begin with literally "Hello world!"'
|
|
48
48
|
#{program_name} example.srl -o example_re.rb -t srl_and_ruby.erb
|
|
49
49
|
DESCR
|
|
50
|
-
|
|
51
|
-
descr
|
|
52
50
|
end
|
|
53
51
|
|
|
54
52
|
def heading
|
data/lib/regex/alternation.rb
CHANGED
|
@@ -19,9 +19,7 @@ module Regex # This module is used as a namespace
|
|
|
19
19
|
# Purpose: Return the String representation of the concatented expressions.
|
|
20
20
|
def text_repr
|
|
21
21
|
result_children = children.map(&:to_str)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return result
|
|
22
|
+
"(?:#{result_children.join('|')})"
|
|
25
23
|
end
|
|
26
24
|
end # class
|
|
27
25
|
end # module
|
data/lib/regex/anchor.rb
CHANGED
|
@@ -8,6 +8,8 @@ module Regex # This module is used as a namespace
|
|
|
8
8
|
# An association between a capture variable and an expression
|
|
9
9
|
# the subject text in the same serial arrangement
|
|
10
10
|
class CapturingGroup < MonadicExpression
|
|
11
|
+
# rubocop: disable Style/OptionalBooleanParameter
|
|
12
|
+
|
|
11
13
|
# The capture variable id. It is a Fixnum when the capture group gets
|
|
12
14
|
# a sequence number,
|
|
13
15
|
# a String when it is an user-defined name
|
|
@@ -42,12 +44,13 @@ module Regex # This module is used as a namespace
|
|
|
42
44
|
atomic = no_backtrack ? '?>' : ''
|
|
43
45
|
if child.is_a?(Regex::NonCapturingGroup)
|
|
44
46
|
# Minor optimization
|
|
45
|
-
|
|
47
|
+
suffix = child.child.to_str
|
|
46
48
|
else
|
|
47
|
-
|
|
49
|
+
suffix = child.to_str
|
|
48
50
|
end
|
|
49
|
-
|
|
51
|
+
"(#{atomic}#{prefix}#{suffix})"
|
|
50
52
|
end
|
|
53
|
+
# rubocop: enable Style/OptionalBooleanParameter
|
|
51
54
|
end # class
|
|
52
55
|
end # module
|
|
53
56
|
|
data/lib/regex/char_class.rb
CHANGED
data/lib/regex/char_range.rb
CHANGED
|
@@ -34,9 +34,7 @@ module Regex # This module is used as a namespace
|
|
|
34
34
|
# Conversion method re-definition.
|
|
35
35
|
# Purpose: Return the String representation of the concatented expressions.
|
|
36
36
|
def text_repr
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return result
|
|
37
|
+
"#{lower.to_str}-#{upper.to_str}"
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
private
|
data/lib/regex/char_shorthand.rb
CHANGED
data/lib/regex/character.rb
CHANGED
data/lib/regex/expression.rb
CHANGED
|
@@ -7,7 +7,10 @@ require_relative 'abstract_method'
|
|
|
7
7
|
module Regex # This module is used as a namespace
|
|
8
8
|
# Abstract class. The generalization of any valid regular (sub)expression.
|
|
9
9
|
class Expression
|
|
10
|
+
# @return [NilClass, Anchor]
|
|
10
11
|
attr_accessor :begin_anchor
|
|
12
|
+
|
|
13
|
+
# @return [NilClass, Anchor]
|
|
11
14
|
attr_accessor :end_anchor
|
|
12
15
|
|
|
13
16
|
# Constructor
|
data/lib/regex/lookaround.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Regex # This module is used as a namespace
|
|
|
42
42
|
def to_str
|
|
43
43
|
dir_syntax = (dir == :ahead) ? '' : '<'
|
|
44
44
|
kind_syntax = (kind == :positive) ? '=' : '!'
|
|
45
|
-
result =
|
|
45
|
+
result = "(?#{dir_syntax}#{kind_syntax}#{child.to_str})"
|
|
46
46
|
return result
|
|
47
47
|
end
|
|
48
48
|
end # class
|
data/lib/regex/multiplicity.rb
CHANGED
|
@@ -50,16 +50,13 @@ module Regex # This module is used as a namespace
|
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
when :possessive
|
|
59
|
-
'+'
|
|
60
|
-
end
|
|
53
|
+
policy2suffix = {
|
|
54
|
+
greedy: '',
|
|
55
|
+
lazy: '?',
|
|
56
|
+
possessive: '+'
|
|
57
|
+
}
|
|
61
58
|
|
|
62
|
-
return subresult +
|
|
59
|
+
return subresult + policy2suffix[policy]
|
|
63
60
|
end
|
|
64
61
|
|
|
65
62
|
private
|
|
@@ -22,7 +22,7 @@ module Regex # This module is used as a namespace
|
|
|
22
22
|
# Conversion method re-definition.
|
|
23
23
|
# Purpose: Return the String representation of the captured expression.
|
|
24
24
|
def text_repr
|
|
25
|
-
result =
|
|
25
|
+
result = "(?:#{all_child_text})"
|
|
26
26
|
return result
|
|
27
27
|
end
|
|
28
28
|
end # class
|
data/lib/regex/quantifiable.rb
CHANGED
data/lib/regex/wildcard.rb
CHANGED
|
@@ -7,11 +7,6 @@ require_relative 'atomic_expression' # Access the superclass
|
|
|
7
7
|
module Regex # This module is used as a namespace
|
|
8
8
|
# A wildcard matches any character (except for the newline).
|
|
9
9
|
class Wildcard < AtomicExpression
|
|
10
|
-
# Constructor
|
|
11
|
-
def initialize
|
|
12
|
-
super
|
|
13
|
-
end
|
|
14
|
-
|
|
15
10
|
protected
|
|
16
11
|
|
|
17
12
|
# Conversion method re-definition.
|
data/lib/srl_ruby/ast_builder.rb
CHANGED
|
@@ -68,6 +68,8 @@ module SrlRuby
|
|
|
68
68
|
return Regex::Multiplicity.new(lowerBound, upperBound, :greedy)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
# rubocop: disable Style/OptionalBooleanParameter
|
|
72
|
+
|
|
71
73
|
def string_literal(aString, to_escape = true)
|
|
72
74
|
if aString.size > 1
|
|
73
75
|
chars = []
|
|
@@ -88,6 +90,7 @@ module SrlRuby
|
|
|
88
90
|
|
|
89
91
|
return result
|
|
90
92
|
end
|
|
93
|
+
# rubocop: enable Style/OptionalBooleanParameter
|
|
91
94
|
|
|
92
95
|
def char_range(lowerBound, upperBound)
|
|
93
96
|
lower = Regex::Character.new(lowerBound)
|
data/lib/srl_ruby/grammar.rb
CHANGED
|
@@ -5,7 +5,7 @@ require 'rley' # Load the gem
|
|
|
5
5
|
module SrlRuby
|
|
6
6
|
########################################
|
|
7
7
|
# SRL grammar
|
|
8
|
-
builder = Rley::
|
|
8
|
+
builder = Rley::Notation::GrammarBuilder.new do
|
|
9
9
|
# Separators...
|
|
10
10
|
add_terminals('LPAREN', 'RPAREN', 'COMMA')
|
|
11
11
|
|
|
@@ -32,33 +32,33 @@ module SrlRuby
|
|
|
32
32
|
|
|
33
33
|
# Grammar rules...
|
|
34
34
|
rule('srl' => 'expression').as 'start_rule'
|
|
35
|
-
rule('expression' =>
|
|
35
|
+
rule('expression' => 'pattern flags').as 'flagged_expr'
|
|
36
36
|
rule('expression' => 'pattern').as 'simple_expr'
|
|
37
|
-
rule('pattern' =>
|
|
37
|
+
rule('pattern' => 'pattern separator sub_pattern').as 'pattern_sequence'
|
|
38
38
|
rule('pattern' => 'sub_pattern').as 'basic_pattern'
|
|
39
39
|
rule('sub_pattern' => 'quantifiable').as 'quantifiable_sub_pattern'
|
|
40
40
|
rule('sub_pattern' => 'assertion').as 'assertion_sub_pattern'
|
|
41
41
|
rule('separator' => 'COMMA').as 'comma_separator'
|
|
42
42
|
rule('separator' => []).as 'void_separator'
|
|
43
|
-
rule('flags' =>
|
|
44
|
-
rule('flags' =>
|
|
45
|
-
rule('single_flag' =>
|
|
46
|
-
rule('single_flag' =>
|
|
47
|
-
rule('single_flag' =>
|
|
48
|
-
rule('quantifiable' =>
|
|
49
|
-
rule('quantifiable' =>
|
|
50
|
-
rule('quantifiable' =>
|
|
43
|
+
rule('flags' => 'flags separator single_flag').as 'flag_sequence'
|
|
44
|
+
rule('flags' => 'separator single_flag').as 'flag_simple'
|
|
45
|
+
rule('single_flag' => 'CASE INSENSITIVE').as 'case_insensitive'
|
|
46
|
+
rule('single_flag' => 'MULTI LINE').as 'multi_line'
|
|
47
|
+
rule('single_flag' => 'ALL LAZY').as 'all_lazy'
|
|
48
|
+
rule('quantifiable' => 'begin_anchor anchorable end_anchor').as 'pinned_quantifiable'
|
|
49
|
+
rule('quantifiable' => 'begin_anchor anchorable').as 'begin_anchor_quantifiable'
|
|
50
|
+
rule('quantifiable' => 'anchorable end_anchor').as 'end_anchor_quantifiable'
|
|
51
51
|
rule('quantifiable' => 'anchorable').as 'simple_quantifiable'
|
|
52
|
-
rule('begin_anchor' =>
|
|
53
|
-
rule('begin_anchor' =>
|
|
54
|
-
rule('end_anchor' =>
|
|
52
|
+
rule('begin_anchor' => 'STARTS WITH').as 'starts_with'
|
|
53
|
+
rule('begin_anchor' => 'BEGIN WITH').as 'begin_with'
|
|
54
|
+
rule('end_anchor' => 'separator MUST END').as 'end_anchor'
|
|
55
55
|
rule('anchorable' => 'assertable').as 'simple_anchorable'
|
|
56
|
-
rule('assertion' =>
|
|
57
|
-
rule('assertion' =>
|
|
58
|
-
rule('assertion' =>
|
|
59
|
-
rule('assertion' =>
|
|
56
|
+
rule('assertion' => 'IF FOLLOWED BY assertable').as 'if_followed'
|
|
57
|
+
rule('assertion' => 'IF NOT FOLLOWED BY assertable').as 'if_not_followed'
|
|
58
|
+
rule('assertion' => 'IF ALREADY HAD assertable').as 'if_had'
|
|
59
|
+
rule('assertion' => 'IF NOT ALREADY HAD assertable').as 'if_not_had'
|
|
60
60
|
rule('assertable' => 'term').as 'simple_assertable'
|
|
61
|
-
rule('assertable' =>
|
|
61
|
+
rule('assertable' => 'term quantifier').as 'quantified_assertable'
|
|
62
62
|
rule('term' => 'atom').as 'atom_term'
|
|
63
63
|
rule('term' => 'alternation').as 'alternation_term'
|
|
64
64
|
rule('term' => 'grouping').as 'grouping_term'
|
|
@@ -69,20 +69,20 @@ module SrlRuby
|
|
|
69
69
|
rule('atom' => 'special_char').as 'special_char_atom'
|
|
70
70
|
rule('atom' => 'literal').as 'literal_atom'
|
|
71
71
|
rule('atom' => 'raw').as 'raw_atom'
|
|
72
|
-
rule('letter_range' =>
|
|
73
|
-
rule('letter_range' =>
|
|
72
|
+
rule('letter_range' => 'LETTER FROM LETTER_LIT TO LETTER_LIT').as 'lowercase_from_to'
|
|
73
|
+
rule('letter_range' => 'UPPERCASE LETTER FROM LETTER_LIT TO LETTER_LIT').as 'uppercase_from_to'
|
|
74
74
|
rule('letter_range' => 'LETTER').as 'any_lowercase'
|
|
75
|
-
rule('letter_range' =>
|
|
76
|
-
rule('digit_range' =>
|
|
77
|
-
rule('character_class' =>
|
|
78
|
-
rule('character_class' =>
|
|
75
|
+
rule('letter_range' => 'UPPERCASE LETTER').as 'any_uppercase'
|
|
76
|
+
rule('digit_range' => 'digit_or_number FROM DIGIT_LIT TO DIGIT_LIT').as 'digits_from_to'
|
|
77
|
+
rule('character_class' => 'ANY CHARACTER').as 'any_character'
|
|
78
|
+
rule('character_class' => 'NO CHARACTER').as 'no_character'
|
|
79
79
|
rule('character_class' => 'digit_or_number').as 'digit'
|
|
80
|
-
rule('character_class' =>
|
|
80
|
+
rule('character_class' => 'NO DIGIT').as 'non_digit'
|
|
81
81
|
rule('character_class' => 'WHITESPACE').as 'whitespace'
|
|
82
|
-
rule('character_class' =>
|
|
82
|
+
rule('character_class' => 'NO WHITESPACE').as 'no_whitespace'
|
|
83
83
|
rule('character_class' => 'ANYTHING').as 'anything'
|
|
84
|
-
rule('character_class' =>
|
|
85
|
-
rule('character_class' =>
|
|
84
|
+
rule('character_class' => 'ONE OF cclass').as 'one_of'
|
|
85
|
+
rule('character_class' => 'NONE OF cclass').as 'none_of'
|
|
86
86
|
rule('cclass' => 'STRING_LIT').as 'quoted_cclass' # Preferred syntax
|
|
87
87
|
rule('cclass' => 'INTEGER').as 'digits_cclass'
|
|
88
88
|
rule('cclass' => 'IDENTIFIER').as 'identifier_cclass'
|
|
@@ -90,32 +90,32 @@ module SrlRuby
|
|
|
90
90
|
rule('special_char' => 'TAB').as 'tab'
|
|
91
91
|
rule('special_char' => 'VERTICAL TAB').as 'vtab'
|
|
92
92
|
rule('special_char' => 'BACKSLASH').as 'backslash'
|
|
93
|
-
rule('special_char' =>
|
|
94
|
-
rule('special_char' =>
|
|
95
|
-
rule('special_char' =>
|
|
96
|
-
rule('special_char' =>
|
|
97
|
-
rule('literal' =>
|
|
93
|
+
rule('special_char' => 'NEW LINE').as 'new_line'
|
|
94
|
+
rule('special_char' => 'CARRIAGE RETURN').as 'carriage_return'
|
|
95
|
+
rule('special_char' => 'WORD').as 'word'
|
|
96
|
+
rule('special_char' => 'NO WORD').as 'no_word'
|
|
97
|
+
rule('literal' => 'LITERALLY STRING_LIT').as 'literally'
|
|
98
98
|
rule('raw' => 'RAW STRING_LIT').as 'raw_literal'
|
|
99
|
-
rule('alternation' =>
|
|
100
|
-
rule('alternatives' =>
|
|
99
|
+
rule('alternation' => 'any_or_either OF LPAREN alternatives RPAREN').as 'any_of'
|
|
100
|
+
rule('alternatives' => 'alternatives separator quantifiable').as 'alternative_list'
|
|
101
101
|
rule('alternatives' => 'quantifiable').as 'simple_alternative'
|
|
102
102
|
rule('any_or_either' => 'ANY').as 'any_keyword'
|
|
103
103
|
rule('any_or_either' => 'EITHER').as 'either_keyword'
|
|
104
|
-
rule('grouping' =>
|
|
105
|
-
rule('capturing_group' =>
|
|
106
|
-
rule('capturing_group' =>
|
|
107
|
-
rule('capturing_group' =>
|
|
108
|
-
rule('capturing_group' =>
|
|
104
|
+
rule('grouping' => 'LPAREN pattern RPAREN').as 'grouping_parenthenses'
|
|
105
|
+
rule('capturing_group' => 'CAPTURE assertable').as 'capture'
|
|
106
|
+
rule('capturing_group' => 'CAPTURE assertable UNTIL assertable').as 'capture_until'
|
|
107
|
+
rule('capturing_group' => 'CAPTURE assertable AS var_name').as 'named_capture'
|
|
108
|
+
rule('capturing_group' => 'CAPTURE assertable AS var_name UNTIL assertable').as 'named_capture_until'
|
|
109
109
|
rule('var_name' => 'STRING_LIT').as 'var_name'
|
|
110
110
|
rule('var_name' => 'IDENTIFIER').as 'var_ident' # capture name not enclosed between quotes
|
|
111
111
|
rule('quantifier' => 'ONCE').as 'once'
|
|
112
112
|
rule('quantifier' => 'TWICE').as 'twice'
|
|
113
|
-
rule('quantifier' =>
|
|
114
|
-
rule('quantifier' =>
|
|
113
|
+
rule('quantifier' => 'EXACTLY count TIMES').as 'exactly'
|
|
114
|
+
rule('quantifier' => 'BETWEEN count AND count times_suffix').as 'between_and'
|
|
115
115
|
rule('quantifier' => 'OPTIONAL').as 'optional'
|
|
116
|
-
rule('quantifier' =>
|
|
117
|
-
rule('quantifier' =>
|
|
118
|
-
rule('quantifier' =>
|
|
116
|
+
rule('quantifier' => 'ONCE OR MORE').as 'once_or_more'
|
|
117
|
+
rule('quantifier' => 'NEVER OR MORE').as 'never_or_more'
|
|
118
|
+
rule('quantifier' => 'AT LEAST count TIMES').as 'at_least'
|
|
119
119
|
rule('digit_or_number' => 'DIGIT').as 'digit_keyword'
|
|
120
120
|
rule('digit_or_number' => 'NUMBER').as 'number_keyword'
|
|
121
121
|
rule('count' => 'DIGIT_LIT').as 'single_digit'
|
data/lib/srl_ruby/tokenizer.rb
CHANGED
|
@@ -17,10 +17,14 @@ module SrlRuby
|
|
|
17
17
|
# Delimiters: parentheses '(' and ')'
|
|
18
18
|
# Separators: comma (optional)
|
|
19
19
|
class Tokenizer
|
|
20
|
+
# @return [StringScanner]
|
|
20
21
|
attr_reader(:scanner)
|
|
22
|
+
|
|
23
|
+
# @return [Integer] current line number
|
|
21
24
|
attr_reader(:lineno)
|
|
25
|
+
|
|
26
|
+
# @return [Integer] offset of start of current line within input
|
|
22
27
|
attr_reader(:line_start)
|
|
23
|
-
# attr_reader(:column)
|
|
24
28
|
|
|
25
29
|
@@lexeme2name = {
|
|
26
30
|
'(' => 'LPAREN',
|
|
@@ -86,7 +90,7 @@ module SrlRuby
|
|
|
86
90
|
WHITESPACE
|
|
87
91
|
WITH
|
|
88
92
|
WORD
|
|
89
|
-
].map { |x| [x, x] }
|
|
93
|
+
].map { |x| [x, x] }.to_h
|
|
90
94
|
|
|
91
95
|
class ScanError < StandardError; end
|
|
92
96
|
|
data/lib/srl_ruby/version.rb
CHANGED
|
@@ -7,20 +7,20 @@ require 'rley' # Load the Rley gem
|
|
|
7
7
|
# [File format](https://github.com/SimpleRegex/Test-Rules/blob/master/README.md)
|
|
8
8
|
########################################
|
|
9
9
|
# Define a grammar for basic arithmetical expressions
|
|
10
|
-
builder = Rley::
|
|
10
|
+
builder = Rley::Notation::GrammarBuilder.new do
|
|
11
11
|
# Punctuation
|
|
12
12
|
add_terminals('COLON', 'DASH')
|
|
13
13
|
|
|
14
14
|
# Keywords
|
|
15
15
|
add_terminals('CAPTURE', 'FOR')
|
|
16
|
-
add_terminals('MATCH
|
|
16
|
+
add_terminals('MATCH', 'NO', 'SRL')
|
|
17
17
|
|
|
18
18
|
# Literals
|
|
19
19
|
add_terminals('INTEGER', 'STRING_LIT')
|
|
20
20
|
add_terminals('IDENTIFIER', 'SRL_SOURCE')
|
|
21
21
|
|
|
22
22
|
rule('rule_file' => 'srl_heading srl_tests').as 'start_rule'
|
|
23
|
-
rule('srl_heading' => 'SRL
|
|
23
|
+
rule('srl_heading' => 'SRL SRL_SOURCE').as 'srl_source'
|
|
24
24
|
rule('srl_tests' => 'srl_tests single_test').as 'test_list'
|
|
25
25
|
rule('srl_tests' => 'single_test').as 'one_test'
|
|
26
26
|
rule('single_test' => 'atomic_test').as 'single_atomic_test'
|
|
@@ -28,8 +28,8 @@ builder = Rley::Syntax::GrammarBuilder.new do
|
|
|
28
28
|
rule('atomic_test' => 'match_test').as 'atomic_match'
|
|
29
29
|
rule('atomic_test' => 'no_match_test').as 'atomic_no_match'
|
|
30
30
|
rule('compound_test' => 'capture_test').as 'compound_capture'
|
|
31
|
-
rule('match_test' => 'MATCH
|
|
32
|
-
rule('no_match_test' => 'NO MATCH
|
|
31
|
+
rule('match_test' => 'MATCH STRING_LIT').as 'match_string'
|
|
32
|
+
rule('no_match_test' => 'NO MATCH STRING_LIT').as 'no_match_string'
|
|
33
33
|
rule('capture_test' => 'capture_heading capture_expectations').as 'capture_test'
|
|
34
34
|
rule('capture_heading' => 'CAPTURE FOR STRING_LIT COLON').as 'capture_string'
|
|
35
35
|
rule('capture_expectations' => 'capture_expectations single_expectation').as 'assertion_list'
|
|
@@ -16,8 +16,13 @@ module Acceptance
|
|
|
16
16
|
# Delimiters: parentheses '(' and ')'
|
|
17
17
|
# Separators: comma (optional)
|
|
18
18
|
class RuleFileTokenizer
|
|
19
|
+
# @return [StringScanner]
|
|
19
20
|
attr_reader(:scanner)
|
|
21
|
+
|
|
22
|
+
# @return [Integer] current line number
|
|
20
23
|
attr_reader(:lineno)
|
|
24
|
+
|
|
25
|
+
# @return [Integer] offset of start of current line within input
|
|
21
26
|
attr_reader(:line_start)
|
|
22
27
|
|
|
23
28
|
# Can be :default, :expecting_srl
|
|
@@ -82,7 +87,7 @@ module Acceptance
|
|
|
82
87
|
elsif (lexeme = scanner.scan(/[0-9]+/))
|
|
83
88
|
token = build_token('INTEGER', lexeme)
|
|
84
89
|
elsif (lexeme = scanner.scan(/srl:|match:/))
|
|
85
|
-
token = build_token(@@keywords[lexeme], lexeme)
|
|
90
|
+
token = build_token(@@keywords[lexeme].chop, lexeme.chop)
|
|
86
91
|
@state = :expecting_srl if lexeme == 'srl:'
|
|
87
92
|
elsif (lexeme = scanner.scan(/[a-zA-Z_][a-zA-Z0-9_]*/))
|
|
88
93
|
keyw = @@keywords[lexeme]
|
|
@@ -6,6 +6,8 @@ require_relative '../../lib/regex/character'
|
|
|
6
6
|
|
|
7
7
|
module Regex # Open this namespace, to get rid of scope qualifiers
|
|
8
8
|
describe Character do
|
|
9
|
+
# rubocop: disable Lint/ConstantDefinitionInBlock
|
|
10
|
+
|
|
9
11
|
# This constant holds an arbitrary selection of characters
|
|
10
12
|
SampleChars = [?a, ?\0, ?\u0107].freeze
|
|
11
13
|
|
|
@@ -116,6 +118,13 @@ module Regex # Open this namespace, to get rid of scope qualifiers
|
|
|
116
118
|
end
|
|
117
119
|
end
|
|
118
120
|
|
|
121
|
+
# Create a module that re-defines the existing to_s method
|
|
122
|
+
module Tweak_to_s
|
|
123
|
+
def to_s # Overwrite the existing to_s method
|
|
124
|
+
?\u03a3
|
|
125
|
+
end
|
|
126
|
+
end # module
|
|
127
|
+
|
|
119
128
|
it 'should known whether it is equal to another Object' do
|
|
120
129
|
newOne = Character.new(?\u03a3)
|
|
121
130
|
|
|
@@ -147,12 +156,6 @@ module Regex # Open this namespace, to get rid of scope qualifiers
|
|
|
147
156
|
expect(simulator).to receive(:to_s).and_return(?\u03a3)
|
|
148
157
|
expect(newOne).to eq(simulator)
|
|
149
158
|
|
|
150
|
-
# Create a module that re-defines the existing to_s method
|
|
151
|
-
module Tweak_to_s
|
|
152
|
-
def to_s # Overwrite the existing to_s method
|
|
153
|
-
?\u03a3
|
|
154
|
-
end
|
|
155
|
-
end # module
|
|
156
159
|
weird = Object.new
|
|
157
160
|
weird.extend(Tweak_to_s)
|
|
158
161
|
expect(newOne).to eq(weird)
|
|
@@ -166,6 +169,7 @@ module Regex # Open this namespace, to get rid of scope qualifiers
|
|
|
166
169
|
expect(ch2.explain).to eq("the character '\u03a3'")
|
|
167
170
|
end
|
|
168
171
|
end # context
|
|
172
|
+
# rubocop: enable Lint/ConstantDefinitionInBlock
|
|
169
173
|
end # describe
|
|
170
174
|
end # module
|
|
171
175
|
|
|
@@ -23,6 +23,7 @@ module Regex # This module is used as a namespace
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
context 'Provided services' do
|
|
26
|
+
# rubocop: disable Style/CombinableLoops
|
|
26
27
|
it 'should know its text representation' do
|
|
27
28
|
policy2text = { greedy: '', lazy: '?', possessive: '+' }
|
|
28
29
|
|
|
@@ -73,6 +74,7 @@ module Regex # This module is used as a namespace
|
|
|
73
74
|
end
|
|
74
75
|
end
|
|
75
76
|
end
|
|
77
|
+
# rubocop: enable Style/CombinableLoops
|
|
76
78
|
end
|
|
77
79
|
end
|
|
78
80
|
end # module
|
data/spec/srl_ruby_spec.rb
CHANGED
|
@@ -226,7 +226,7 @@ SRL
|
|
|
226
226
|
let(:prefix) { 'letter from p to t ' }
|
|
227
227
|
|
|
228
228
|
it "should parse 'once' syntax" do
|
|
229
|
-
regexp = SrlRuby.parse(prefix
|
|
229
|
+
regexp = SrlRuby.parse("#{prefix}once")
|
|
230
230
|
expect(regexp.source).to eq('[p-t]{1}')
|
|
231
231
|
end
|
|
232
232
|
|
|
@@ -246,26 +246,26 @@ SRL
|
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
it "should parse 'between ... and ... times' syntax" do
|
|
249
|
-
regexp = SrlRuby.parse(prefix
|
|
249
|
+
regexp = SrlRuby.parse("#{prefix}between 2 and 4 times")
|
|
250
250
|
expect(regexp.source).to eq('[p-t]{2,4}')
|
|
251
251
|
|
|
252
252
|
# Dropping 'times' keyword is a shorter alternative syntax
|
|
253
|
-
regexp = SrlRuby.parse(prefix
|
|
253
|
+
regexp = SrlRuby.parse("#{prefix}between 2 and 4")
|
|
254
254
|
expect(regexp.source).to eq('[p-t]{2,4}')
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
it "should parse 'once or more' syntax" do
|
|
258
|
-
regexp = SrlRuby.parse(prefix
|
|
258
|
+
regexp = SrlRuby.parse("#{prefix}once or more")
|
|
259
259
|
expect(regexp.source).to eq('[p-t]+')
|
|
260
260
|
end
|
|
261
261
|
|
|
262
262
|
it "should parse 'never or more' syntax" do
|
|
263
|
-
regexp = SrlRuby.parse(prefix
|
|
263
|
+
regexp = SrlRuby.parse("#{prefix}never or more")
|
|
264
264
|
expect(regexp.source).to eq('[p-t]*')
|
|
265
265
|
end
|
|
266
266
|
|
|
267
267
|
it "should parse 'at least ... times' syntax" do
|
|
268
|
-
regexp = SrlRuby.parse(prefix
|
|
268
|
+
regexp = SrlRuby.parse("#{prefix}at least 10 times")
|
|
269
269
|
expect(regexp.source).to eq('[p-t]{10,}')
|
|
270
270
|
end
|
|
271
271
|
end # context
|
data/srl_ruby.gemspec
CHANGED
|
@@ -65,13 +65,13 @@ SUMMARY
|
|
|
65
65
|
spec.require_paths = ['lib']
|
|
66
66
|
PkgExtending.pkg_files(spec)
|
|
67
67
|
PkgExtending.pkg_documentation(spec)
|
|
68
|
-
spec.required_ruby_version = '>= 2.
|
|
68
|
+
spec.required_ruby_version = '>= 2.5.0'
|
|
69
69
|
|
|
70
70
|
# Runtime dependencies
|
|
71
|
-
spec.add_dependency 'rley', '~> 0.
|
|
71
|
+
spec.add_dependency 'rley', '~> 0.8.02'
|
|
72
72
|
|
|
73
73
|
# Development dependencies
|
|
74
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
|
74
|
+
spec.add_development_dependency 'bundler', '~> 2.1.0'
|
|
75
75
|
spec.add_development_dependency 'cucumber', '>= 2.2.0'
|
|
76
76
|
spec.add_development_dependency 'rake', '~> 12.0'
|
|
77
77
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: srl_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dimitri Geshef
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rley
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.8.02
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.8.02
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.
|
|
33
|
+
version: 2.1.0
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.
|
|
40
|
+
version: 2.1.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: cucumber
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -190,7 +190,7 @@ homepage: https://github.com/famished-tiger/SRL-Ruby
|
|
|
190
190
|
licenses:
|
|
191
191
|
- MIT
|
|
192
192
|
metadata: {}
|
|
193
|
-
post_install_message:
|
|
193
|
+
post_install_message:
|
|
194
194
|
rdoc_options:
|
|
195
195
|
- --charset=UTF-8 --exclude="examples|spec"
|
|
196
196
|
require_paths:
|
|
@@ -199,15 +199,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
199
199
|
requirements:
|
|
200
200
|
- - ">="
|
|
201
201
|
- !ruby/object:Gem::Version
|
|
202
|
-
version: 2.
|
|
202
|
+
version: 2.5.0
|
|
203
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
204
|
requirements:
|
|
205
205
|
- - ">="
|
|
206
206
|
- !ruby/object:Gem::Version
|
|
207
207
|
version: '0'
|
|
208
208
|
requirements: []
|
|
209
|
-
rubygems_version: 3.
|
|
210
|
-
signing_key:
|
|
209
|
+
rubygems_version: 3.1.4
|
|
210
|
+
signing_key:
|
|
211
211
|
specification_version: 4
|
|
212
212
|
summary: A parser for the [Simple Regex Language](https://simple-regex.com/). It translates
|
|
213
213
|
patterns expressed in SRL into plain Ruby Regexp objects or in regex literals. Use
|