srl_ruby 0.4.14 → 0.4.15

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: aa7a9699a1a4f26e820e1523d4f6d3fa186cd814afeb5b41e164ea191df7303b
4
- data.tar.gz: 0f4b1c7de0da2ed0a1acf1f2a700271d35afc383b5d9eeec0d790993f9d8928b
3
+ metadata.gz: af00786c71ac6736bb80041630395c02bf7e86a8a15c4601b3010edefadc7d21
4
+ data.tar.gz: ac70e3dc3bdd7ce80e84e9d2c5c72b3f45d4664fb1d47d4e12e85d57b24c3aa7
5
5
  SHA512:
6
- metadata.gz: 972f392c2817101f0bffcc688b867060f19da7c258e5b0bd2fb2061a602df6d0c8f00df85be855bc6bb2cc24b8bd1c1994fac00d06a7ca9b1fe353277acbd21f
7
- data.tar.gz: 7b8e2065d771a5ae84051bc7633d09ea6ed7dcb781b277fd47118b3796cf5a2f7f4d1fe44e29b5acf65303902e8c9a1b9b4f7692b8c9b4079c47115258450870
6
+ metadata.gz: 42229711b0814750b89ed47ff893defbc51ae40463613f85c3c3d82afff577984452eb8039439ebec6813708f892cf657ed338df6170d0ab0acc411a96cc471f
7
+ data.tar.gz: dd628a6cdd006763a00a5c82950bc5721bf4f9ee6a065b88f29f0dda9a0161bd7e5613dc3379f30479b3866fbca77b454afe2919084a633cc326a5195b3082f4
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## [0.4.13] - 2025-02-22
1
+ ## [0.4.15] - 2025-03-20
2
+ - Tested against rley 0.9.02 and rubocop 1.74.0
3
+ ### Changed
4
+ - File `srl_ruby.gemspec`: make dependencies more lenient
5
+
6
+ ## [0.4.14] - 2025-02-22
2
7
  - Tested against rubocop-rspec 3.5.0
3
8
 
4
9
  ### Fixed
@@ -41,13 +41,13 @@ module Regex # This module is used as a namespace
41
41
  # codepoint value.
42
42
  # Examples:
43
43
  # Initializing with codepoint value...
44
- # RegAn::Character.new(0x3a3) # Represents: Σ
44
+ # Regex::Character.new(0x3a3) # Represents: Σ
45
45
  # (Unicode GREEK CAPITAL LETTER SIGMA)
46
- # RegAn::Character.new(931) # Also represents: Σ (931 dec == 3a3 hex)
46
+ # Regex::Character.new(931) # Also represents: Σ (931 dec == 3a3 hex)
47
47
  #
48
48
  # Initializing with a single character string
49
- # RegAn::Character.new(?\u03a3) # Also represents: Σ
50
- # RegAn::Character.new('Σ') # Obviously, represents a Σ
49
+ # Regex::Character.new(?\u03a3) # Also represents: Σ
50
+ # Regex::Character.new('Σ') # Obviously, represents a Σ
51
51
  #
52
52
  # Initializing with an escape sequence string
53
53
  # Recognized escaped characters are: \a (alarm, 0x07), \n (newline, 0xA),
@@ -56,8 +56,8 @@ module Regex # This module is used as a namespace
56
56
  # \uXXXX where XXXX is a 4 hex digits integer value, \u{X...}, \ooo (octal)
57
57
  # \xXX (hex)
58
58
  # Any other escaped character will be treated as a literal character
59
- # RegAn::Character.new('\n') # Represents a newline
60
- # RegAn::Character.new('\u03a3') # Represents a Σ
59
+ # Regex::Character.new('\n') # Represents a newline
60
+ # Regex::Character.new('\u03a3') # Represents a Σ
61
61
  def initialize(aValue)
62
62
  super()
63
63
  case aValue
@@ -80,7 +80,7 @@ module Regex # This module is used as a namespace
80
80
 
81
81
  # Convertion method that returns a character given a codepoint (integer) value.
82
82
  # Example:
83
- # RegAn::Character::codepoint2char(0x3a3) # Returns: Σ (
83
+ # Regex::Character::codepoint2char(0x3a3) # Returns: Σ (
84
84
  # The Unicode GREEK CAPITAL LETTER SIGMA)
85
85
  def self.codepoint2char(aCodepoint)
86
86
  [aCodepoint].pack('U') # Remark: chr() fails with codepoints > 256
