srl_ruby 0.4.11 → 0.4.13

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a2509164bd980bf2145d41c15281608694674f633b2a6f2b482b6298db7d36a
4
- data.tar.gz: 3112162a2a27268dd4d0c1e8cf4b0af25b98a158152e7ceca9e9d5f34c347c96
3
+ metadata.gz: a1aca92632a6d6009140d3df47adbacc96ec7237b665c8c7677192134b0dbffa
4
+ data.tar.gz: 4d9b6f2143a4d37b2092a179406aec2a5bfacff28e67383ce933a9f533cd1666
5
5
  SHA512:
6
- metadata.gz: 51099a1c625930c9e139079f73647524caf6db7ed23ccdcdee475a720dcdb238d4e48ad0632f6ec7b0cee8e57785a25ce7b5f4232c605811f382a95d11b31afa
7
- data.tar.gz: a4a7383ce66944d5b5c834200a8e5b2367660912a93daaca13dc27eb95fd56f0b655317c575a4013dd5e69b22af804a4dcbfb5ce5a5804249bf78d7495d5a4e9
6
+ metadata.gz: f154f7efc63ee2130369cc1f95e7d02d9883f13f747001c612851e2cc7cda964062a908015f5e2a852912587f35443ccbaef7163667644acd7bbf67de4d8835b
7
+ data.tar.gz: 4cfe10c6fcabe4b04ebb12da4e91eef6e416539dc6f54a9e590b8e1458fae3be284ca1c5d2d58be0dfa9d22ec8cbd4720674d1eb637ee8c3861781e7490cdd6d
data/.rubocop.yml CHANGED
@@ -2,12 +2,14 @@ AllCops:
2
2
  Exclude:
3
3
  - 'exp/**/*'
4
4
  - 'demo/**/*'
5
+ NewCops: enable
6
+ SuggestExtensions: false
7
+
8
+ Gemspec/DevelopmentDependencies:
9
+ EnforcedStyle: gemspec
5
10
 
6
- Gemspec/DateAssignment:
7
- Enabled: true
8
-
9
11
  Gemspec/RequireMFA: # new in 1.23
10
- Enabled: false
12
+ Enabled: true
11
13
 
12
14
  Layout/ArgumentAlignment:
13
15
  Enabled: false
@@ -47,136 +49,19 @@ Layout/HashAlignment:
47
49
  Layout/IndentationWidth:
48
50
  Enabled: false
49
51
 
50
- Layout/IndentationConsistency:
51
- Enabled: true
52
-
53
52
  Layout/HeredocIndentation:
54
53
  Enabled: false
55
54
 
56
- Layout/LineEndStringConcatenationIndentation:
57
- Enabled: true
58
-
59
- Layout/MultilineHashBraceLayout:
60
- Enabled: true
61
-
62
55
  Layout/MultilineMethodCallBraceLayout:
63
56
  Enabled: true
64
57
  EnforcedStyle: same_line
65
58
 
66
- Layout/SpaceAroundOperators:
67
- Enabled: true
68
-
69
- Layout/SpaceBeforeBrackets:
70
- Enabled: true
71
-
72
- Layout/SpaceInsideParens:
73
- Enabled: true
74
-
75
- Layout/IndentationStyle:
76
- Enabled: true
77
-
78
- Layout/SpaceAroundMethodCallOperator:
79
- Enabled: true
80
-
81
- Layout/TrailingEmptyLines:
82
- Enabled: true
83
-
84
- Layout/TrailingWhitespace:
85
- Enabled: true
86
-
87
- Lint/AmbiguousAssignment:
88
- Enabled: true
89
-
90
- Lint/AmbiguousOperatorPrecedence: # new in 1.21
91
- Enabled: true
92
-
93
- Lint/AmbiguousRange:
94
- Enabled: true
95
-
96
- Lint/DeprecatedConstants:
97
- Enabled: true
98
-
99
- Lint/DuplicateBranch:
100
- Enabled: true
101
-
102
- Lint/DuplicateRegexpCharacterClassElement:
103
- Enabled: true
104
-
105
- Lint/EmptyBlock:
106
- Enabled: true
107
-
108
59
  Lint/EmptyClass:
109
60
  Enabled: false
110
61
 
111
- Lint/EmptyInPattern:
112
- Enabled: true
113
-
114
- Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
115
- Enabled: true
116
-
117
- Lint/LambdaWithoutLiteralBlock:
118
- Enabled: true
119
-
120
- Lint/Loop:
121
- Enabled: true
122
-
123
- Lint/NoReturnInBeginEndBlocks:
124
- Enabled: true
125
-
126
- Lint/NumberedParameterAssignment:
127
- Enabled: true
128
-
129
- Lint/OrAssignmentToConstant:
130
- Enabled: true
131
-
132
- Lint/RaiseException:
133
- Enabled: true
134
-
135
- Lint/RedundantDirGlobSort:
136
- Enabled: true
137
-
138
- Lint/RefinementImportMethods: # new in 1.27
139
- Enabled: true
140
-
141
- Lint/RequireRelativeSelfPath: # new in 1.22
142
- Enabled: true
143
-
144
- Lint/RescueException:
145
- Enabled: true
146
-
147
- Lint/StructNewOverride:
148
- Enabled: true
149
-
150
- Lint/SymbolConversion:
151
- Enabled: true
152
-
153
- Lint/ToEnumArguments:
154
- Enabled: true
155
-
156
- Lint/TripleQuotes:
157
- Enabled: true
158
-
159
- Lint/UnexpectedBlockArity:
160
- Enabled: true
161
-
162
- Lint/UnmodifiedReduceAccumulator:
163
- Enabled: true
164
-
165
- Lint/UnusedMethodArgument:
166
- Enabled: true
167
-
168
- Lint/UselessAccessModifier:
169
- Enabled: true
170
-
171
- Lint/UselessRuby2Keywords: # new in 1.23
172
- Enabled: true
173
-
174
62
  Lint/Void:
