srl_ruby 0.4.6 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb518e00a96315122ae3bcc125af089a37d9631dbb5c3af8ba10f244382acb8f
4
- data.tar.gz: 4f9eb678fb49a30cd60a9d6b49f703de06e7d9fb993a9605b5c36c89cff92953
3
+ metadata.gz: 32a18d724b0eaeff828ffc7fa2413834ea9e16dd1c46a06af7d5438c56fec159
4
+ data.tar.gz: 628b07343fdd3da4a2903b48b392ce6b52880e68ad0f229efd0d702abe3a90df
5
5
  SHA512:
6
- metadata.gz: ac09784a223162a0b2f5b1d4ec5a20a8b95efaa916ea1e7279a6dcdefd79f7b36488161abbba44fc2c619fa722096f5c705467236c66c39335b45e4415084dfb
7
- data.tar.gz: daa15a338b751afc3ce2b9b0c5cd018eaae1e720d7d921da60be89264d01239c4f8504c44ebc37fa0cf32755cd7d2316e077bd487b6d9703ddde5acceb2039e8
6
+ metadata.gz: 376fa359b54c5f5434c70ca9d855d718bfb933e30c5cdf29409f23ee3113659577b5680c073e091ca42c7e3ed0c68836ed9120fb93aa3d2be1a78cdcae08d8fb
7
+ data.tar.gz: 256f800715bc35d61cf134cddb91f199455357712e5f197d271e7efaebb6e745c66970d4a02935dd6f6779f22eb9309af744f0de47e78226bed924ae22885847
data/.rubocop.yml CHANGED
@@ -1,10 +1,21 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - 'exp/**/*'
4
+ - 'demo/**/*'
5
+
6
+ Gemspec/DateAssignment:
7
+ Enabled: true
8
+
9
+ Layout/ArgumentAlignment:
10
+ Enabled: false
11
+
12
+ Layout/ArrayAlignment:
13
+ Enabled: true
14
+ EnforcedStyle: with_fixed_indentation
4
15
 
5
16
  Layout/CaseIndentation:
6
17
  Enabled: false
7
-
18
+
8
19
  Layout/ClosingHeredocIndentation:
9
20
  Enabled: false
10
21
 
@@ -16,7 +27,7 @@ Layout/ElseAlignment:
16
27
 
17
28
  Layout/EmptyLines:
18
29
  Enabled: false
19
-
30
+
20
31
  Layout/EndAlignment:
21
32
  Enabled: false
22
33
 
@@ -24,39 +35,127 @@ Layout/EndOfLine:
24
35
  Enabled: true
25
36
  EnforcedStyle: lf
26
37
 
38
+ Layout/FirstArgumentIndentation:
39
+ Enabled: false
40
+
41
+ Layout/HashAlignment:
42
+ Enabled: false
43
+
27
44
  Layout/IndentationWidth:
28
45
  Enabled: false
29
46
 
30
47
  Layout/IndentationConsistency:
31
48
  Enabled: true
32
-
33
- Layout/IndentHeredoc:
49
+
50
+ Layout/HeredocIndentation:
34
51
  Enabled: false
35
-
52
+
53
+ Layout/LineEndStringConcatenationIndentation:
54
+ Enabled: true
55
+
36
56
  Layout/MultilineHashBraceLayout:
37
57
  Enabled: true
38
58
 
59
+ Layout/MultilineMethodCallBraceLayout:
60
+ Enabled: true
61
+ EnforcedStyle: same_line
62
+
39
63
  Layout/SpaceAroundOperators:
40
64
  Enabled: true
41
65
 
66
+ Layout/SpaceBeforeBrackets:
67
+ Enabled: true
68
+
42
69
  Layout/SpaceInsideParens:
43
70
  Enabled: true
44
-
45
- Layout/Tab:
71
+
72
+ Layout/IndentationStyle:
73
+ Enabled: true
74
+
75
+ Layout/SpaceAroundMethodCallOperator:
46
76
  Enabled: true
47
-
48
- Layout/TrailingBlankLines:
77
+
78
+ Layout/TrailingEmptyLines:
49
79
  Enabled: true
50
80
 
