parsanol 1.3.131-arm-linux → 1.3.133-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 +4 -4
- data/lib/parsanol/3.2/parsanol_native.so +2 -2
- data/lib/parsanol/3.3/parsanol_native.so +2 -2
- data/lib/parsanol/3.4/parsanol_native.so +2 -2
- data/lib/parsanol/4.0/parsanol_native.so +2 -2
- data/lib/parsanol/native/libparsanol.so +2 -2
- data/lib/parsanol/parg/cli.rb +22 -1
- data/lib/parsanol/parg/compiler.rb +2 -1
- data/lib/parsanol/parg/model_bindings.rb +126 -0
- data/lib/parsanol/parg.rb +1 -0
- data/lib/parsanol/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da3a095c72f65652ddab5b934de4f64f2c0826745224d43036097f558e4bbac0
|
|
4
|
+
data.tar.gz: 1f67d5b9aa5d48361539b2ca731bda6e06e53cf9d6200134ac7c2dcea4e2d493
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 293d7578ea11e2c9c7d304e3a9175a45ff6eeb7fc281ce80ad47f9ba3d61af6c3beae8acde36578b6a8fb5d22c4c4dfcffb8202a15c51958ddf8fa9ed1ec9a69
|
|
7
|
+
data.tar.gz: 18c817da76188bf803072750d0c190aa70c712516e0e5d329d75cdddc0500350d3ec3a1281a7d39a879c6a38652263c7344f01ff3b6991795ff405f689627307
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: data/lib/parsanol/3.2/parsanol_native.so
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 40174108 bytes
|
|
4
|
+
sha256: a4abd3f5e778228091e4116065ebb81d15adc599f3482bf9b622737742021ec4
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: data/lib/parsanol/3.3/parsanol_native.so
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 40359356 bytes
|
|
4
|
+
sha256: fbdca2cc15d273d19be06530ec4fa0f3510de1b1279bd8afef9ff9dbf519accc
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: data/lib/parsanol/3.4/parsanol_native.so
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 40353544 bytes
|
|
4
|
+
sha256: e35eba05fd94a28eac6d1251f1be6cd2db12e9b18cad47a211d8b1106edfc743
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: data/lib/parsanol/4.0/parsanol_native.so
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 40363240 bytes
|
|
4
|
+
sha256: 986c052f3c478ec717dbc61f81d11a1210428cf300d9e6c140b23ba68994fe66
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: data/lib/parsanol/native/libparsanol.so
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 36496788 bytes
|
|
4
|
+
sha256: 2bf9b4db07fed268f82cee8074cf77bb08a302ceec53c8bd8f48bfdf00220ae4
|
data/lib/parsanol/parg/cli.rb
CHANGED
|
@@ -22,7 +22,12 @@ module Parsanol
|
|
|
22
22
|
compile to an artifact envelope;
|
|
23
23
|
--bindings also writes one
|
|
24
24
|
checksummed per-target binding
|
|
25
|
-
artifact beside it (#432)
|
|
25
|
+
artifact beside it (#432);
|
|
26
|
+
--model-bindings FILE embeds a
|
|
27
|
+
rule -> model sidecar (JSON/YAML)
|
|
28
|
+
in the artifact
|
|
29
|
+
bindings <artifact.json> dump the embedded rule -> model
|
|
30
|
+
binding table as JSON (coradoc#307)
|
|
26
31
|
test <file.parg|artifact.json> run the grammar's test section
|
|
27
32
|
parse <file> [--entry E] INPUT parse one input; prints the tree
|
|
28
33
|
and the bound captures
|
|
@@ -75,6 +80,7 @@ module Parsanol
|
|
|
75
80
|
when "lint" then lint
|
|
76
81
|
when "export" then export_grammar
|
|
77
82
|
when "diff" then diff_artifacts
|
|
83
|
+
when "bindings" then dump_bindings
|
|
78
84
|
when "lsp" then Lsp.new.run && 0
|
|
79
85
|
else
|
|
80
86
|
warn USAGE
|
|
@@ -145,6 +151,9 @@ module Parsanol
|
|
|
145
151
|
source = @argv.shift
|
|
146
152
|
out = flag_value("-o") || default_artifact_name(source)
|
|
147
153
|
envelope = compile_source(source).envelope
|
|
154
|
+
if (sidecar = flag_value("--model-bindings"))
|
|
155
|
+
envelope = ModelBindings.embed(envelope, ModelBindings.load(sidecar))
|
|
156
|
+
end
|
|
148
157
|
# Seal: the exact text written is the exact text the byte-level
|
|
149
158
|
# checksum covers (Compiler.seal_json includes the trailing
|
|
150
159
|
# newline).
|
|
@@ -162,6 +171,18 @@ module Parsanol
|
|
|
162
171
|
0
|
|
163
172
|
end
|
|
164
173
|
|
|
174
|
+
# `parg bindings ARTIFACT`: the embedded rule -> model table as JSON.
|
|
175
|
+
def dump_bindings
|
|
176
|
+
path = @argv.shift
|
|
177
|
+
unless path
|
|
178
|
+
warn "usage: parsanol parg bindings ARTIFACT.json"
|
|
179
|
+
return 2
|
|
180
|
+
end
|
|
181
|
+
envelope = ModelBindings.read_envelope(path)
|
|
182
|
+
puts ModelBindings.dump(envelope)
|
|
183
|
+
0
|
|
184
|
+
end
|
|
185
|
+
|
|
165
186
|
# Every --bindings flag value, `all` expanded to the target set.
|
|
166
187
|
# Empty when the flag is absent (compile emits no binding artifacts).
|
|
167
188
|
def bindings_targets
|
|
@@ -61,7 +61,8 @@ module Parsanol
|
|
|
61
61
|
# unicode_tables — is byte-stable when the grammar's behavior is
|
|
62
62
|
# unchanged. Mirrors the cross-engine parity view.
|
|
63
63
|
SEMANTICS_EXCLUDED = %w[checksum byte_checksum compiler_version
|
|
64
|
-
unicode_tables semantics_hash validated
|
|
64
|
+
unicode_tables semantics_hash validated
|
|
65
|
+
model_bindings].freeze
|
|
65
66
|
|
|
66
67
|
def self.semantics_hash(envelope)
|
|
67
68
|
payload = envelope.except(*SEMANTICS_EXCLUDED)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "yaml"
|
|
5
|
+
|
|
6
|
+
module Parsanol
|
|
7
|
+
module PARG
|
|
8
|
+
# The rule -> model binding table embedded in an artifact (coradoc#307).
|
|
9
|
+
#
|
|
10
|
+
# A sidecar (JSON or YAML) declares, per rule, which model a raw-tree
|
|
11
|
+
# node inflates to:
|
|
12
|
+
#
|
|
13
|
+
# version: 1
|
|
14
|
+
# rules:
|
|
15
|
+
# thematic_break:
|
|
16
|
+
# keys: [hr] # exact capture-key set of the node
|
|
17
|
+
# model: HorizontalRule
|
|
18
|
+
# captures: {} # attribute => scalar capture key
|
|
19
|
+
# children: {} # attribute => nested-node capture key
|
|
20
|
+
# defaults: { style: "---" } # attributes fixed by the rule
|
|
21
|
+
#
|
|
22
|
+
# `parg compile --model-bindings FILE` embeds it under the envelope's
|
|
23
|
+
# additive "model_bindings" key; artifacts compiled without a sidecar
|
|
24
|
+
# carry no such key and are byte-identical to before. The table is not
|
|
25
|
+
# parse semantics, so semantics_hash ignores it; the checksum covers it.
|
|
26
|
+
module ModelBindings
|
|
27
|
+
KEY = "model_bindings"
|
|
28
|
+
VERSION = 1
|
|
29
|
+
RULE_FIELDS = %w[keys model captures children defaults].freeze
|
|
30
|
+
|
|
31
|
+
module_function
|
|
32
|
+
|
|
33
|
+
# @param path [String] a .json / .yml / .yaml sidecar
|
|
34
|
+
# @return [Hash] the validated, string-keyed table
|
|
35
|
+
def load(path)
|
|
36
|
+
text = File.read(path, encoding: Encoding::UTF_8)
|
|
37
|
+
raw = File.extname(path).match?(/\.ya?ml\z/i) ? YAML.safe_load(text) : JSON.parse(text)
|
|
38
|
+
normalize(raw)
|
|
39
|
+
rescue JSON::ParserError, Psych::SyntaxError => e
|
|
40
|
+
raise ArtifactError, "model bindings #{path}: #{e.message}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @return [Hash] the table with every rule filled to the full shape
|
|
44
|
+
def normalize(raw)
|
|
45
|
+
raise ArtifactError, "model bindings: expected a mapping" unless raw.is_a?(Hash)
|
|
46
|
+
|
|
47
|
+
table = stringify(raw)
|
|
48
|
+
unless table["version"] == VERSION
|
|
49
|
+
raise ArtifactError, "model bindings: unsupported version #{table['version'].inspect} (want #{VERSION})"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
rules = table["rules"]
|
|
53
|
+
raise ArtifactError, "model bindings: `rules` must be a mapping" unless rules.is_a?(Hash)
|
|
54
|
+
|
|
55
|
+
{ "version" => VERSION, "rules" => rules.to_h { |name, rule| [name, normalize_rule(name, rule)] } }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def normalize_rule(name, rule)
|
|
59
|
+
raise ArtifactError, "model bindings: rule #{name.inspect} must be a mapping" unless rule.is_a?(Hash)
|
|
60
|
+
|
|
61
|
+
unknown = rule.keys - RULE_FIELDS
|
|
62
|
+
raise ArtifactError, "model bindings: rule #{name.inspect} has unknown field #{unknown.first.inspect}" unless unknown.empty?
|
|
63
|
+
unless rule["model"].is_a?(String) && !rule["model"].empty?
|
|
64
|
+
raise ArtifactError, "model bindings: rule #{name.inspect} needs a `model`"
|
|
65
|
+
end
|
|
66
|
+
unless rule["keys"].is_a?(Array) && !rule["keys"].empty?
|
|
67
|
+
raise ArtifactError, "model bindings: rule #{name.inspect} needs non-empty `keys`"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
{
|
|
71
|
+
"keys" => rule["keys"].map(&:to_s),
|
|
72
|
+
"model" => rule["model"],
|
|
73
|
+
"captures" => hash_field(name, rule, "captures"),
|
|
74
|
+
"children" => hash_field(name, rule, "children"),
|
|
75
|
+
"defaults" => hash_field(name, rule, "defaults"),
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def hash_field(name, rule, field)
|
|
80
|
+
value = rule.fetch(field, {})
|
|
81
|
+
raise ArtifactError, "model bindings: rule #{name.inspect} `#{field}` must be a mapping" unless value.is_a?(Hash)
|
|
82
|
+
|
|
83
|
+
value
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def stringify(value)
|
|
87
|
+
case value
|
|
88
|
+
when Hash then value.to_h { |key, item| [key.to_s, stringify(item)] }
|
|
89
|
+
when Array then value.map { |item| stringify(item) }
|
|
90
|
+
else value
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Embed a table in an envelope and re-seal the canonical checksum.
|
|
95
|
+
def embed(envelope, table)
|
|
96
|
+
sealed = envelope.merge(KEY => table)
|
|
97
|
+
sealed["checksum"] = Compiler.checksum(sealed)
|
|
98
|
+
sealed
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Read an artifact file for the dump: JSON plus checksum verification
|
|
102
|
+
# only, so no grammar source and no custom-atom class is needed.
|
|
103
|
+
def read_envelope(path)
|
|
104
|
+
envelope = JSON.parse(File.read(path, encoding: Encoding::UTF_8))
|
|
105
|
+
unless envelope.is_a?(Hash) && envelope["checksum"] == Compiler.checksum(envelope)
|
|
106
|
+
raise ArtifactError, "#{path}: artifact checksum mismatch"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
envelope
|
|
110
|
+
rescue JSON::ParserError => e
|
|
111
|
+
raise ArtifactError, "#{path}: #{e.message}"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# @return [Hash, nil] the embedded table, nil for an artifact without one
|
|
115
|
+
def from(envelope)
|
|
116
|
+
envelope[KEY]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# The machine-readable dump: rule -> model/keys/captures/children/defaults.
|
|
120
|
+
def dump(envelope)
|
|
121
|
+
table = from(envelope) || { "version" => VERSION, "rules" => {} }
|
|
122
|
+
JSON.pretty_generate(table)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
data/lib/parsanol/parg.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Parsanol
|
|
|
26
26
|
autoload :Compiler, "parsanol/parg/compiler"
|
|
27
27
|
autoload :Artifact, "parsanol/parg/artifact"
|
|
28
28
|
autoload :Bindings, "parsanol/parg/bindings"
|
|
29
|
+
autoload :ModelBindings, "parsanol/parg/model_bindings"
|
|
29
30
|
autoload :Render, "parsanol/parg/render"
|
|
30
31
|
autoload :Derive, "parsanol/parg/derive"
|
|
31
32
|
autoload :SelfHost, "parsanol/parg/selfhost"
|
data/lib/parsanol/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.3.133
|
|
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-11-
|
|
11
|
+
date: 2026-11-04 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
|
|
@@ -120,6 +120,7 @@ files:
|
|
|
120
120
|
- lib/parsanol/parg/lints.rb
|
|
121
121
|
- lib/parsanol/parg/lsp.rb
|
|
122
122
|
- lib/parsanol/parg/lutaml.rb
|
|
123
|
+
- lib/parsanol/parg/model_bindings.rb
|
|
123
124
|
- lib/parsanol/parg/node.rb
|
|
124
125
|
- lib/parsanol/parg/parser.rb
|
|
125
126
|
- lib/parsanol/parg/preprocess.rb
|