175
63
  Enabled: false
176
64
 
177
- Lint/UselessAssignment:
178
- Enabled: true
179
-
180
65
  Metrics/AbcSize:
181
66
  Enabled: false
182
67
 
@@ -215,15 +100,6 @@ Naming/ConstantName:
215
100
 
216
101
  Naming/ClassAndModuleCamelCase:
217
102
  Enabled: false
218
-
219
- Naming/BlockForwarding: # new in 1.24
220
- Enabled: true
221
-
222
- Naming/BlockParameterName:
223
- Enabled: true
224
-
225
- Naming/InclusiveLanguage:
226
- Enabled: true
227
103
 
228
104
  Naming/MethodParameterName:
229
105
  Enabled: false
@@ -234,15 +110,6 @@ Naming/MethodName:
234
110
  Naming/VariableName:
235
111
  Enabled: false
236
112
 
237
- Security/IoMethods: # new in 1.22
238
- Enabled: true
239
-
240
- Style/Alias:
241
- Enabled: true
242
-
243
- Style/ArgumentsForwarding:
244
- Enabled: true
245
-
246
113
  Style/AsciiComments:
247
114
  Enabled: false
248
115
 
@@ -276,9 +143,6 @@ Style/CommentedKeyword:
276
143
  Style/ConditionalAssignment:
277
144
  Enabled: false
278
145
 
279
- Style/DefWithParentheses:
280
- Enabled: true
281
-
282
146
  Style/Documentation:
283
147
  Enabled: false
284
148
 
@@ -288,92 +152,23 @@ Style/DocumentDynamicEvalDefinition:
288
152
  Style/ExpandPathArguments:
289
153
  Enabled: false
290
154
 
291
- Style/ExponentialNotation:
292
- Enabled: true
293
-
294
- Style/FileRead: # new in 1.24
295
- Enabled: true
296
-
297
- Style/FileWrite: # new in 1.24
298
- Enabled: true
299
-
300
155
  Style/GuardClause:
301
156
  Enabled: false
302
157
 
303
- Style/HashEachMethods:
304
- Enabled: true
305
-
306
- Style/HashExcept:
307
- Enabled: true
308
-
309
- Style/HashTransformKeys:
310
- Enabled: true
311
-
312
- Style/HashTransformValues:
313
- Enabled: true
314
-
315
158
  Style/IfUnlessModifier:
316
159
  Enabled: false
317
160
 
318
- Style/InPatternThen:
319
- Enabled: true
320
-
321
161
  Style/InverseMethods:
322
162
  Enabled: false
323
-
324
- Style/MapToHash: # new in 1.24
325
- Enabled: true
326
163
 
327
164
  Style/MissingRespondToMissing:
328
165
  Enabled: false
329
166
 
330
- Style/MultilineInPatternThen:
331
- Enabled: true
332
-
333
- Style/NegatedIfElseCondition:
334
- Enabled: true
335
-
336
- Style/NestedFileDirname: # new in 1.26
337
- Enabled: true
338
-
339
167
  Style/Next:
340
168
  Enabled: false
341
169
 
342
- Style/NilLambda:
343
- Enabled: true
344
-
345
- Style/NumberedParameters: # new in 1.22
346
- Enabled: true
347
-
348
- Style/NumberedParametersLimit: # new in 1.22
349
- Enabled: true
350
-
351
170
  Style/NumericLiterals:
352
171
  Enabled: false
353
-
354
- Style/OpenStructUse: # new in 1.23
355
- Enabled: true
356
-
357
- Style/QuotedSymbols:
358
- Enabled: true
359
-
360
- Style/RaiseArgs:
361
- Enabled: true
362
-
363
- Style/RedundantArgument:
364
- Enabled: true
365
-
366
- Style/RedundantInitialize: # new in 1.27
367
- Enabled: true
368
-
369
- Style/RedundantReturn:
370
- Enabled: false
371
-
372
- Style/RedundantSelf:
373
- Enabled: true
374
-
375
- Style/RedundantSelfAssignmentBranch:
376
- Enabled: true
377
172
 
378
173
  Style/RegexpLiteral:
379
174
  Enabled: false
@@ -381,123 +176,11 @@ Style/RegexpLiteral:
381
176
  Style/PercentLiteralDelimiters:
382
177
  Enabled: false
383
178
 
384
- Style/SelectByRegexp: # new in 1.22
385
- Enabled: true
386
-
387
179
  Style/StderrPuts:
388
180
  Enabled: false
389
181
 
390
- Style/StringLiterals:
391
- Enabled: true
392
-
393
- Style/SwapValues:
394
- Enabled: true
395
-
396
182
  Style/TernaryParentheses:
397
183
  Enabled: false
398
184
 
399
185
  Style/UnlessElse:
400
186
  Enabled: false