51
81
  Layout/TrailingWhitespace:
52
82
  Enabled: true
53
83
 
84
+ Lint/AmbiguousAssignment:
85
+ Enabled: true
86
+
87
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
88
+ Enabled: true
89
+
90
+ Lint/AmbiguousRange:
91
+ Enabled: true
92
+
93
+ Lint/DeprecatedConstants:
94
+ Enabled: true
95
+
96
+ Lint/DuplicateBranch:
97
+ Enabled: true
98
+
99
+ Lint/DuplicateRegexpCharacterClassElement:
100
+ Enabled: true
101
+
102
+ Lint/EmptyBlock:
103
+ Enabled: true
104
+
105
+ Lint/EmptyClass:
106
+ Enabled: false
107
+
108
+ Lint/EmptyInPattern:
109
+ Enabled: true
110
+
111
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
112
+ Enabled: true
113
+
114
+ Lint/LambdaWithoutLiteralBlock:
115
+ Enabled: true
116
+
54
117
  Lint/Loop:
55
118
  Enabled: true
56
119
 
120
+ Lint/NoReturnInBeginEndBlocks:
121
+ Enabled: true
122
+
123
+ Lint/NumberedParameterAssignment:
124
+ Enabled: true
125
+
126
+ Lint/OrAssignmentToConstant:
127
+ Enabled: true
128
+
129
+ Lint/RaiseException:
130
+ Enabled: true
131
+
132
+ Lint/RedundantDirGlobSort:
133
+ Enabled: true
134
+
135
+ Lint/RequireRelativeSelfPath: # new in 1.22
136
+ Enabled: true
137
+
57
138
  Lint/RescueException:
58
139
  Enabled: true
59
140
 
141
+ Lint/StructNewOverride:
142
+ Enabled: true
143
+
144
+ Lint/SymbolConversion:
145
+ Enabled: true
146
+
147
+ Lint/ToEnumArguments:
148
+ Enabled: true
149
+
150
+ Lint/TripleQuotes:
151
+ Enabled: true
152
+
153
+ Lint/UnexpectedBlockArity:
154
+ Enabled: true
155
+
156
+ Lint/UnmodifiedReduceAccumulator:
157
+ Enabled: true
158
+
60
159
  Lint/UnusedMethodArgument:
61
160
  Enabled: true
62
161
 
@@ -76,20 +175,24 @@ Metrics/BlockLength:
76
175
  Enabled: true
77
176
  Max: 350
78
177
 
178
+ Metrics/BlockNesting:
179
+ Enabled: true
180
+ Max: 5
181
+
79
182
  Metrics/ClassLength:
80
183
  Enabled: true
81
- Max: 350
184
+ Max: 450
82
185
 
83
186
  Metrics/CyclomaticComplexity:
84
187
  Enabled: false
85
188
 
86
- Metrics/LineLength:
189
+ Layout/LineLength:
87
190
  Enabled: false
88
191
  Max: 90
89
192
 
90
193
  Metrics/MethodLength:
91
194
  Enabled: true
92
- Max: 40
195
+ Max: 60
93
196
 
94
197
  Metrics/ModuleLength:
95
198
  Enabled: true
@@ -103,21 +206,30 @@ Naming/ConstantName:
103
206
 
104
207
  Naming/ClassAndModuleCamelCase:
105
208
  Enabled: false
106
-
107
- Naming/UncommunicativeBlockParamName:
209
+
210
+ Naming/BlockParameterName:
108
211
  Enabled: true
109
-
110
- Naming/UncommunicativeMethodParamName:
212
+
213
+ Naming/InclusiveLanguage:
214
+ Enabled: true
215
+
216
+ Naming/MethodParameterName:
217
+ Enabled: false
218
+
219
+ Naming/MethodName:
111
220
  Enabled: false
112
221
 
113
222
  Naming/VariableName:
114
223
  Enabled: false
115
224
 
225
+ Security/IoMethods: # new in 1.22
226
+ Enabled: true
227
+
116
228
  Style/Alias:
117
229
  Enabled: true
118
230
 
119
- Layout/AlignHash:
120
- Enabled: false
231
+ Style/ArgumentsForwarding:
232
+ Enabled: true
121
233
 