@@ -88,7 +88,7 @@ module Regex # This module is used as a namespace
88
88
 
89
89
  # Convertion method that returns the codepoint for the given single character.
90
90
  # Example:
91
- # RegAn::Character::char2codepoint('Σ') # Returns: 0x3a3
91
+ # Regex::Character::char2codepoint('Σ') # Returns: 0x3a3
92
92
  def self.char2codepoint(aChar)
93
93
  aChar.ord
94
94
  end
@@ -102,7 +102,7 @@ module Regex # This module is used as a namespace
102
102
  # \xXX (hex)
103
103
  # Any other escaped character will be treated as a literal character
104
104
  # Example:
105
- # RegAn::Character::esc2codepoint('\n') # Returns: 0xd
105
+ # Regex::Character::esc2codepoint('\n') # Returns: 0xd
106
106
  def self.esc2codepoint(esc_seq)
107
107
  msg = "Escape sequence #{esc_seq} does not begin with a backslash (\\)."
108
108
  raise StandardError, msg unless esc_seq[0] == '\\'
@@ -70,6 +70,7 @@ module Regex # This module is used as a namespace
70
70
  end
71
71
 
72
72
  # Validation method. Return the validated lower bound value
73
+ # @param anUpperBound [Integer, Symbol] integer or :more symbol
73
74
  def valid_upper_bound(anUpperBound)
74
75
  err_msg = "Invalid upper bound of repetition count #{anUpperBound}"
75
76
  unless anUpperBound.kind_of?(Integer) || (anUpperBound == :more)
@@ -12,8 +12,10 @@ module SrlRuby
12
12
  # (say, a parse tree) from simpler objects (terminal and non-terminal
13
13
  # nodes) and using a step by step approach.
14
14
  class ASTBuilder < Rley::ParseRep::ASTBaseBuilder
15
+ # @return [Hash]
15
16
  Terminal2NodeClass = {}.freeze
16
17
 
18
+ # @return [Array<Symbol>] Options for the regular expression
17
19
  attr_reader :options
18
20
 
19
21
  # Create a new AST builder instance.
@@ -24,6 +26,7 @@ module SrlRuby
24
26
  end
25
27
 
26
28
  # Notification that the parse tree construction is complete.
29
+ # @return [void]
27
30
  def done!
28
31
  apply_options
29
32
  super
@@ -31,10 +34,12 @@ module SrlRuby
31
34
 
32
35
  protected
33
36
 
37
+ # @return [Hash]
34
38
  def terminal2node
35
39
  Terminal2NodeClass
36
40
  end
37
41
 
42
+ # @return [void]
38
43
  def apply_options
39
44
  tree_root = result.root
40
45
  regexp_opts = []
@@ -62,12 +67,17 @@ module SrlRuby
62
67
  Rley::PTree::TerminalNode.new(aToken, aTokenPosition)
63
68
  end
64
69
 
70
+ # @param lowerBound [Integer]
71
+ # @param upperBound [Integer, Symbol]
72
+ # @return [Regex::Multiplicity]
65
73
  def multiplicity(lowerBound, upperBound)
66
74
  Regex::Multiplicity.new(lowerBound, upperBound, :greedy)
67
75
  end
68
76
 
69
77
  # rubocop: disable Style/OptionalBooleanParameter
70
78
 
79
+ # @param aString [String]
80
+ # @param [Array<Regex::Character>, Regex::Concatenation, Regex::Character]
71
81
  def string_literal(aString, to_escape = true)
72
82
  if aString.size > 1
73
83
  chars = []
@@ -90,6 +100,8 @@ module SrlRuby
90
100
  end
91
101
  # rubocop: enable Style/OptionalBooleanParameter
92
102
 
103
+ # @param lowerBound [Integer]
104
+ # @param upperBound [Integer]
93
105
  def char_range(lowerBound, upperBound)
94
106
  lower = Regex::Character.new(lowerBound)
95
107
  upper = Regex::Character.new(upperBound)
@@ -111,6 +111,6 @@ module SrlRuby
111
111
  end
112
112
 
113
113
  # And now build the grammar and make it accessible via a global constant
114
- # [Rley::Syntax::Grammar]
114
+ # @return [Rley::Syntax::Grammar]
115
115
  Grammar = builder.grammar
116
116
  end # module
@@ -17,14 +17,31 @@ module SrlRuby
17
17
  # Delimiters: parentheses '(' and ')'