401
-
402
- # Rubocop complains when it doesn't find an explicit setting for the following cops:
403
- Layout/EmptyLinesAroundAttributeAccessor:
404
- Enabled: true
405
-
406
- Lint/BinaryOperatorWithIdenticalOperands:
407
- Enabled: true
408
-
409
- Lint/DeprecatedOpenSSLConstant:
410
- Enabled: true
411
-
412
- Lint/DuplicateElsifCondition:
413
- Enabled: true
414
-
415
- Lint/DuplicateRescueException:
416
- Enabled: true
417
-
418
- Lint/EmptyConditionalBody:
419
- Enabled: true
420
-
421
- Lint/FloatComparison:
422
- Enabled: true
423
-
424
- Lint/MissingSuper:
425
- Enabled: true
426
-
427
- Lint/MixedRegexpCaptureTypes:
428
- Enabled: true
429
-
430
- Lint/OutOfRangeRegexpRef:
431
- Enabled: true
432
-
433
- Lint/SelfAssignment:
434
- Enabled: true
435
-
436
- Lint/TopLevelReturnWithArgument:
437
- Enabled: true
438
-
439
- Lint/UnreachableLoop:
440
- Enabled: true
441
-
442
- Style/AccessorGrouping:
443
- Enabled: true
444
-
445
- Style/ArrayCoercion:
446
- Enabled: true
447
-
448
- Style/BisectedAttrAccessor:
449
- Enabled: true
450
-
451
- Style/CaseLikeIf:
452
- Enabled: true
453
-
454
- Style/EndlessMethod:
455
- Enabled: true
456
-
457
- Style/ExplicitBlockArgument:
458
- Enabled: true
459
-
460
- Style/GlobalStdStream:
461
- Enabled: true
462
-
463
- Style/HashAsLastArrayItem:
464
- Enabled: true
465
-
466
- Style/HashConversion:
467
- Enabled: true
468
-
469
- Style/HashLikeCase:
470
- Enabled: true
471
-
472
- Style/IfWithBooleanLiteralBranches:
473
- Enabled: true
474
-
475
- Style/OptionalBooleanParameter:
476
- Enabled: true
477
-
478
- Style/RedundantAssignment:
479
- Enabled: true
480
-
481
- Style/RedundantFetchBlock:
482
- Enabled: true
483
-
484
- Style/RedundantFileExtensionInRequire:
485
- Enabled: true
486
-
487
- Style/RedundantRegexpCharacterClass:
488
- Enabled: true
489
-
490
- Style/RedundantRegexpEscape:
491
- Enabled: true
492
-
493
- Style/SingleArgumentDig:
494
- Enabled: true
495
-
496
- Style/SlicingWithRange:
497
- Enabled: true
498
-
499
- Style/StringChars:
500
- Enabled: true
501
-
502
- Style/StringConcatenation:
503
- Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [0.4.13] - 2025-02-22
2
+ - Tested against MRI Ruby 3.4.1
3
+
4
+ ### Changed
5
+ - Shortened `.rubocop.yml` file
6
+
7
+ ### Fixed
8
+ - Fixed all "offences" reported by Rubocop 1.72.2
9
+
10
+ ## [0.4.12] - 2022-04-22
11
+ - Code refactoring.
12
+
13
+ ### Changed
14
+ - Refactoring class `SrlRuby::Tokenizer`: use of manifest constants, simplified newline and whitespace processing.
15
+ - Updated of `.rubocop.yml` to integrate newer cops (from version 1.28)
16
+ - Code refactoring: removal of redundant `return`
17
+
1
18
  ## [0.4.11] - 2022-04-17
2
19
  - Fixed code breaking change in Ruby 3.1+: prime library is no longer part of stdlib.
3
20
 
data/LICENSE.txt CHANGED
@@ -5,7 +5,7 @@ the 'srl_test' directory, which is subject to its own license.
5
5
 
6
6
  The MIT License (MIT)
7
7
 
8
- Copyright (c) 2018-2021 Dimitri Geshef
8
+ Copyright (c) 2018-2025 Dimitri Geshef
9
9
 
10
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
11
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -405,8 +405,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/famish
405
405
 
406
406
  ## License
407
407
 
408
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
409
-
410
- ## Code of Conduct
411
-
412
- Everyone interacting in the SrlRuby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/srl_ruby/blob/master/CODE_OF_CONDUCT.md).
408
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -2,19 +2,18 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task' # Rspec as testing tool
5
- # require 'cucumber/rake/task' # Cucumber as testing tool
5
+ require 'cucumber/rake/task' # Cucumber as testing tool
6
6
 
7
7
  # desc 'Run RSpec'
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
- # Cucumber::Rake::Task.new do |_|
11
- # # Comment
12
- # end
10
+ Cucumber::Rake::Task.new do |_|
11
+ # Comment
12
+ end
13
13
 
14
14
  # Combine RSpec and Cucumber tests
15
15
  desc 'Run tests, with RSpec and Cucumber'
16
- task test: :spec
17
- # task test: %i[spec cucumber]
16
+ task test: %i[spec cucumber]
18
17
 
19
18
 
20
19
  # Default rake task
data/cucumber.yml CHANGED
@@ -1,4 +1,4 @@
1
- default: --strict -v -b --format progress features
1
+ default: --strict -v -b --publish-quiet --format progress features
2
2
 
3
3
 
4
4
 
@@ -17,7 +17,7 @@ module AbstractMethod
17
17
  # end
18
18
  def abstract_method
19
19
  # Determine the short class name of self
20
- className = self.class.name.split(/::/).last
20
+ className = self.class.name.split('::').last
21
21
 
22
22
  # Retrieve the top text line of the call stack
23
23
  top_line = caller(1..1)
@@ -11,7 +11,7 @@ module Regex # This module is used as a namespace
11
11
  # Redefined method.
12
12
  # @return [TrueClass] Return true since it may not have any child.
13
13
  def atomic?
14
- return true
14
+ true
15
15
  end
16
16
 
17
17
  # Notification that the parse tree construction is complete.
@@ -30,9 +30,7 @@ module Regex # This module is used as a namespace
30
30
  end
31
31
  sub_result << child.to_str
32
32
  end