122
234
  Style/AsciiComments:
123
235
  Enabled: false
@@ -137,6 +249,9 @@ Style/ClassCheck:
137
249
  Style/ClassVars:
138
250
  Enabled: false
139
251
 
252
+ Style/CollectionCompact:
253
+ Enabled: true
254
+
140
255
  Style/ColonMethodCall:
141
256
  Enabled: false
142
257
 
@@ -155,44 +270,204 @@ Style/DefWithParentheses:
155
270
  Style/Documentation:
156
271
  Enabled: false
157
272
 
273
+ Style/DocumentDynamicEvalDefinition:
274
+ Enabled: true
275
+
158
276
  Style/ExpandPathArguments:
159
277
  Enabled: false
160
278
 
279
+ Style/ExponentialNotation:
280
+ Enabled: true
281
+
161
282
  Style/GuardClause:
162
283
  Enabled: false
163
284
 
285
+ Style/HashEachMethods:
286
+ Enabled: true
287
+
288
+ Style/HashExcept:
289
+ Enabled: true
290
+
291
+ Style/HashTransformKeys:
292
+ Enabled: true
293
+
294
+ Style/HashTransformValues:
295
+ Enabled: true
296
+
164
297
  Style/IfUnlessModifier:
165
298
  Enabled: false
166
299
 
300
+ Style/InPatternThen:
301
+ Enabled: true
302
+
167
303
  Style/InverseMethods:
304
+ Enabled: false
305
+
306
+ Style/MissingRespondToMissing:
307
+ Enabled: false
308
+
309
+ Style/MultilineInPatternThen:
310
+ Enabled: true
311
+
312
+ Style/NegatedIfElseCondition:
168
313
  Enabled: true
169
314
 
170
315
  Style/Next:
171
316
  Enabled: false
172
317
 
318
+ Style/NilLambda:
319
+ Enabled: true
320
+
321
+ Style/NumberedParameters: # new in 1.22
322
+ Enabled: true
323
+
324
+ Style/NumberedParametersLimit: # new in 1.22
325
+ Enabled: true
326
+
327
+ Style/NumericLiterals:
328
+ Enabled: false
329
+
330
+ Style/QuotedSymbols:
331
+ Enabled: true
332
+
173
333
  Style/RaiseArgs:
174
334
  Enabled: true
175
335
 
336
+ Style/RedundantArgument:
337
+ Enabled: true
338
+
176
339
  Style/RedundantReturn:
177
340
  Enabled: false
178
-
341
+
179
342
  Style/RedundantSelf:
180
343
  Enabled: true
181
344
 
345
+ Style/RedundantSelfAssignmentBranch:
346
+ Enabled: true
347
+
182
348
  Style/RegexpLiteral:
183
349
  Enabled: false
184
350
 
185
351
  Style/PercentLiteralDelimiters:
186
352
  Enabled: false
187
-
353
+
354
+ Style/SelectByRegexp: # new in 1.22
355
+ Enabled: true
356
+
188
357
  Style/StderrPuts:
189
- Enabled: false
358
+ Enabled: false
190
359
 
191
360
  Style/StringLiterals:
192
361
  Enabled: true
193
362
 
363
+ Style/SwapValues:
364
+ Enabled: true
365
+
194
366
  Style/TernaryParentheses:
195
367
  Enabled: false
196
-
368
+
197
369
  Style/UnlessElse:
