parsanol 1.3.60-arm-linux → 1.3.62-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: 3da792758f39f95fbce274233536ba8519258c53630d11fc7c0a672563fbd17d
4
- data.tar.gz: 6fbfbb9537fbc97d84724e7cba802db0c3e1af038191612f60727fe5a854cd35
3
+ metadata.gz: 9e937ece569372893f1e8b605e79ac9e12176e91f3dd05c97481760836750f30
4
+ data.tar.gz: e5ed882bf7bba2ed2da7eb316bf09b939e6b5e969f371af381110ec7b3d0fc05
5
5
  SHA512:
6
- metadata.gz: 8dc9c2beb73b4a5a704fae73d6b6dff230f634d48a97c79ea6f2d77fa8c861b5c5c6789f3ebd3d3f659a28bffb880783064a6bb48d09499341793cbce6cc6939
7
- data.tar.gz: 23f12c81803f60944b8a856da0e275df70f11957816612a5337fabd544d547eef2e08e42915fb95e3eee9ed8b0c4c9ec687e731fd033b3a8127084d238d60441
6
+ metadata.gz: 44d8275b48a88e30bdefe6ef38984d075a8d83f525448a11436818704c48d5433c7478197bf97d0e3ae4e18c1c2e79711d56d882104b2ead0e1eb589017de967
7
+ data.tar.gz: be45a6e954fb31614c9719121f119adf03ec02a62c73364f6fff5de9cf2c64fee34cfbd377b7a1b2dc03187eed65ed3753308497f617912b423c9003f36adea0
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -220,15 +220,21 @@ module Parsanol
220
220
  # to recover inputs from grammars native cannot express.
221
221
  parsanol_grammar =
222
222
  grammar.is_a?(Parsanol::Atoms::Base) || grammar.is_a?(Parsanol::Parser)
223
- if parsanol_grammar && (m = error.message.match(NATIVE_POS_MARKER))
223
+ # The position capture is extracted as a plain String: a MatchData
224
+ # would pin its subject — the full multi-KB failure message — for
225
+ # as long as anything downstream retains it, and callers that
226
+ # rescue-and-collect (pubid's flavor dispatcher) retain millions
227
+ # across long parses (#123).
228
+ message = error.message
229
+ if parsanol_grammar && (pos_str = message[NATIVE_POS_MARKER, 1])
224
230
  source = Parsanol::Source.new(input)
225
231
  success, value = grammar.run_with_context(source, nil, true)
226
232
  return grammar.finalize_result(value) if success
227
233
 
228
- pos = m[1].to_i
229
- msg = error.message.sub(NATIVE_POS_MARKER, "")
234
+ pos = pos_str.to_i
235
+ msg = message.sub(NATIVE_POS_MARKER, "")
230
236
  cause = Parsanol::Cause.new(msg, source, pos)
231
- raise Parsanol::ParseFailed.new(cause.to_s, cause)
237
+ raise Parsanol::ParseFailed.new(cause.to_s, cause), cause: nil
232
238
  end
233
239
 
234
240
  if parsanol_grammar
@@ -243,17 +249,20 @@ module Parsanol
243
249
  value.raise
244
250
  end
245
251
 
246
- if (marker = error.message.match(NATIVE_POS_MARKER))
252
+ # Same capture-string extraction as above; `cause: nil` keeps the
253
+ # retained ParseFailed from pinning the original RuntimeError and
254
+ # its message through the exception-cause chain (#123).
255
+ if (pos_str = message[NATIVE_POS_MARKER, 1])
247
256
  source = Parsanol::Source.new(input)
248
257
  cause = Parsanol::Cause.new(
249
- error.message.sub(NATIVE_POS_MARKER, ""), source, marker[1].to_i
258
+ message.sub(NATIVE_POS_MARKER, ""), source, pos_str.to_i
250
259
  )
251
- raise Parsanol::ParseFailed.new(cause.to_s, cause)
260
+ raise Parsanol::ParseFailed.new(cause.to_s, cause), cause: nil
252
261
  end
253
262
 
254
263
  source = Parsanol::Source.new(input)
255
- cause = Parsanol::Cause.new(error.message, source, source.bytepos)
256
- raise Parsanol::ParseFailed.new(cause.to_s, cause)
264
+ cause = Parsanol::Cause.new(message, source, source.bytepos)
265
+ raise Parsanol::ParseFailed.new(cause.to_s, cause), cause: nil
257
266
  end
258
267
 
259
268
  # Pre-serialized JSON grammar path (library authors with cached JSON).
@@ -14,7 +14,7 @@ module Parsanol
14
14
  attr_reader :envelope, :path, :tables_dir
15
15
 
16
16
  def self.load(path, tables_dir: nil)
17
- envelope = JSON.parse(File.read(path))
17
+ envelope = JSON.parse(PARG.read_utf8(path))
18
18
  new(envelope, path, tables_dir || File.dirname(path))
19
19
  end
20
20
 
@@ -169,7 +169,7 @@ module Parsanol
169
169
 
170
170
  file = declared
171
171
  path = File.join(@tables_dir.to_s, file)