33
- result = "[#{negated ? '^' : ''}#{result_children}]"
34
-
35
- return result
33
+ "[#{negated ? '^' : ''}#{result_children}]"
36
34
  end
37
35
  end # class
38
36
  end # module
@@ -44,7 +44,7 @@ module Regex # This module is used as a namespace
44
44
  msg = 'Character range error: lower bound is greater than upper bound.'
45
45
  raise StandardError, msg if theLowerBound.codepoint > theUpperBound.codepoint
46
46
 
47
- return [theLowerBound, theUpperBound]
47
+ [theLowerBound, theUpperBound]
48
48
  end
49
49
  end # class
50
50
  end # module
@@ -45,7 +45,7 @@ module Regex # This module is used as a namespace
45
45
  msg = "Unknown predefined character class \\#{aShortname}"
46
46
  raise StandardError, msg unless StandardCClasses.include? aShortname
47
47
 
48
- return aShortname
48
+ aShortname
49
49
  end
50
50
  end # class
51
51
  end # module
@@ -93,7 +93,7 @@ module Regex # This module is used as a namespace
93
93
  aChar.ord
94
94
  end
95
95
 
96
- # Convertion method that returns the codepoint for the given escape
96
+ # Conversion method that returns the codepoint for the given escape
97
97
  # sequence (a String).
98
98
  # Recognized escaped characters are: \a (alarm, 0x07), \n (newline, 0xA),
99
99
  # \r (carriage return, 0xD), \t (tab, 0x9), \e (escape, 0x1B), \f (form feed,
@@ -104,12 +104,10 @@ module Regex # This module is used as a namespace
104
104
  # Example:
105
105
  # RegAn::Character::esc2codepoint('\n') # Returns: 0xd
106
106
  def self.esc2codepoint(esc_seq)
107
- msg = "Escape sequence #{esc_seq} does not begin with a backslash (\)."
107
+ msg = "Escape sequence #{esc_seq} does not begin with a backslash (\\)."
108
108
  raise StandardError, msg unless esc_seq[0] == '\\'
109
109
 
110
- result = (esc_seq.length == 2) ? digram2codepoint(esc_seq) : esc_number2codepoint(esc_seq)
111
-
112
- return result
110
+ (esc_seq.length == 2) ? digram2codepoint(esc_seq) : esc_number2codepoint(esc_seq)
113
111
  end
114
112
 
115
113
  # Return the character as a String object
@@ -127,7 +125,7 @@ module Regex # This module is used as a namespace
127
125
  # newOne == 0x03a3 # true. The Integer is compared to the codepoint value.
128
126
  # Will test equality with any Object that knows the to_s method
129
127
  def ==(other)
130
- result = case other
128
+ case other
131
129
  when Character
132
130
  to_str == other.to_str
133
131
 
@@ -141,8 +139,6 @@ module Regex # This module is used as a namespace
141
139
  # Unknown type: try with a convertion
142
140
  self == other.to_s # Recursive call
143
141
  end
144
-
145
- return result
146
142
  end
147
143
 
148
144
  # Return a plain English description of the character
@@ -160,7 +156,7 @@ module Regex # This module is used as a namespace
160
156
  def text_repr
161
157
  return char if lexeme.nil?
162
158
 
163
- return lexeme.dup
159
+ lexeme.dup
164
160
  end
165
161
 
166
162
  # Convertion method that returns a codepoint for the given two characters
@@ -178,7 +174,7 @@ module Regex # This module is used as a namespace
178
174
  # If it not a special sequence, then escaped character is
179
175
  # considered literally (the backslash is 'dummy')
180
176
  result = char2codepoint(aDigram[-1]) if result.nil?
181
- return result
177
+ result
182
178
  end
183
179
 
184
180
  private_class_method :digram2codepoint
@@ -199,7 +195,7 @@ module Regex # This module is used as a namespace
199
195
 
200
196
  # Extract the hexadecimal number
201
197
  hexliteral = hexa # shorterSeq.sub(/^[xXu]\{?([0-9a-fA-F]+)}?$/, '\1')
202
- return hexliteral.hex
198
+ hexliteral.hex
203
199
  end
204
200
  end
205
201
 
@@ -19,11 +19,9 @@ module Regex # This module is used as a namespace
19
19
  # Conversion method re-definition.
20
20
  # Purpose: Return the String representation of the concatented expressions.
21
21
  def text_repr
22
- outcome = children.inject(+'') do |result, child|
22
+ children.inject(+'') do |result, child|
23
23
  result << child.to_str
24
24
  end
25
-
26
- return outcome
27
25
  end
28
26
  end # class
29
27
  end # module
@@ -26,8 +26,7 @@ module Regex # This module is used as a namespace
26
26
  # @param theParentOptions [Hash] matching options. They are overridden
27
27
  # by options with same name that are bound to this object.
28
28
  def options(theParentOptions)
29
- resulting_options = theParentOptions.merge(@local_options)
30
- return resulting_options
29
+ theParentOptions.merge(@local_options)
31
30
  end
32
31
 
33
32
  # Template method.
@@ -38,7 +37,7 @@ module Regex # This module is used as a namespace
38
37
  result << text_repr
39
38
  result << suffix
40
39
 
41
- return result
40
+ result
42
41
  end
43
42
 
44
43
  protected
@@ -42,8 +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 = "(?#{dir_syntax}#{kind_syntax}#{child.to_str})"
46
- return result
45
+ "(?#{dir_syntax}#{kind_syntax}#{child.to_str})"
47
46
  end
48
47
  end # class
49
48
  end # module
@@ -26,7 +26,7 @@ module Regex # This module is used as a namespace
26
26
  result = 0
27
27
  flags.each { |f| result |= f }
28
28
 