198
- Enabled: false
370
+ Enabled: false
371
+
372
+ # Rubocop complains when it doesn't find an explicit setting for the following cops:
373
+ Layout/EmptyLinesAroundAttributeAccessor:
374
+ Enabled: true
375
+
376
+ Lint/BinaryOperatorWithIdenticalOperands:
377
+ Enabled: true
378
+
379
+ Lint/DeprecatedOpenSSLConstant:
380
+ Enabled: true
381
+
382
+ Lint/DuplicateElsifCondition:
383
+ Enabled: true
384
+
385
+ Lint/DuplicateRescueException:
386
+ Enabled: true
387
+
388
+ Lint/EmptyConditionalBody:
389
+ Enabled: true
390
+
391
+ Lint/FloatComparison:
392
+ Enabled: true
393
+
394
+ Lint/MissingSuper:
395
+ Enabled: true
396
+
397
+ Lint/MixedRegexpCaptureTypes:
398
+ Enabled: true
399
+
400
+ Lint/OutOfRangeRegexpRef:
401
+ Enabled: true
402
+
403
+ Lint/SelfAssignment:
404
+ Enabled: true
405
+
406
+ Lint/TopLevelReturnWithArgument:
407
+ Enabled: true
408
+
409
+ Lint/UnreachableLoop:
410
+ Enabled: true
411
+
412
+ Style/AccessorGrouping:
413
+ Enabled: true
414
+
415
+ Style/ArrayCoercion:
416
+ Enabled: true
417
+
418
+ Style/BisectedAttrAccessor:
419
+ Enabled: true
420
+
421
+ Style/CaseLikeIf:
422
+ Enabled: true
423
+
424
+ Style/EndlessMethod:
425
+ Enabled: true
426
+
427
+ Style/ExplicitBlockArgument:
428
+ Enabled: true
429
+
430
+ Style/GlobalStdStream:
431
+ Enabled: true
432
+
433
+ Style/HashAsLastArrayItem:
434
+ Enabled: true
435
+
436
+ Style/HashConversion:
437
+ Enabled: true
438
+
439
+ Style/HashLikeCase:
440
+ Enabled: true
441
+
442
+ Style/IfWithBooleanLiteralBranches:
443
+ Enabled: true
444
+
445
+ Style/OptionalBooleanParameter:
446
+ Enabled: true
447
+
448
+ Style/RedundantAssignment:
449
+ Enabled: true
450
+
451
+ Style/RedundantFetchBlock:
452
+ Enabled: true
453
+
454
+ Style/RedundantFileExtensionInRequire:
455
+ Enabled: true
456
+
457
+ Style/RedundantRegexpCharacterClass:
458
+ Enabled: true
459
+
460
+ Style/RedundantRegexpEscape:
461
+ Enabled: true
462
+
463
+ Style/SingleArgumentDig:
464
+ Enabled: true
465
+
466
+ Style/SlicingWithRange:
467
+ Enabled: true
468
+
469
+ Style/StringChars:
470
+ Enabled: true
471
+
472
+ Style/StringConcatenation:
473
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
+ ## [0.4.9] - 2021-11-01
2
+ - Code update to align with `Rley` v. 0.8.08
3
+
4
+ ### Changed
5
+ - File `ast_builder.rb` Updated some `reduce_...` methods to cope with ? quantifier change
6
+ - File `srl_ruby.gemspec` Updated the dependency towards Rley
7
+ - File `.rubocop.yml` Added newest cops from 1.21 and 1.22
8
+
9
+ ### Fixed
10
+ - File `grammar.rb` is now calling `Rley::grammar_builder` factory method.
11
+ - File `rule_file_grammar.rb` is now calling `Rley::grammar_builder` factory method.
12
+
13
+ ## [0.4.8] - 2021-08-27
14
+ - Updated dependencies (Bundler >~ 2.2), (Rley >~ 0.8.03)
15
+ - Grammar refactoring to take profit of new Rley rule syntax.
16
+
17
+ ### Changed
18
+ - File `srl_ruby.gemspec` Updated the dependencies
19
+ - File `grammar.rb` Grammar refactored (use ? * + modifiers in production rules)
20
+ - class `ASTBuilder` updated `reduce_` to reflect new refactored production rules.
21
+
22
+ ## [0.4.7] - 2021-08-24
23
+ - Updated dependencies (Ruby >= 2.5), (Rley >= 0.8.02)
24
+ - Code restyling to please rubocop 1.19.1.
25
+ ### Changed
26
+ - File `srl_ruby.gemspec` Updated the dependencies
27
+ - File `.rubocop.yml` Added configuration for newest cops
28
+
1
29
  ## [0.4.6] - 2019-08-17
2
- - Code refactoring to use string frozen magic comments (as a consequence, srl_ruby runs only on Rubies 2.3 or newer).
30
+ - Code refactoring to use string frozen magic comments (as a consequence, skeem runs only on Rubies 2.3 or newer).
3
31
  - Code restyling to please rubocop 0.7.40.