172
- raw = path.end_with?(".json") ? JSON.parse(File.read(path)) : YAML.safe_load_file(path, aliases: true)
172
+ raw = path.end_with?(".json") ? JSON.parse(PARG.read_utf8(path)) : YAML.safe_load_file(path, aliases: true)
173
173
  rows = case raw
174
174
  when Hash
175
175
  raw.map { |key, value| { "name" => key.to_s }.merge(value.to_h.transform_keys(&:to_s)) }
@@ -25,7 +25,7 @@ module Parsanol
25
25
  end
26
26
 
27
27
  def read_file(file)
28
- content = File.read(file).gsub(/^#[^\n]*\n/, "")
28
+ content = PARG.read_utf8(file).gsub(/^#[^\n]*\n/, "")
29
29
  header = content.match(/suite\s+\w+(?:\s+for\s+entry\s+(?<entry>\w+))?\s*\{/)
30
30
  unless header
31
31
  raise ParseError,
@@ -36,7 +36,8 @@ module Parsanol
36
36
  end
37
37
 
38
38
  def initialize(argv)
39
- @argv = argv.dup
39
+ # Under a non-UTF-8 locale ARGV arrives as BINARY; inputs are UTF-8.
40
+ @argv = argv.map { |arg| arg.dup.force_encoding(Encoding::UTF_8) }
40
41
  @tables_dir = nil
41
42
  end
42
43
 
@@ -82,7 +83,7 @@ module Parsanol
82
83
  source = @argv.shift
83
84
  out = flag_value("-o") || default_artifact_name(source)
84
85
  envelope = compile_source(source).envelope
85
- File.write(out, "#{JSON.generate(envelope)}\n")
86
+ File.write(out, "#{JSON.generate(envelope)}\n", encoding: Encoding::UTF_8)
86
87
  puts "#{out} #{envelope['checksum']} warnings=#{envelope['lint']['order_warnings'].size}"
87
88
  0
88
89
  end
@@ -161,7 +162,7 @@ module Parsanol
161
162
  puts "parsanol parg repl — #{file} entry #{entry_name.inspect}; blank line quits"
162
163
  loop do
163
164
  print "> "
164
- input = $stdin.gets
165
+ input = $stdin.gets&.force_encoding(Encoding::UTF_8)
165
166
  break if input.nil? || input.strip.empty?
166
167
 
167
168
  begin
@@ -209,7 +210,7 @@ module Parsanol
209
210
 
210
211
  def compile_source(file)
211
212
  tables = @tables_dir || default_tables_dir(file)
212
- document = Parsanol::PARG::Parser.new(File.read(file)).parse
213
+ document = Parsanol::PARG::Parser.new(PARG.read_utf8(file)).parse
213
214
  Parsanol::PARG::Imports.merge!(document, [File.dirname(file)])
214
215
  Parsanol::PARG::Compiler.compile(document, tables_dir: tables)
215
216
  end
@@ -254,7 +254,7 @@ module Parsanol
254
254
  end
255
255
 
256
256
  raw = if path.end_with?(".json")
257
- JSON.parse(File.read(path))
257
+ JSON.parse(PARG.read_utf8(path))
258
258
  else
259
259
  YAML.safe_load_file(path, aliases: true)
260
260
  end
@@ -19,7 +19,7 @@ module Parsanol
19
19
  raise CompileError, "import cycle: #{(merging + [name]).join(' -> ')}" if merging.include?(name)
20
20
 
21
21
  source = find_file(name, import_dirs)
22
- used = Parser.new(File.read(source)).parse
22
+ used = Parser.new(PARG.read_utf8(source)).parse
23
23
  merge!(used, import_dirs, merging + [name])
24
24
  merge_used(document, used, "#{name}.")
25
25
  end
@@ -32,7 +32,7 @@ module Parsanol
32
32
  def validate(source)
33
33
  raise ArtifactError, "parg artifact not found (set PG_ARTIFACT)" unless available?
34
34
 
35
- envelope = JSON.parse(File.read(artifact_path))
35
+ envelope = JSON.parse(PARG.read_utf8(artifact_path))
36
36
  artifact = Artifact.new(envelope, nil, nil)
37
37
  artifact.parse("file", source)
38
38
  end
data/lib/parsanol/parg.rb CHANGED
@@ -38,5 +38,12 @@ module Parsanol
38
38
  autoload :Imports, "parsanol/parg/imports"
39
39
  autoload :Suite, "parsanol/parg/authoring"
40
40
  autoload :Schema, "parsanol/parg/authoring"
41
+
42
+ # PARG sources and JSON artifacts are UTF-8 by definition: read them as
43
+ # UTF-8 whatever the locale's default external encoding, and skip a
44
+ # byte-order mark the way YAML.safe_load_file does (GH-121).
45
+ def self.read_utf8(path)
46
+ File.read(path, mode: "r:bom|utf-8")
47
+ end
41
48
  end
42
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.60"
4
+ VERSION = "1.3.62"
5
5
  end
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.60
4
+ version: 1.3.62
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-01 00:00:00.000000000 Z
11
+ date: 2026-10-02 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