29
- return result
29
+ result
30
30
  end
31
31
 
32
32
  # Equality operator
@@ -35,12 +35,12 @@ module Regex # This module is used as a namespace
35
35
  return true if object_id == other.object_id
36
36
 
37
37
  if other.kind_of?(MatchOption)
38
- isEqual = ((flags == other.flags) && (child == other.child))
38
+ isEqual = (flags == other.flags) && (child == other.child)
39
39
  else
40
40
  isEqual = false
41
41
  end
42
42
 
43
- return isEqual
43
+ isEqual
44
44
  end
45
45
 
46
46
  protected
@@ -32,9 +32,7 @@ module Regex # This module is used as a namespace
32
32
 
33
33
  # Return the text representation of the child (if any)
34
34
  def all_child_text
35
- result = child.nil? ? '' : child.to_str
36
-
37
- return result
35
+ child.nil? ? '' : child.to_str
38
36
  end
39
37
  end # class
40
38
  end # module
@@ -56,7 +56,7 @@ module Regex # This module is used as a namespace
56
56
  possessive: '+'
57
57
  }
58
58
 
59
- return subresult + policy2suffix[policy]
59
+ subresult + policy2suffix[policy]
60
60
  end
61
61
 
62
62
  private
@@ -66,7 +66,7 @@ module Regex # This module is used as a namespace
66
66
  err_msg = "Invalid lower bound of repetition count #{aLowerBound}"
67
67
  raise StandardError, err_msg unless aLowerBound.kind_of?(Integer)
68
68
 
69
- return aLowerBound
69
+ aLowerBound
70
70
  end
71
71
 
72
72
  # Validation method. Return the validated lower bound value
@@ -76,7 +76,7 @@ module Regex # This module is used as a namespace
76
76
  raise StandardError, err_msg
77
77
  end
78
78
 
79
- return anUpperBound
79
+ anUpperBound
80
80
  end
81
81
 
82
82
  # Validation method. Return the validated policy value.
@@ -85,7 +85,7 @@ module Regex # This module is used as a namespace
85
85
  valid_policies = %i[greedy lazy possessive]
86
86
  raise StandardError, err_msg unless valid_policies.include? aPolicy
87
87
 
88
- return aPolicy
88
+ aPolicy
89
89
  end
90
90
  end # class
91
91
  end # module
@@ -22,8 +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 = "(?:#{all_child_text})"
26
- return result
25
+ "(?:#{all_child_text})"
27
26
  end
28
27
  end # class
29
28
  end # module
@@ -24,7 +24,7 @@ module Regex # This module is used as a namespace
24
24
  def <<(aChild)
25
25
  @children << aChild
26
26
 
27
- return self
27
+ self
28
28
  end
29
29
 
30
30
  # Notification that the parse tree construction is complete.
@@ -52,7 +52,7 @@ module Regex # This module is used as a namespace
52
52
  def df_visitor
53
53
  root = children # The visit will start from the children of this object
54
54
 
55
- visitor = Enumerator.new do |result| # result is a Yielder
55
+ Enumerator.new do |result| # result is a Yielder
56
56
  # Initialization part: will run once
57
57
  visit_stack = [root] # The LIFO queue of nodes to visit
58
58
 
@@ -78,8 +78,6 @@ module Regex # This module is used as a namespace
78
78
  break if visit_stack.empty?
79
79
  end
80
80
  end
81
-
82
- return visitor
83
81
  end
84
82
  end # class
85
83
  end # module
@@ -8,7 +8,7 @@ module Regex # This module is used as a namespace
8
8
  module Quantifiable
9
9
  # Redefined method. Return true since it may not have any child.
10
10
  def quantified?
11
- return !@quantifier.nil?
11
+ !@quantifier.nil?
12
12
  end
13
13
 
14
14
  def quantifier
@@ -30,8 +30,7 @@ module Regex # This module is used as a namespace
30
30
  # Conversion method re-definition.
31
31
  # @return [String] String representation of the concatented expressions.
32
32
  def text_repr
33
- result = all_child_text + multiplicity.to_str
34
- return result
33
+ all_child_text + multiplicity.to_str
35
34
  end
36
35
  end # class
37
36
  end # module
@@ -19,7 +19,7 @@ module SrlRuby
19
19
  # Create a new AST builder instance.
20
20
  # @param theTokens [Array<Token>] The sequence of input tokens.
21
21
  def initialize(theTokens)
22
- super(theTokens)
22
+ super
23
23
  @options = []
24
24
  end
25
25
 
@@ -59,13 +59,11 @@ module SrlRuby
59
59
  # @param aTokenPosition [Integer] Position of token in the input stream
60
60
  # @param aToken [Rley::Lexical::Token] The input token
61
61
  def new_leaf_node(_production, _terminal, aTokenPosition, aToken)
62
- node = Rley::PTree::TerminalNode.new(aToken, aTokenPosition)
63
-
64
- return node
62
+ Rley::PTree::TerminalNode.new(aToken, aTokenPosition)
65
63
  end
66
64
 
67
65
  def multiplicity(lowerBound, upperBound)
68
- return Regex::Multiplicity.new(lowerBound, upperBound, :greedy)
66
+ Regex::Multiplicity.new(lowerBound, upperBound, :greedy)
69
67
  end
70
68
 
71
69
  # rubocop: disable Style/OptionalBooleanParameter
@@ -88,14 +86,14 @@ module SrlRuby
88
86
  result = Regex::Character.new(aString)
89
87
  end
90
88
 
91
- return result
89
+ result
92
90
  end
93
91
  # rubocop: enable Style/OptionalBooleanParameter
94
92
 
95
93
  def char_range(lowerBound, upperBound)