18
18
  # Separators: comma (optional)
19
19
  class Tokenizer
20
+ # @return [Regexp] Matches a SRL character class
20
21
  PATT_CHAR_CLASS = /[^,"\s]{2,}/
22
+
23
+ # @return [Regexp] Matches single digit
21
24
  PATT_DIGIT_LIT = /[0-9]((?=\s|,|\))|$)/
25
+
26
+ # @return [Regexp] Matches a SRL identifier
22
27
  PATT_IDENTIFIER = /[a-zA-Z_][a-zA-Z0-9_]+/
23
- PATT_INTEGER = /[0-9]{2,}((?=\s|,|\))|$)/ # An integer has 2..* digits
28
+
29
+ # @return [Regexp] Matches a decimal integer. An integer has 2..* digits
30
+ PATT_INTEGER = /[0-9]{2,}((?=\s|,|\))|$)/
31
+
32
+ # @return [Regexp] Matches a single letter.
24
33
  PATT_LETTER_LIT = /[a-zA-Z]((?=\s|,|\))|$)/
34
+
35
+ # @return [Regexp] Matches a new line (cross-platform)
25
36
  PATT_NEWLINE = /(?:\r\n)|\r|\n/
26
- PATT_STR_DBL_QUOTE = /"(?:\\"|[^"])*"/ # Double quotes literal?
27
- PATT_STR_SNGL_QUOTE = /'(?:\\'|[^'])*'/ # Single quotes literal?
37
+
38
+ # @return [Regexp] Matches a text enclosed in double quotes
39
+ PATT_STR_DBL_QUOTE = /"(?:\\"|[^"])*"/
40
+
41
+ # @return [Regexp] Matches a text enclosed in single quotes
42
+ PATT_STR_SNGL_QUOTE = /'(?:\\'|[^'])*'/
43
+
44
+ # @return [Regexp] Matches SRL blank(s)
28
45
  PATT_WHITESPACE = /[ \t\f]+/
29
46
 
30
47
  # @return [StringScanner]
@@ -36,6 +53,7 @@ module SrlRuby
36
53
  # @return [Integer] offset of start of current line within input
37
54
  attr_reader(:line_start)
38
55
 
56
+ # @return [{String => String}] Mapping special single characters to symbolic names.
39
57
  Lexeme2name = {
40
58
  '(' => 'LPAREN',
41
59
  ')' => 'RPAREN',
@@ -43,6 +61,7 @@ module SrlRuby
43
61
  }.freeze
44
62
 
45
63
  # Here are all the SRL keywords (in uppercase)
64
+ # @return [{String => String}]
46
65
  Keywords = %w[
47
66
  ALL
48
67
  ALREADY
@@ -102,6 +121,7 @@ module SrlRuby
102
121
  WORD
103
122
  ].to_h { |x| [x, x] }
104
123
 
124
+ # Exception class for scanner/tokenizer failures.
105
125
  class ScanError < StandardError; end
106
126
 
107
127
  # Constructor. Initialize a tokenizer for SRL.
@@ -112,6 +132,8 @@ module SrlRuby
112
132
  @line_start = 0
113
133
  end
114
134
 
135
+ # Returns the sequence of tokens recognized from the input text given at initialization.
136
+ # @return [Array<Rley::Lexical::Token>]
115
137
  def tokens
116
138
  tok_sequence = []
117
139
  until @scanner.eos?
@@ -124,6 +146,7 @@ module SrlRuby
124
146
 
125
147
  private
126
148
 
149
+ # @return [Rley::Lexical::Token]
127
150
  def _next_token
128
151
  token = nil
129
152
 
@@ -170,6 +193,9 @@ module SrlRuby
170
193
  token
171
194
  end
172
195
 
196
+ # @param aSymbolName [String]
197
+ # @param aLexeme [String]
198
+ # @return [Rley::Lexical::Token]
173
199
  def build_token(aSymbolName, aLexeme)
174
200
  begin
175
201
  col = scanner.pos - aLexeme.size - @line_start + 1
@@ -184,6 +210,7 @@ module SrlRuby
184
210
  end
185
211
 
186
212
  # Event: next line detected.
213
+ # @return [Integer] Current scanning position (offset)
187
214
  def next_line_scanned
188
215
  @lineno += 1
189
216
  @line_start = scanner.pos
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SrlRuby
4
- VERSION = '0.4.14'
4
+ # @return [String] Version number of the Gem
5
+ VERSION = '0.4.15'
5
6
  end
data/srl_ruby.gemspec CHANGED
@@ -68,12 +68,12 @@ SUMMARY
68
68
  spec.required_ruby_version = '>= 3.2.0'
69
69
 
70
70
  # Runtime dependencies
71
- spec.add_dependency 'rley', '~> 0.8.11'
71
+ spec.add_dependency 'rley', '~> 0.9', '>= 0.9.02'
72
72
 
73
73
  # Development dependencies
74
- spec.add_development_dependency 'bundler', '>= 2.2.0'
75
- spec.add_development_dependency 'cucumber', '>= 3.1.2'
76
- spec.add_development_dependency 'rake', '>= 12.0'
77
- spec.add_development_dependency 'rspec', '~> 3.0'
74
+ spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.0'
75
+ spec.add_development_dependency 'cucumber', '~> 9'
76
+ spec.add_development_dependency 'rake', '~> 13'
77
+ spec.add_development_dependency 'rspec', '~> 3', '>= 3.10.0'
78
78
  spec.metadata = { 'rubygems_mfa_required' => 'true' }
79
79
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srl_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-22 00:00:00.000000000 Z
10
+ date: 2025-03-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rley
@@ -15,18 +15,27 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.8.11
18
+ version: '0.9'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.02
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
26
  - - "~>"
24
27
  - !ruby/object:Gem::Version
25
- version: 0.8.11
28
+ version: '0.9'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.9.02
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: bundler
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '2.2'
30
39
  - - ">="
31
40
  - !ruby/object:Gem::Version
32
41
  version: 2.2.0
@@ -34,6 +43,9 @@ dependencies:
34
43
  prerelease: false
35
44
  version_requirements: !ruby/object:Gem::Requirement
36
45
  requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.2'
37
49
  - - ">="
38
50
  - !ruby/object:Gem::Version
39
51
  version: 2.2.0
@@ -41,44 +53,50 @@ dependencies:
41
53
  name: cucumber
42
54
  requirement: !ruby/object:Gem::Requirement
43
55
  requirements:
44
- - - ">="
56
+ - - "~>"
45
57
  - !ruby/object:Gem::Version
46
- version: 3.1.2
58
+ version: '9'
47
59
  type: :development
48
60
  prerelease: false
49
61
  version_requirements: !ruby/object:Gem::Requirement
50
62
  requirements:
51
- - - ">="
63
+ - - "~>"
52
64
  - !ruby/object:Gem::Version
53
- version: 3.1.2
65
+ version: '9'
54
66
  - !ruby/object:Gem::Dependency
55
67
  name: rake
56
68
  requirement: !ruby/object:Gem::Requirement
57
69
  requirements:
58
- - - ">="
70
+ - - "~>"
59
71
  - !ruby/object:Gem::Version
60
- version: '12.0'
72
+ version: '13'
61
73
  type: :development
62
74
  prerelease: false
63
75
  version_requirements: !ruby/object:Gem::Requirement
64
76
  requirements:
65
- - - ">="
77
+ - - "~>"
66
78
  - !ruby/object:Gem::Version
67
- version: '12.0'
79
+ version: '13'
68
80
  - !ruby/object:Gem::Dependency
69
81
  name: rspec
70
82
  requirement: !ruby/object:Gem::Requirement
71
83
  requirements:
72
84
  - - "~>"
73
85
  - !ruby/object:Gem::Version
74
- version: '3.0'
86
+ version: '3'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.10.0
75
90
  type: :development
76
91
  prerelease: false
77
92
  version_requirements: !ruby/object:Gem::Requirement
78
93
  requirements:
79
94
  - - "~>"
80
95
  - !ruby/object:Gem::Version
81
- version: '3.0'
96
+ version: '3'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 3.10.0
82
100
  description: |2
83
101
  A compiler and library that transforms highly readable Simple Regex Language
84
102
  patterns into regular expressions.
@@ -205,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
223
  - !ruby/object:Gem::Version
206
224
  version: '0'
207
225
  requirements: []
208
- rubygems_version: 3.6.2
226
+ rubygems_version: 3.6.6
209
227
  specification_version: 4
210
228
  summary: A parser for the [Simple Regex Language](https://simple-regex.com/). It translates
211
229
  patterns expressed in SRL into plain Ruby Regexp objects or in regex literals. Use