parsanol 1.3.31-arm-linux → 1.3.32-arm-linux

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: 48fd80cc4febd6d9bcfc1e961e7a542fe2dad4fb2bf33d0c3ef6663ea23bd1d9
4
- data.tar.gz: ecc56ff04709f72bed81413530aabe26cab9c0ad916f70ef764548a79745a258
3
+ metadata.gz: bcc6dfae6ffa797eb5cf348321b8ba478685f164c87b9f6d5631ae5d4c875772
4
+ data.tar.gz: 49305e9b8acbf788ebcb7dab375a5e4343652d573b949b33442cad9945f1d028
5
5
  SHA512:
6
- metadata.gz: 9f340f75ddcaba515c29872e7b1f933a521231d888e24900dd926dbf061e7e82ed290d9b02dfbe637aed67aa9441b5a3b2194ce9c9cb860ca778d5893cfaad3f
7
- data.tar.gz: 2d29cdfa98ecf993c4276a4833b014c2e325b7ffed6451819a28689e7eee71a70519a3875350a664b6ce8d30e537d9107de9d87ecfc99f8a726728cf51572b15
6
+ metadata.gz: 60b8818a30dae829cdd46a49a7315b25c0e29471280c52f322539feb8e6ca5b62dfe90bc6e633faa13f6dc72e236775065ec458b98999015decf5b3c2df62243
7
+ data.tar.gz: cd69af0d55393572413d6378fa3e6992a1275f18b797fa45a0095bdfb38b028ab08e8c0dea3ddaea62fe8900e7c46eb3cfc8226d793ea745259be272a9d243f6
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.31"
4
+ VERSION = "1.3.32"
5
5
  end
data/lib/parsanol.rb CHANGED
@@ -129,10 +129,60 @@ module Parsanol
129
129
  def match(pattern = nil)
130
130
  return CharacterClassBuilder.new unless pattern
131
131
 
132
+ match_quantifier_warning(pattern)
132
133
  Atoms::Re.new(pattern)
133
134
  end
134
135
  module_function :match
135
136
 
137
+ # `match` consumes exactly one character (Parslet parity), so a regex
138
+ # quantifier is silently truncated: match(/[0-9]+/) matches a single
139
+ # digit. Warn once per offending pattern — the intended spelling is
140
+ # `match("[0-9]").repeat(1)`.
141
+ # Deliberately mutable: it accumulates warned patterns per process.
142
+ QUANTIFIER_WARNED = {} # rubocop:disable Style/MutableConstant
143
+ private_constant :QUANTIFIER_WARNED
144
+
145
+ def match_quantifier_warning(pattern)
146
+ return if QUANTIFIER_WARNED.key?(pattern)
147
+ return unless pattern.is_a?(String)
148
+ return unless quantified_pattern?(pattern)
149
+
150
+ QUANTIFIER_WARNED[pattern] = true
151
+ warn "Parsanol: match(#{pattern.inspect}) matches exactly one character " \
152
+ "(Parslet parity); the quantifier is ignored. " \
153
+ "Use match(...).repeat(1) to match repeatedly."
154
+ end
155
+ module_function :match_quantifier_warning
156
+
157
+ # True when the pattern carries a top-level quantifier (+, *, ?, or
158
+ # {n,m}) outside a character class.
159
+ def quantified_pattern?(pattern)
160
+ in_class = false
161
+ escaped = false
162
+ previous = nil
163
+
164
+ pattern.each_char.with_index do |ch, idx|
165
+ if escaped
166
+ escaped = false
167
+ elsif ch == "\\"
168
+ escaped = true
169
+ elsif in_class
170
+ in_class = false if ch == "]"
171
+ elsif ch == "["
172
+ in_class = true
173
+ elsif %w[+ * ?].include?(ch) || (ch == "{" && idx + 1 < pattern.length && pattern[idx + 1] =~ /\d/)
174
+ # A leading quantifier applies to nothing and cannot truncate a
175
+ # character match; any other quantifier does.
176
+ return true if idx.positive? && !previous.nil? && previous != "("
177
+ end
178
+
179
+ previous = ch
180
+ end
181
+
182
+ false
183
+ end
184
+ module_function :quantified_pattern?
185
+
136
186
  # Creates a literal string matcher.
137
187
  #
138
188
  # @param literal [String] the string to match
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsanol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.31
4
+ version: 1.3.32
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-17 00:00:00.000000000 Z
11
+ date: 2026-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A small Ruby library for constructing parsers in the PEG (Parsing Expression
14
14
  Grammar) fashion. Parsanol provides Parslet-compatible API with additional features