96
94
  lower = Regex::Character.new(lowerBound)
97
95
  upper = Regex::Character.new(upperBound)
98
- return Regex::CharRange.new(lower, upper)
96
+ Regex::CharRange.new(lower, upper)
99
97
  end
100
98
 
101
99
  def char_class(toNegate, *theChildren)
@@ -283,7 +281,7 @@ module SrlRuby
283
281
  end
284
282
 
285
283
  # TODO check other implementations
286
- return Regex::CharClass.new(false, *alternatives)
284
+ Regex::CharClass.new(false, *alternatives)
287
285
  end
288
286
 
289
287
  # rule('character_class' => %w[NONE OF STRING_LIT]).tag 'none_of'
@@ -337,13 +335,13 @@ module SrlRuby
337
335
  # What if literal is empty?...
338
336
 
339
337
  raw_literal = theChildren[-1].token.lexeme.dup
340
- return string_literal(raw_literal)
338
+ string_literal(raw_literal)
341
339
  end
342
340
 
343
341
  # rule('raw' => %w[RAW STRING_LIT]).tag 'raw_literal'
344
342
  def reduce_raw_literal(_production, _range, _tokens, theChildren)
345
343
  raw_literal = theChildren[-1].token.lexeme.dup
346
- return Regex::RawExpression.new(raw_literal)
344
+ Regex::RawExpression.new(raw_literal)
347
345
  end
348
346
 
349
347
  # rule('alternation' => %w[ANY OF LPAREN alternatives RPAREN]).tag 'any_of'
@@ -358,12 +356,12 @@ module SrlRuby
358
356
  result = Regex::Alternation.new(*theChildren[3])
359
357
  end
360
358
 
361
- return result
359
+ result
362
360
  end
363
361
 
364
362
  # rule('alternatives' => %w[alternatives separator quantifiable]).tag 'alternative_list'
365
363
  def reduce_alternative_list(_production, _range, _tokens, theChildren)
366
- return theChildren[0] << theChildren[-1]
364
+ theChildren[0] << theChildren[-1]
367
365
  end
368
366
 
369
367
  # rule('alternatives' => 'quantifiable').tag 'simple_alternative'
@@ -418,7 +416,7 @@ module SrlRuby
418
416
  make_last_repetition_lazy(theChildren[1])
419
417
  group = Regex::CapturingGroup.new(theChildren[1], name)
420
418
  (_, until_expr) = theChildren[4]
421
- return Regex::Concatenation.new(group, until_expr)
419
+ Regex::Concatenation.new(group, until_expr)
422
420
  end
423
421
 
424
422
  # rule('quantifier' => 'ONCE').tag 'once'
@@ -17,6 +17,16 @@ module SrlRuby
17
17
  # Delimiters: parentheses '(' and ')'
18
18
  # Separators: comma (optional)
19
19
  class Tokenizer