4
32
  ### Changed
5
33
  - File `README.md` updated note on compatibility with Rubies
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-2019 Dimitri Geshef
8
+ Copyright (c) 2018-2021 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/Rakefile CHANGED
@@ -10,6 +10,7 @@ RSpec::Core::RakeTask.new do |spec|
10
10
  end
11
11
 
12
12
  Cucumber::Rake::Task.new do |_|
13
+ # Comment
13
14
  end
14
15
 
15
16
  # Combine RSpec and Cucumber tests
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 + '/' + fname
56
+ t_filepath = "#{Dir.getwd}/#{fname}"
53
57
  else
54
- t_filepath = def_template_dir + '/' + fname
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 + '/' + DefTemplate
62
+ t_filepath = "#{def_template_dir}/#{DefTemplate}"
59
63
  end
60
64
  path = Pathname.new(t_filepath)
61
- erb_template = ERB.new(path.read, nil, '<>')
62
-
63
- erb_template
65
+ ERB.new(path.read, nil, '<>')
64
66
  end
65
67
 
66
68
  def validate_filename(raw_fname)
@@ -37,7 +37,7 @@ class Srl2RubyCLIParser < OptionParser
37
37
  end
38
38
 
39
39
  def description
40
- descr = <<-DESCR
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
@@ -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
- result = '(?:' + result_children.join('|') + ')'
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
@@ -26,6 +26,7 @@ module Regex # This module is used as a namespace
26
26
  # Constructor
27
27
  # @param aKind [String] Lexeme representation of the anchor
28
28
  def initialize(aKind)
29
+ super()
29
30
  @kind = valid_kind(aKind)
30
31
  end
31
32
 
@@ -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
- result = '(' + atomic + prefix + child.child.to_str + ')'
47
+ suffix = child.child.to_str
46
48
  else
47
- result = '(' + atomic + prefix + child.to_str + ')'
49
+ suffix = child.to_str
48
50
  end
49
- return result
51
+ "(#{atomic}#{prefix}#{suffix})"
50
52
  end
53
+ # rubocop: enable Style/OptionalBooleanParameter
51
54
  end # class
52
55
  end # module
53
56
 
@@ -30,7 +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 + ']'
33
+ result = "[#{negated ? '^' : ''}#{result_children}]"
34
34
 
35
35
  return result
36
36
  end
@@ -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
- result = lower.to_str + '-' + upper.to_str
38
-
39
- return result
37
+ "#{lower.to_str}-#{upper.to_str}"
40
38
  end
41
39
 
42
40
  private
@@ -26,6 +26,7 @@ module Regex # This module is used as a namespace
26
26
 
27
27
  # Constructor
28
28
  def initialize(aShortname)
29
+ super()
29
30
  @shortname = valid_shortname(aShortname)
30
31
  end
31
32
 
@@ -59,6 +59,7 @@ module Regex # This module is used as a namespace
59
59
  # RegAn::Character.new('\n') # Represents a newline
60
60
  # RegAn::Character.new('\u03a3') # Represents a Σ
61
61
  def initialize(aValue)
62
+ super()
62
63
  case aValue
63
64
  when String
64
65
  if aValue.size == 1
@@ -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
@@ -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 = '(?' + dir_syntax + kind_syntax + child.to_str + ')'
45
+ result = "(?#{dir_syntax}#{kind_syntax}#{child.to_str})"
46
46
  return result
47
47
  end
48
48
  end # class
@@ -50,16 +50,13 @@ module Regex # This module is used as a namespace
50
50
  end
51
51
  end
52
52
 
53
- suffix = case policy
54
- when :greedy
55
- ''
56
- when :lazy
57
- '?'
58
- when :possessive
59
- '+'
60
- end
53
+ policy2suffix = {
54
+ greedy: '',
55
+ lazy: '?',
56
+ possessive: '+'
57
+ }
61
58
 
62
- return subresult + suffix
59
+ return subresult + policy2suffix[policy]
63
60
  end
64
61
 
65
62
  private