20
+ PATT_CHAR_CLASS = /[^,"\s]{2,}/.freeze
21
+ PATT_DIGIT_LIT = /[0-9]((?=\s|,|\))|$)/.freeze
22
+ PATT_IDENTIFIER = /[a-zA-Z_][a-zA-Z0-9_]+/.freeze
23
+ PATT_INTEGER = /[0-9]{2,}((?=\s|,|\))|$)/.freeze # An integer has 2..* digits
24
+ PATT_LETTER_LIT = /[a-zA-Z]((?=\s|,|\))|$)/.freeze
25
+ PATT_NEWLINE = /(?:\r\n)|\r|\n/.freeze
26
+ PATT_STR_DBL_QUOTE = /"(?:\\"|[^"])*"/.freeze # Double quotes literal?
27
+ PATT_STR_SNGL_QUOTE = /'(?:\\'|[^'])*'/.freeze # Single quotes literal?
28
+ PATT_WHITESPACE = /[ \t\f]+/.freeze
29
+
20
30
  # @return [StringScanner]
21
31
  attr_reader(:scanner)
22
32
 
@@ -26,14 +36,14 @@ module SrlRuby
26
36
  # @return [Integer] offset of start of current line within input
27
37
  attr_reader(:line_start)
28
38
 
29
- @@lexeme2name = {
39
+ Lexeme2name = {
30
40
  '(' => 'LPAREN',
31
41
  ')' => 'RPAREN',
32
42
  ',' => 'COMMA'
33
43
  }.freeze
34
44
 
35
45
  # Here are all the SRL keywords (in uppercase)
36
- @@keywords = %w[
46
+ Keywords = %w[
37
47
  ALL
38
48
  ALREADY
39
49
  AND
@@ -109,47 +119,55 @@ module SrlRuby
109
119
  tok_sequence << token unless token.nil?
110
120
  end
111
121
 
112
- return tok_sequence
122
+ tok_sequence
113
123
  end
114
124
 
115
125
  private
116
126
 
117
127
  def _next_token
118
- skip_whitespaces
119
- curr_ch = scanner.peek(1)
120
- return nil if curr_ch.nil? || curr_ch.empty?
121
-
122
128
  token = nil
123
129
 
124
- if '(),'.include? curr_ch
125
- # Delimiters, separators => single character token
126
- token = build_token(@@lexeme2name[curr_ch], scanner.getch)
127
- elsif (lexeme = scanner.scan(/[0-9]{2,}((?=\s|,|\))|$)/))
128
- token = build_token('INTEGER', lexeme) # An integer has 2..* digits
129
- elsif (lexeme = scanner.scan(/[0-9]((?=\s|,|\))|$)/))
130
- token = build_token('DIGIT_LIT', lexeme)
131
- elsif (lexeme = scanner.scan(/"(?:\\"|[^"])*"/)) # Double quotes literal?
132
- unquoted = lexeme.gsub(/(^")|("$)/, '')
133
- token = build_token('STRING_LIT', unquoted)
134
- elsif (lexeme = scanner.scan(/'(?:\\'|[^'])*'/)) # Single quotes literal?
135
- unquoted = lexeme.gsub(/(^')|('$)/, '')
136
- token = build_token('STRING_LIT', unquoted)
137
- elsif (lexeme = scanner.scan(/[a-zA-Z]((?=\s|,|\))|$)/))
138
- token = build_token('LETTER_LIT', lexeme)
139
- elsif (lexeme = scanner.scan(/[a-zA-Z_][a-zA-Z0-9_]+/))
140
- keyw = @@keywords[lexeme.upcase]
141
- tok_type = keyw || 'IDENTIFIER'
142
- token = build_token(tok_type, lexeme)
143
- elsif (lexeme = scanner.scan(/[^,"\s]{2,}/))
144
- token = build_token('CHAR_CLASS', lexeme)
145
- else # Unknown token
146
- erroneous = curr_ch.nil? ? '' : scanner.scan(/./)
147
- sequel = scanner.scan(/.{1,20}/)
148
- erroneous += sequel unless sequel.nil?
149
- raise ScanError, "Unknown token #{erroneous} on line #{lineno}"
150
- end
130
+ # Loop until end of input reached or token found
131
+ until token || scanner.eos?
132
+
133
+ if scanner.skip(PATT_NEWLINE)
134
+ next_line_scanned
135
+ next
136
+ end
137
+ next if scanner.skip(PATT_WHITESPACE) # Skip whitespaces
138
+
139
+ curr_ch = scanner.peek(1)
140
+
141
+ token = if '(),'.include? curr_ch
142
+ # Delimiters, separators => single character token
143
+ build_token(Lexeme2name[curr_ch], scanner.getch)
144
+ elsif (lexeme = scanner.scan(PATT_INTEGER))
145
+ build_token('INTEGER', lexeme)
146
+ elsif (lexeme = scanner.scan(PATT_DIGIT_LIT))
147
+ build_token('DIGIT_LIT', lexeme)
148
+ elsif (lexeme = scanner.scan(PATT_STR_DBL_QUOTE))
149
+ unquoted = lexeme.gsub(/(^")|("$)/, '')
150
+ build_token('STRING_LIT', unquoted)
151
+ elsif (lexeme = scanner.scan(PATT_STR_SNGL_QUOTE))
152
+ unquoted = lexeme.gsub(/(^')|('$)/, '')
153
+ build_token('STRING_LIT', unquoted)
154
+ elsif (lexeme = scanner.scan(PATT_LETTER_LIT))
155
+ build_token('LETTER_LIT', lexeme)
156
+ elsif (lexeme = scanner.scan(PATT_IDENTIFIER))
157
+ keyw = Keywords[lexeme.upcase]
158
+ tok_type = keyw || 'IDENTIFIER'
159
+ build_token(tok_type, lexeme)
160
+ elsif (lexeme = scanner.scan(PATT_CHAR_CLASS))
161
+ build_token('CHAR_CLASS', lexeme)
162
+ else # Unknown token
163
+ erroneous = curr_ch.nil? ? '' : scanner.scan(/./)
164
+ sequel = scanner.scan(/.{1,20}/)
165
+ erroneous += sequel unless sequel.nil?
166
+ raise ScanError, "Unknown token #{erroneous} on line #{lineno}"
167
+ end
168
+ end # until
151
169
 
152
- return token
170
+ token
153
171
  end
154
172
 
155
173
  def build_token(aSymbolName, aLexeme)
@@ -162,38 +180,13 @@ module SrlRuby
162
180
  raise e
163
181
  end
164
182
 
165
- return token
166
- end
167
-
168
- def skip_whitespaces
169
- pre_pos = scanner.pos
170
-
171
- loop do
172
- ws_found = false
173
- found = scanner.skip(/[ \t\f]+/)
174
- ws_found = true if found
175
- found = scanner.skip(/(?:\r\n)|\r|\n/)
176
- if found
177
- ws_found = true
178
- @lineno += 1
179
- @line_start = scanner.pos
180
- end
181
- break unless ws_found
182
- end
183
-
184
- curr_pos = scanner.pos
185
- return if curr_pos == pre_pos
186
- # skipped = scanner.string.slice(Range.new(pre_pos, curr_pos))
187
- # triplet = skipped.rpartition(/\n|\r/)
188
- # @column = 1 unless triplet[1].empty?
189
-
190
- # Correction for the tabs
191
- # tab_count = triplet[2].chars.count { |ch| ch =~ /\t/ }
192
- # @column += triplet[2].size + tab_count * (tab_size - 1) - 1
183
+ token
193
184
  end
194
185
 
195
- def tab_size
196
- 2
186
+ # Event: next line detected.
187
+ def next_line_scanned
188
+ @lineno += 1
189
+ @line_start = scanner.pos
197
190
  end
198
191
  end # class
199
192
  end # module
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SrlRuby
4
- VERSION = '0.4.11'
4
+ VERSION = '0.4.13'
5
5
  end
data/lib/srl_ruby.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './srl_ruby/version'
4
- require_relative './srl_ruby/tokenizer'
5
- require_relative './srl_ruby/grammar'
6
- require_relative './srl_ruby/ast_builder'
3
+ require_relative 'srl_ruby/version'
4
+ require_relative 'srl_ruby/tokenizer'
5
+ require_relative 'srl_ruby/grammar'
6
+ require_relative 'srl_ruby/ast_builder'
7
7
 
8
8
  module SrlRuby
9
9
  # Compile the SRL expression in given filename into a Regexp object.
@@ -14,7 +14,7 @@ module SrlRuby
14
14
  File.open(filename, 'r') { |f| source = f.read }
15
15
  return source if source.nil? || source.empty?
16
16
 
17
- return parse(source)
17
+ parse(source)
18
18
  end
19
19
 
20
20
  # Compile the given SRL expression into its Regexp equivalent.
@@ -52,6 +52,6 @@ module SrlRuby
52
52
  # Now output the regexp literal
53
53
  root = ast_ptree.root
54
54
  options = root.is_a?(Regex::MatchOption) ? root.combine_opts : nil
55
- return Regexp.new(root.to_str, options)
55
+ Regexp.new(root.to_str, options)
56
56
  end
57
57
  end # module
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../spec_helper'
4
- require_relative './support/rule_file_parser'
4
+ require_relative 'support/rule_file_parser'
5
5
  require_relative '../../lib/srl_ruby'
6
6
 
7
7
  ##############################
@@ -46,7 +46,7 @@ module Acceptance
46
46
  end
47
47
  end
48
48
 
49
- return rule_file
49
+ rule_file
50
50
  end
51
51
 
52
52
  # rule('srl_heading' => %w[SRL: SRL_SOURCE]).as 'srl_source'
@@ -14,7 +14,7 @@ module Acceptance # This module is used as a namespace
14
14
  File.open(filename, 'r') { |f| source = f.read }
15
15
  return source if source.nil? || source.empty?
16
16
 
17
- return parse(source)
17
+ parse(source)
18
18
  end
19
19
 
20
20
  # Parse the rule file
@@ -41,8 +41,7 @@ module Acceptance # This module is used as a namespace
41
41
  ast_ptree = engine.convert(result)
42
42
 
43
43
  # Now output the regexp literal
44
- root = ast_ptree.root
45
- return root
44
+ ast_ptree.root
46
45
  end
47
46
  end
48
47
  end # module
@@ -4,7 +4,6 @@
4
4
  # Tokenizer for SimpleRegex Test-Rule files
5
5
  # [File format](https://github.com/SimpleRegex/Test-Rules/blob/master/README.md)
6
6
  require 'strscan'
7
- require 'pp'
8
7
  require 'rley'
9
8
 
10
9
  module Acceptance
@@ -58,7 +57,7 @@ module Acceptance
58
57
  tok_sequence << token unless token.nil?
59
58
  end
60
59
 
61
- return tok_sequence
60
+ tok_sequence
62
61
  end
63
62
 
64
63
  private
@@ -68,13 +67,11 @@ module Acceptance
68
67
  curr_ch = scanner.peek(1)
69
68
  return nil if curr_ch.nil? || curr_ch.empty?
70
69
 
71
- token = if state == :default
70
+ if state == :default
72
71
  default_mode
73
72
  else
74
73
  expecting_srl
75
74
  end
76
-
77
- return token
78
75
  end
79
76
 
80
77
  def default_mode
@@ -103,7 +100,7 @@ module Acceptance
103
100
  raise ScanError, "Unknown token #{erroneous}"
104
101
  end
105
102
 
106
- return token
103
+ token
107
104
  end
108
105
 
109
106
  def expecting_srl
@@ -123,7 +120,7 @@ module Acceptance
123
120
  raise e
124
121
  end
125
122
 
126
- return token
123
+ token
127
124
  end
128
125
 
129
126
  def skip_noise
@@ -152,7 +149,7 @@ module Acceptance
152
149
  end
153
150
 
154
151
  curr_pos = scanner.pos
155
- return curr_pos != pre_pos
152
+ curr_pos != pre_pos
156
153
  end
157
154
 
158
155
  def skip_comment
data/srl_ruby.gemspec CHANGED
@@ -65,7 +65,7 @@ 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.5.0'
68
+ spec.required_ruby_version = '>= 3.2.0'
69
69
 
70
70
  # Runtime dependencies
71
71
  spec.add_dependency 'rley', '~> 0.8.11'
@@ -75,4 +75,5 @@ SUMMARY
75
75
  spec.add_development_dependency 'cucumber', '>= 3.1.2'
76
76
  spec.add_development_dependency 'rake', '>= 12.0'
77
77
  spec.add_development_dependency 'rspec', '~> 3.0'
78
+ spec.metadata = { 'rubygems_mfa_required' => 'true' }
78
79
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srl_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-04-17 00:00:00.000000000 Z
10
+ date: 2025-02-22 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rley
@@ -189,8 +188,8 @@ files:
189
188
  homepage: https://github.com/famished-tiger/SRL-Ruby
190
189
  licenses:
191
190
  - MIT
192
- metadata: {}
193
- post_install_message:
191
+ metadata:
192
+ rubygems_mfa_required: 'true'
194
193
  rdoc_options:
195
194
  - --charset=UTF-8 --exclude="examples|spec"
196
195
  require_paths:
@@ -199,15 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
198
  requirements:
200
199
  - - ">="
201
200
  - !ruby/object:Gem::Version
202
- version: 2.5.0
201
+ version: 3.2.0
203
202
  required_rubygems_version: !ruby/object:Gem::Requirement
204
203
  requirements:
205
204
  - - ">="
206
205
  - !ruby/object:Gem::Version
207
206
  version: '0'
208
207
  requirements: []
209
- rubygems_version: 3.3.7
210
- signing_key:
208
+ rubygems_version: 3.6.2
211
209
  specification_version: 4
212
210
  summary: A parser for the [Simple Regex Language](https://simple-regex.com/). It translates
213
211
  patterns expressed in SRL into plain Ruby Regexp objects or in regex literals. Use