@pubid/pubid 0.1.61 → 0.1.63
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.
- package/artifact/corpus.json.gz +0 -0
- package/dist/conformance/implementation.d.ts +2 -0
- package/dist/flavors/iala/index.d.ts +26 -0
- package/dist/flavors/iala/index.js +183 -20
- package/dist/flavors/iho/index.js +244 -11
- package/dist/pubid-urn/schemas/iala.js +2 -0
- package/dist/pubid-urn/schemas/iho.js +1 -0
- package/dist/urn/parsers.js +307 -69
- package/dist/urn/types.d.ts +4 -1
- package/package.json +1 -1
- package/vendor/parg/adobe.json +1 -1
- package/vendor/parg/iala.json +1 -1
- package/vendor/parg/iho.json +1 -1
|
@@ -18,6 +18,8 @@ export const ialaSchema = define("iala", (s) => {
|
|
|
18
18
|
s.type("pubid:iala:letter", "letter");
|
|
19
19
|
s.type("pubid:iala:manual", "manual");
|
|
20
20
|
s.type("pubid:iala:model-course", "mc");
|
|
21
|
+
s.type("pubid:iala:product-specification", "ps");
|
|
22
|
+
s.type("pubid:iala:publication", "pub");
|
|
21
23
|
s.type("pubid:iala:recommendation", "rec");
|
|
22
24
|
s.type("pubid:iala:report", "rpt");
|
|
23
25
|
s.type("pubid:iala:resolution", "r");
|
package/dist/urn/parsers.js
CHANGED
|
@@ -3,6 +3,287 @@ import { splitParts, withYear } from "./types.js";
|
|
|
3
3
|
// including its lossiness (dropped segments stay dropped) and its error
|
|
4
4
|
// cases. The parity fixture (test/fixtures/urn-parity.json) pins the
|
|
5
5
|
// reference behavior for ~93k corpus URNs.
|
|
6
|
+
// --- the IHO URN decode (lib/pubid/iho/urn_parser.rb) -------------------
|
|
7
|
+
//
|
|
8
|
+
// Both namespaces decode onto the canonical shape through the same
|
|
9
|
+
// marker machinery: the segments build an attribute map (the positional
|
|
10
|
+
// ed-/year- attachment included), and the map renders the canonical
|
|
11
|
+
// human text for the text parse — the draft-era part faces rebind
|
|
12
|
+
// through the builder and the spelling face drops, so a decoded
|
|
13
|
+
// identifier renders the primary colon designator.
|
|
14
|
+
const IHO_MRN_TYPE_LETTERS = { spec: "S", per: "P", reg: "M" };
|
|
15
|
+
// The publication name: the lowercase series letter + number, the
|
|
16
|
+
// S-158 member hyphen-joined (s158-102).
|
|
17
|
+
const IHO_MRN_NAME_RE = /^([spmbc])(\d+)(?:-(\d+))?$/;
|
|
18
|
+
const IHO_DOTTED = /^\d+\.\d+\.\d+$/;
|
|
19
|
+
const IHO_SUBNUMBER = /^\d+$/;
|
|
20
|
+
// The docnumber's own charset: digits with : / - suffix runs.
|
|
21
|
+
const IHO_NUMBER = /^\d+(?:[:/-]\d+)*$/;
|
|
22
|
+
// Marker => attribute, with the value pattern each marker's slot
|
|
23
|
+
// accepts (the grammar's own production rules; values case-preserved).
|
|
24
|
+
const IHO_MARKERS = {
|
|
25
|
+
ed: { key: "ed", pattern: /^\d+\.\d+\.\d+$/ },
|
|
26
|
+
sup: { key: "supplement", pattern: /^\d+$/ },
|
|
27
|
+
part: { key: "part", pattern: /^(?:\d+[a-zA-Z]*|[A-Z]|[SPMBC]-\d+)$/ },
|
|
28
|
+
spec: { key: "spec", pattern: /^[1-6]\d\d$/ },
|
|
29
|
+
specsub: { key: "spec_sub", pattern: /^\d+$/ },
|
|
30
|
+
specvar: { key: "spec_variant", pattern: /^[A-Z]+$/ },
|
|
31
|
+
annex: { key: "annex", pattern: /^[A-Z]$/ },
|
|
32
|
+
appendix: { key: "appendix", pattern: /^(?:[A-Z](?:-\d+)?|\d+)$/ },
|
|
33
|
+
vol: { key: "volume", pattern: /^\d+$/ },
|
|
34
|
+
issue: { key: "issue", pattern: /^\d+$/ },
|
|
35
|
+
year: { key: "year", pattern: /^(?:19|20)\d{2}$/ },
|
|
36
|
+
};
|
|
37
|
+
const IHO_MARKER_RE = new RegExp(`^(${Object.keys(IHO_MARKERS).join("|")})-(.+)$`);
|
|
38
|
+
// Legacy dotted keys (deprecated; decodable, never emitted). "y." is
|
|
39
|
+
// the pre-positional year tag — a year IS a volume, so its value
|
|
40
|
+
// decodes into the volume.
|
|
41
|
+
const IHO_LEGACY_KEYS = {
|
|
42
|
+
part: "part",
|
|
43
|
+
annex: "annex",
|
|
44
|
+
suppl: "supplement",
|
|
45
|
+
ap: "appendix",
|
|
46
|
+
appendix: "appendix",
|
|
47
|
+
vol: "volume",
|
|
48
|
+
issue: "issue",
|
|
49
|
+
y: "volume",
|
|
50
|
+
};
|
|
51
|
+
/** The segments build the attribute map: marker segments validated
|
|
52
|
+
* against their own value pattern, ed-/year- positional (the edition
|
|
53
|
+
* attaches to the component it follows, the year to that component's
|
|
54
|
+
* edition owner), specsub-/specvar- only after their parent, the
|
|
55
|
+
* appendix carrying its subnumber hyphen-joined or as the bare atom
|
|
56
|
+
* directly after it. Unknown, reordered or junk segments reject. */
|
|
57
|
+
function ihoConsumeSegments(attrs, segments, body) {
|
|
58
|
+
let component;
|
|
59
|
+
let editionOwner;
|
|
60
|
+
const fail = (message, segment) => {
|
|
61
|
+
throw new Error(`${message} ${JSON.stringify(segment)} in ${JSON.stringify(body)}`);
|
|
62
|
+
};
|
|
63
|
+
const store = (key, value) => {
|
|
64
|
+
if (attrs[key] !== undefined)
|
|
65
|
+
fail("Duplicate", `${key}: ${value}`);
|
|
66
|
+
attrs[key] = value;
|
|
67
|
+
};
|
|
68
|
+
const isSpecNode = (node) => node === "spec" || node === "spec_sub" || node === "spec_variant";
|
|
69
|
+
for (let idx = 0; idx < segments.length; idx += 1) {
|
|
70
|
+
const segment = segments[idx];
|
|
71
|
+
const marker = IHO_MARKER_RE.exec(segment);
|
|
72
|
+
if (marker !== null) {
|
|
73
|
+
const tag = marker[1];
|
|
74
|
+
const value = marker[2];
|
|
75
|
+
const entry = IHO_MARKERS[tag];
|
|
76
|
+
if (!entry.pattern.test(value))
|
|
77
|
+
fail(`Invalid ${tag} value`, JSON.stringify(value));
|
|
78
|
+
const key = entry.key;
|
|
79
|
+
if ((key === "spec_sub" || key === "spec_variant") &&
|
|
80
|
+
component !== "spec" && component !== "spec_sub") {
|
|
81
|
+
fail(`${key}- is only allowed after spec- in`, segment);
|
|
82
|
+
}
|
|
83
|
+
if (key === "ed" || key === "year") {
|
|
84
|
+
// Positional: the edition attaches to the component it follows
|
|
85
|
+
// (the base when none precedes), the year to that component's
|
|
86
|
+
// edition owner. An S-4 spec carries neither — it rides its
|
|
87
|
+
// publication's edition.
|
|
88
|
+
if (isSpecNode(component)) {
|
|
89
|
+
fail("an S-4 spec rides its publication's edition:", segment);
|
|
90
|
+
}
|
|
91
|
+
if (key === "ed") {
|
|
92
|
+
store(component === undefined ? "edition" : `${component}_edition`, value);
|
|
93
|
+
editionOwner = component;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
store(editionOwner !== undefined ? `${editionOwner}_year` : "year", value);
|
|
97
|
+
editionOwner = undefined;
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (key === "appendix") {
|
|
102
|
+
// The hyphen-joined compound value ("D-2", the MRN emission)
|
|
103
|
+
// splits into the appendix and its subnumber; the legacy
|
|
104
|
+
// emission carries the subnumber as the bare atom below.
|
|
105
|
+
const compound = /^([A-Z])-(\d+)$/.exec(value);
|
|
106
|
+
if (compound !== null) {
|
|
107
|
+
store("appendix", compound[1]);
|
|
108
|
+
store("appendix_subnumber", compound[2]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
store("appendix", value);
|
|
112
|
+
}
|
|
113
|
+
component = "appendix";
|
|
114
|
+
editionOwner = undefined;
|
|
115
|
+
const next = segments[idx + 1];
|
|
116
|
+
if (next !== undefined && IHO_SUBNUMBER.test(next)) {
|
|
117
|
+
store("appendix_subnumber", next);
|
|
118
|
+
idx += 1;
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
store(key, value);
|
|
123
|
+
component = key;
|
|
124
|
+
editionOwner = undefined;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const legacy = /^([a-z]+)\.(.*)$/.exec(segment);
|
|
128
|
+
if (legacy !== null) {
|
|
129
|
+
const key = IHO_LEGACY_KEYS[legacy[1]];
|
|
130
|
+
if (key === undefined)
|
|
131
|
+
fail("Unexpected segment", segment);
|
|
132
|
+
// The legacy appendix value stored the subnumber in one string
|
|
133
|
+
// ("appendix.D-2"); it decodes into the two components.
|
|
134
|
+
const sub = key === "appendix" ? /^([A-Z])-(\d+)$/.exec(legacy[2]) : null;
|
|
135
|
+
if (sub !== null) {
|
|
136
|
+
store("appendix", sub[1]);
|
|
137
|
+
store("appendix_subnumber", sub[2]);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
store(key, legacy[2]);
|
|
141
|
+
}
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (IHO_DOTTED.test(segment)) {
|
|
145
|
+
// A bare a.b.c segment is the legacy edition encoding.
|
|
146
|
+
store("edition", segment);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
fail("Unexpected segment", segment);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** The canonical human text of a decoded attribute map (the render's
|
|
153
|
+
* own FACES order: the colon designator on the code, the edition
|
|
154
|
+
* before the part, the citation replacing the Part face). */
|
|
155
|
+
function ihoCanonicalText(typeLetter, attrs) {
|
|
156
|
+
let text = `IHO ${typeLetter}-${attrs["number"] ?? ""}`;
|
|
157
|
+
if (attrs["checks_for"] !== undefined)
|
|
158
|
+
text += `:${attrs["checks_for"]}`;
|
|
159
|
+
if (attrs["edition"] !== undefined)
|
|
160
|
+
text += ` ${attrs["edition"]}`;
|
|
161
|
+
if (attrs["supplement"] !== undefined) {
|
|
162
|
+
text += ` Sup ${attrs["supplement"]}`;
|
|
163
|
+
if (attrs["supplement_edition"] !== undefined)
|
|
164
|
+
text += ` ${attrs["supplement_edition"]}`;
|
|
165
|
+
if (attrs["supplement_year"] !== undefined)
|
|
166
|
+
text += ` (${attrs["supplement_year"]})`;
|
|
167
|
+
}
|
|
168
|
+
if (attrs["spec"] !== undefined) {
|
|
169
|
+
// "B-401", "B-122.1", "B-521(I)" — the citation face replaces the
|
|
170
|
+
// Part face.
|
|
171
|
+
text += ` ${attrs["part"]}-${attrs["spec"]}`;
|
|
172
|
+
if (attrs["spec_sub"] !== undefined)
|
|
173
|
+
text += `.${attrs["spec_sub"]}`;
|
|
174
|
+
if (attrs["spec_variant"] !== undefined)
|
|
175
|
+
text += `(${attrs["spec_variant"]})`;
|
|
176
|
+
}
|
|
177
|
+
else if (attrs["part"] !== undefined) {
|
|
178
|
+
text += ` Part ${attrs["part"]}`;
|
|
179
|
+
if (attrs["part_edition"] !== undefined)
|
|
180
|
+
text += ` ${attrs["part_edition"]}`;
|
|
181
|
+
if (attrs["part_year"] !== undefined)
|
|
182
|
+
text += ` (${attrs["part_year"]})`;
|
|
183
|
+
}
|
|
184
|
+
if (attrs["annex"] !== undefined) {
|
|
185
|
+
text += ` Annex ${attrs["annex"]}`;
|
|
186
|
+
if (attrs["annex_edition"] !== undefined)
|
|
187
|
+
text += ` ${attrs["annex_edition"]}`;
|
|
188
|
+
if (attrs["annex_year"] !== undefined)
|
|
189
|
+
text += ` (${attrs["annex_year"]})`;
|
|
190
|
+
}
|
|
191
|
+
if (attrs["appendix"] !== undefined) {
|
|
192
|
+
text += ` Appendix ${attrs["appendix"]}`;
|
|
193
|
+
if (attrs["appendix_subnumber"] !== undefined)
|
|
194
|
+
text += `-${attrs["appendix_subnumber"]}`;
|
|
195
|
+
if (attrs["appendix_edition"] !== undefined)
|
|
196
|
+
text += ` ${attrs["appendix_edition"]}`;
|
|
197
|
+
if (attrs["appendix_year"] !== undefined)
|
|
198
|
+
text += ` (${attrs["appendix_year"]})`;
|
|
199
|
+
}
|
|
200
|
+
if (attrs["volume"] !== undefined) {
|
|
201
|
+
text += ` Vol. ${attrs["volume"]}`;
|
|
202
|
+
if (attrs["issue"] !== undefined)
|
|
203
|
+
text += ` (${attrs["issue"]})`;
|
|
204
|
+
if (attrs["volume_edition"] !== undefined)
|
|
205
|
+
text += ` ${attrs["volume_edition"]}`;
|
|
206
|
+
if (attrs["volume_year"] !== undefined)
|
|
207
|
+
text += ` (${attrs["volume_year"]})`;
|
|
208
|
+
}
|
|
209
|
+
if (attrs["year"] !== undefined)
|
|
210
|
+
text += ` (${attrs["year"]})`;
|
|
211
|
+
return text;
|
|
212
|
+
}
|
|
213
|
+
/** The S-158 family rebind on the decode path: a draft-era part face
|
|
214
|
+
* riding number 158 rebinds onto checks_for and the spelling face
|
|
215
|
+
* drops (the decoded identifier renders the primary colon
|
|
216
|
+
* designator). */
|
|
217
|
+
function ihoRebindChecks(typeLetter, attrs) {
|
|
218
|
+
if (typeLetter !== "S" || attrs["number"] !== "158" || attrs["checks_for"] !== undefined) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const part = attrs["part"];
|
|
222
|
+
if (part === undefined)
|
|
223
|
+
return;
|
|
224
|
+
const seriesRef = /^([SPMBC])-(\d+)$/.exec(part);
|
|
225
|
+
const digits = seriesRef !== null ? seriesRef[2] : /^\d+$/.test(part) ? part : undefined;
|
|
226
|
+
if (digits === undefined)
|
|
227
|
+
return;
|
|
228
|
+
delete attrs["part"];
|
|
229
|
+
// The edition/year that followed the draft-era part face are the
|
|
230
|
+
// BASE ones (the pubid#775 mis-bind fix).
|
|
231
|
+
if (attrs["edition"] === undefined && attrs["part_edition"] !== undefined) {
|
|
232
|
+
attrs["edition"] = attrs["part_edition"];
|
|
233
|
+
}
|
|
234
|
+
if (attrs["year"] === undefined && attrs["part_year"] !== undefined) {
|
|
235
|
+
attrs["year"] = attrs["part_year"];
|
|
236
|
+
}
|
|
237
|
+
delete attrs["part_edition"];
|
|
238
|
+
delete attrs["part_year"];
|
|
239
|
+
attrs["checks_for"] = digits;
|
|
240
|
+
}
|
|
241
|
+
/** The MRN guidance decode: type token, name (number + optional S-158
|
|
242
|
+
* member), the bare dotted edition, then the shared marker machinery. */
|
|
243
|
+
function ihoMrnText(body) {
|
|
244
|
+
const segments = splitParts(body);
|
|
245
|
+
const typeToken = (segments.shift() ?? "").toLowerCase();
|
|
246
|
+
const letter = IHO_MRN_TYPE_LETTERS[typeToken];
|
|
247
|
+
if (letter === undefined) {
|
|
248
|
+
throw new Error(`Unknown IHO publication type ${JSON.stringify(typeToken)} in ${JSON.stringify(body)}`);
|
|
249
|
+
}
|
|
250
|
+
const name = segments.shift() ?? "";
|
|
251
|
+
const nameMatch = IHO_MRN_NAME_RE.exec(name);
|
|
252
|
+
if (nameMatch === null) {
|
|
253
|
+
throw new Error(`Unknown IHO publication name ${JSON.stringify(name)} in ${JSON.stringify(body)}`);
|
|
254
|
+
}
|
|
255
|
+
const attrs = { number: nameMatch[2] };
|
|
256
|
+
if (nameMatch[3] !== undefined)
|
|
257
|
+
attrs["checks_for"] = nameMatch[3];
|
|
258
|
+
if (segments[0] !== undefined && IHO_DOTTED.test(segments[0])) {
|
|
259
|
+
attrs["edition"] = segments.shift();
|
|
260
|
+
}
|
|
261
|
+
ihoConsumeSegments(attrs, segments, body);
|
|
262
|
+
ihoRebindChecks(letter, attrs);
|
|
263
|
+
return ihoCanonicalText(letter, attrs);
|
|
264
|
+
}
|
|
265
|
+
/** The legacy positional decode: the type letter, the docnumber, a
|
|
266
|
+
* further bare digit segment binding the S-158 member (checks_for —
|
|
267
|
+
* "urn:iho:s:158:100"; another anchor rejects through the builder),
|
|
268
|
+
* then the shared marker machinery. */
|
|
269
|
+
function ihoLegacyText(body) {
|
|
270
|
+
const segments = splitParts(body);
|
|
271
|
+
const typeToken = (segments.shift() ?? "").toLowerCase();
|
|
272
|
+
if (!/^[spmbc]$/.test(typeToken)) {
|
|
273
|
+
throw new Error(`Unknown IHO series ${JSON.stringify(typeToken)} in ${JSON.stringify(body)}`);
|
|
274
|
+
}
|
|
275
|
+
const number = segments.shift() ?? "";
|
|
276
|
+
if (!IHO_NUMBER.test(number)) {
|
|
277
|
+
throw new Error(`Missing docnumber ${JSON.stringify(number)} in ${JSON.stringify(body)}`);
|
|
278
|
+
}
|
|
279
|
+
const attrs = { number };
|
|
280
|
+
if (segments[0] !== undefined && /^\d+$/.test(segments[0])) {
|
|
281
|
+
attrs["checks_for"] = segments.shift();
|
|
282
|
+
}
|
|
283
|
+
ihoConsumeSegments(attrs, segments, body);
|
|
284
|
+
ihoRebindChecks(typeToken.toUpperCase(), attrs);
|
|
285
|
+
return ihoCanonicalText(typeToken.toUpperCase(), attrs);
|
|
286
|
+
}
|
|
6
287
|
// The adopted CEN spine consumes its own supplements; their urn segments
|
|
7
288
|
// carry the consolidation marker ("plus" = "+A1", its absence = "/A1") —
|
|
8
289
|
// cen_cenelec/urn_generator.rb's supplement_segments.
|
|
@@ -286,72 +567,26 @@ export const URN_PARSERS = {
|
|
|
286
567
|
return parse(year ? `GOST ${number}-${year}` : `GOST ${number}`);
|
|
287
568
|
},
|
|
288
569
|
},
|
|
289
|
-
// lib/pubid/iho/urn_parser.rb
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
//
|
|
570
|
+
// lib/pubid/iho/urn_parser.rb — two namespaces. The EMITTED form for
|
|
571
|
+
// S/P/M is the IHO MRN guidance scheme
|
|
572
|
+
// "urn:mrn:iho:pub:<type>:<name>[:<dotted edition>][:<atoms>]" —
|
|
573
|
+
// type spec/per/reg mapping back to the series letter, the name the
|
|
574
|
+
// lowercase letter + number with the S-158 member hyphenated in
|
|
575
|
+
// (s158-102), the bare dotted edition right after the name, then the
|
|
576
|
+
// lowercase marker atoms. The LEGACY urn:iho: positional scheme (the
|
|
577
|
+
// B/C emission; decodable for every series, never emitted for S/P/M):
|
|
578
|
+
// the type letter, the docnumber, a further bare digit segment
|
|
579
|
+
// binding the S-158 member ("urn:iho:s:158:100"), then the markers.
|
|
580
|
+
// Legacy 2.0.x dotted keys (part./annex./suppl./ap./appendix./vol./
|
|
581
|
+
// issue./y.) stay decodable, never emitted. Both paths decode onto
|
|
582
|
+
// the canonical shape: the draft-era part faces rebind through the
|
|
583
|
+
// builder and the spelling face drops, so a decoded identifier
|
|
584
|
+
// renders the primary colon designator.
|
|
298
585
|
iho: {
|
|
299
|
-
prefix: "urn:iho:",
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
const VERSION_SEGMENT = /^\d+\.\d+\.\d+$/;
|
|
304
|
-
const DIGITS = /^\d+$/;
|
|
305
|
-
const TAG_TEXT = {
|
|
306
|
-
ed: (v) => ` ${v}`,
|
|
307
|
-
year: (v) => ` (${v})`,
|
|
308
|
-
sup: (v) => ` Sup ${v}`,
|
|
309
|
-
part: (v) => ` Part ${v}`,
|
|
310
|
-
annex: (v) => ` Annex ${v}`,
|
|
311
|
-
appendix: (v) => ` Appendix ${v}`,
|
|
312
|
-
vol: (v) => ` Vol. ${v}`,
|
|
313
|
-
issue: (v) => ` (${v})`,
|
|
314
|
-
// Legacy dotted keys: decodable, never emitted. The dotted
|
|
315
|
-
// appendix value carries its subnumber in one string ("D-2").
|
|
316
|
-
ap: (v) => ` Ap. ${v}`,
|
|
317
|
-
suppl: (v) => ` Suppl ${v}`,
|
|
318
|
-
y: (v) => ` ${v}`,
|
|
319
|
-
};
|
|
320
|
-
const parts = splitParts(body);
|
|
321
|
-
const typeToken = (parts[0] ?? "").toUpperCase();
|
|
322
|
-
const tagged = (s) => /^[a-z]+[-.]/i.test(s);
|
|
323
|
-
const first = parts[1] ?? "";
|
|
324
|
-
let idx = 2;
|
|
325
|
-
while (idx < parts.length && !tagged(parts[idx]) && !VERSION_SEGMENT.test(parts[idx])) {
|
|
326
|
-
idx += 1;
|
|
327
|
-
}
|
|
328
|
-
const number = [first, ...parts.slice(2, idx)];
|
|
329
|
-
let text = `IHO ${typeToken}-${number.join(":")}`;
|
|
330
|
-
let appendixSeen = false;
|
|
331
|
-
for (; idx < parts.length; idx += 1) {
|
|
332
|
-
const segment = parts[idx];
|
|
333
|
-
if (VERSION_SEGMENT.test(segment)) {
|
|
334
|
-
text += ` ${segment}`;
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (DIGITS.test(segment)) {
|
|
338
|
-
// The appendix subnumber is the only bare atom past the
|
|
339
|
-
// markers, allowed directly after its appendix segment.
|
|
340
|
-
if (!appendixSeen)
|
|
341
|
-
throw new Error(`unexpected bare segment: ${segment}`);
|
|
342
|
-
text += `-${segment}`;
|
|
343
|
-
continue;
|
|
344
|
-
}
|
|
345
|
-
const match = NEW_TAG.exec(segment) ?? LEGACY_TAG.exec(segment);
|
|
346
|
-
const tag = match?.[1]?.toLowerCase();
|
|
347
|
-
const value = match?.[2] ?? "";
|
|
348
|
-
const fn = tag !== undefined ? TAG_TEXT[tag] : undefined;
|
|
349
|
-
if (fn === undefined)
|
|
350
|
-
throw new Error(`unknown iho urn segment: ${segment}`);
|
|
351
|
-
if (tag === "appendix")
|
|
352
|
-
appendixSeen = true;
|
|
353
|
-
text += fn(value);
|
|
354
|
-
}
|
|
586
|
+
prefix: "urn:mrn:iho:pub:",
|
|
587
|
+
prefixes: ["urn:mrn:iho:pub:", "urn:iho:"],
|
|
588
|
+
reconstruct(body, parse, prefix) {
|
|
589
|
+
const text = prefix === "urn:iho:" ? ihoLegacyText(body) : ihoMrnText(body);
|
|
355
590
|
return parse(text);
|
|
356
591
|
},
|
|
357
592
|
},
|
|
@@ -440,7 +675,9 @@ export const URN_PARSERS = {
|
|
|
440
675
|
let edition;
|
|
441
676
|
let language;
|
|
442
677
|
for (const seg of parts) {
|
|
443
|
-
|
|
678
|
+
// The letter carries the sub-numbered S-100 annex letters
|
|
679
|
+
// ("annex-b2"), grammar#146.
|
|
680
|
+
const annexMatch = seg.match(/^annex(-([a-z]\d?))?$/i);
|
|
444
681
|
if (annexMatch) {
|
|
445
682
|
annexLetter = annexMatch[2]?.toUpperCase();
|
|
446
683
|
annexForm = annexLetter ? "ANNEX" : "Annex";
|
|
@@ -869,9 +1106,10 @@ export function lookupUrnParser(flavor) {
|
|
|
869
1106
|
return URN_PARSERS[flavor];
|
|
870
1107
|
}
|
|
871
1108
|
export function parseUrnFor(def, urn, parse) {
|
|
872
|
-
const
|
|
873
|
-
|
|
1109
|
+
const prefixes = def.prefixes ?? [def.prefix];
|
|
1110
|
+
const hit = prefixes.find((p) => urn.toLowerCase().startsWith(p));
|
|
1111
|
+
if (hit === undefined) {
|
|
874
1112
|
throw new Error(`Invalid ${def.prefix.toUpperCase()} URN: ${JSON.stringify(urn)}`);
|
|
875
1113
|
}
|
|
876
|
-
return def.reconstruct(urn.slice(
|
|
1114
|
+
return def.reconstruct(urn.slice(hit.length), parse, hit);
|
|
877
1115
|
}
|
package/dist/urn/types.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export type UrnParserDef = {
|
|
|
3
3
|
/** Full URN prefix including the trailing colon
|
|
4
4
|
* (gem UrnParser PREFIX / "urn:" + flavor_name + ":"). */
|
|
5
5
|
prefix: string;
|
|
6
|
+
/** Additional accepted namespaces (legacy spellings stay decodable,
|
|
7
|
+
* never emitted). reconstruct receives the matched prefix. */
|
|
8
|
+
prefixes?: readonly string[];
|
|
6
9
|
/** Rebuild the human text (or parse directly) from the URN body. */
|
|
7
|
-
reconstruct: (body: string, parse: (text: string) => Identifier) => Identifier;
|
|
10
|
+
reconstruct: (body: string, parse: (text: string) => Identifier, prefix?: string) => Identifier;
|
|
8
11
|
};
|
|
9
12
|
/** Split the body on ":" (gem Base#split_parts). */
|
|
10
13
|
export declare function splitParts(body: string): string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
4
4
|
"description": "TypeScript PubID identifiers: resolution, normalization and canonical hashes for every identifier in the pubid-testsuite corpus (41 standards bodies), with a conformance runner mirroring the Ruby reference",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/vendor/parg/adobe.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.
|
|
1
|
+
{"bindings":null,"version":"0.2.0","grammar":"PubidAdobe","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":40}},{"Str":{"pattern":"Adobe"}},{"Str":{"pattern":" "}},{"Str":{"pattern":"TN"}},{"Str":{"pattern":" "}},{"Repetition":{"atom":4,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,2,3,5]}},{"Str":{"pattern":"Adobe"}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Technical"}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Note"}},{"Str":{"pattern":" "}},{"Repetition":{"atom":12,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"#"}},{"Repetition":{"atom":14,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":" "}},{"Repetition":{"atom":16,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[13,15,17]}},{"Repetition":{"atom":18,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[7,8,9,10,11,19]}},{"Str":{"pattern":"ATN"}},{"Str":{"pattern":" "}},{"Repetition":{"atom":22,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[21,23]}},{"Alternative":{"atoms":[6,20,24]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":26,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"number","atom":27}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Re":{"pattern":"[_]"}},{"Alternative":{"atoms":[30,31,32,33]}},{"Repetition":{"atom":34,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"slug","atom":35}},{"Sequence":{"atoms":[29,36]}},{"Repetition":{"atom":37,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[25,28,38]}},{"Named":{"name":"tech_note","atom":39}},{"Entity":{"atom":44}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":42,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"tech_note_bare","atom":43}},{"Entity":{"atom":98}},{"Str":{"pattern":"Adobe Publication "}},{"Repetition":{"atom":46,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":97}},{"Entity":{"atom":78}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":50,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Alternative":{"atoms":[52,53]}},{"Repetition":{"atom":54,"min":0,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":57,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Alternative":{"atoms":[59,60]}},{"Repetition":{"atom":61,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[56,58,62]}},{"Repetition":{"atom":63,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[51,55,64]}},{"Named":{"name":"slug","atom":65}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":68,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":71,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[70,72]}},{"Repetition":{"atom":73,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[69,74]}},{"Named":{"name":"version","atom":75}},{"Sequence":{"atoms":[66,67,76]}},{"Named":{"name":"publication_version","atom":77}},{"Entity":{"atom":96}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":80,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Alternative":{"atoms":[82,83]}},{"Repetition":{"atom":84,"min":0,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":87,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Alternative":{"atoms":[89,90]}},{"Repetition":{"atom":91,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[86,88,92]}},{"Repetition":{"atom":93,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[81,85,94]}},{"Named":{"name":"slug","atom":95}},{"Alternative":{"atoms":[49,79]}},{"Sequence":{"atoms":[47,48]}},{"Alternative":{"atoms":[0,41,45]}}],"root":99},"bindings":[{"capture":"tech_note","path":"tech_note","type":"raw","card":null,"preprocess":null},{"capture":"tech_note_bare","path":"tech_note_bare","type":"string","card":null,"preprocess":null},{"capture":"publication_version","path":"publication_version","type":"raw","card":null,"preprocess":null},{"capture":"number","path":"number","type":"string","card":null,"preprocess":null},{"capture":"slug","path":"slug","type":"string","card":null,"preprocess":null},{"capture":"version","path":"version","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule publication_slug_or_version: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"Adobe TN 15","expect":{}},{"entry":"identifier","kind":"accept","input":"ATN 30","expect":{}},{"entry":"identifier","kind":"accept","input":"Adobe Technical Note #12","expect":{}},{"entry":"identifier","kind":"accept","input":"pdf-reference-1.7","expect":{}},{"entry":"identifier","kind":"accept","input":"Adobe Publication tiff-6.0","expect":{}},{"entry":"identifier","kind":"accept","input":"Adobe Publication xfa-3.3","expect":{}},{"entry":"identifier","kind":"accept","input":"adobe-japan1-7","expect":{}},{"entry":"identifier","kind":"reject","input":"###","expect":{}}],"docs":{},"source":"# Port of lib/pubid/adobe/parser.rb: tech notes (Adobe TN 5014, legacy\n# \"Adobe Technical Note #5014\", ATN5014, bare 5014) and publications\n# (adobe-glyph-list, adobe-japan1-7 with the version split tried first).\n#\n# Edition 2: every reference inside a captured body is inlined to raw\n# terms (a rule reference materializes as a named node in the edition-2\n# tree, so only a raw capture binds a scalar span). The prefix spellings\n# and slug shapes live inline below; the wrapper captures (tech_note,\n# tech_note_bare, publication_version) keep the v1 tree shape and the\n# bindings name their scalar leaves.\n\ngrammar PubidAdobe version \"0.2.0\" edition 2 {\n\n # Capture precedence: (*rep) as name wraps the whole repetition, so a\n # digit run joins to one string instead of re-keying every character;\n # slug is captured exactly once (the bare form) or as a sibling of\n # version inside the publication_version capture. The three prefix\n # spellings are inlined longest-first (ordered choice is decisive).\n tech_note = {\n (\n ( \"Adobe\" \" \" \"TN\" [\" \"]\n / \"Adobe\" \" \" \"Technical\" \" \" \"Note\" [[\" \"] [\"#\"] [\" \"]]\n / \"ATN\" [\" \"] )\n (1*%x30-39) as number\n [(\".\" (1*(%x41-5A / %x61-7A / %x30-39 / %x5F)) as slug)]\n ) as tech_note\n }\n # The bare form captures the digit run as one span: the builder\n # stringifies the :tech_note_bare value AS the number (no nested read),\n # so an inner capture here would render the hash, not the digits.\n bare_number = (1*%x30-39) as tech_note_bare\n # Slug text: a lower-case lead segment, then dash-joined segments.\n # The version face is a dot-joined digit run (\"7\", \"1.7\", \"6.0\") — the\n # PDF Reference editions, TIFF 6.0 and XFA 3.3 carry dotted versions.\n publication_with_version = {\n (\n ( 1*%x61-7A *(%x61-7A / %x30-39)\n *(\"-\" 1*%x61-7A *(%x61-7A / %x30-39)) ) as slug\n \"-\"\n ( 1*%x30-39 *( \".\" 1*%x30-39 ) ) as version\n ) as publication_version\n }\n slug_inner = {\n ( 1*%x61-7A *(%x61-7A / %x30-39)\n *(\"-\" 1*%x61-7A *(%x61-7A / %x30-39)) ) as slug\n }\n publication_slug_or_version = publication_with_version / slug_inner\n publication = [\"Adobe Publication \"] publication_slug_or_version\n identifier = tech_note / bare_number / publication\n\n entry identifier: identifier\n\n test {\n accept \"Adobe TN 15\"\n accept \"ATN 30\"\n accept \"Adobe Technical Note #12\"\n accept \"pdf-reference-1.7\"\n accept \"Adobe Publication tiff-6.0\"\n accept \"Adobe Publication xfa-3.3\"\n accept \"adobe-japan1-7\"\n reject \"###\"\n }\n\n bindings identifier {\n # The builder dispatches on the wrapper keys and reads the leaves from\n # inside them (adobe/builder.rb build_tech_note / build_publication_version),\n # so the wrappers bind uncast — the nested hash the builder expects. The\n # scalar bindings carry the same leaves flat for typed consumers.\n tech_note -> tech_note (raw)\n tech_note_bare -> tech_note_bare (string)\n publication_version -> publication_version (raw)\n number -> number (string)\n slug -> slug (string)\n version -> version (string)\n }\n}\n","source_hash":"716ecf16e7525972b7a01fa986f4e6a81898080dbdf0a84e516447e729d8e7b4","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:77a3e453cf351ab679c4295ff10126a094b6c8d390f54f67703dc8cc7799c12b","checksum":"sha256:680933a1482ee9cf4875d20f36496986cf7b2f20f2c4ca5cf6ceff6f5a093328","validated":{"lint_errors":0,"lint_warnings":2,"tests_total":8,"tests_failures":0,"self_test":true}}
|
package/vendor/parg/iala.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidIala","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":102}},{"Entity":{"atom":3}},{"Str":{"pattern":"IALA "}},{"Repetition":{"atom":2,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":16}},{"Str":{"pattern":"GA"}},{"Str":{"pattern":"S"}},{"Str":{"pattern":"R"}},{"Str":{"pattern":"G"}},{"Str":{"pattern":"M"}},{"Str":{"pattern":"C"}},{"Str":{"pattern":"A"}},{"Str":{"pattern":"L"}},{"Str":{"pattern":"X"}},{"Str":{"pattern":"P"}},{"Alternative":{"atoms":[5,6,7,8,9,10,11,12,13,14]}},{"Named":{"name":"type_letter","atom":15}},{"Entity":{"atom":32}},{"Entity":{"atom":22}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number","atom":21}},{"Entity":{"atom":29}},{"Entity":{"atom":25}},{"Str":{"pattern":"."}},{"Entity":{"atom":20}},{"Repetition":{"atom":26,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"dotted_segment","atom":27}},{"Sequence":{"atoms":[24,28]}},{"Repetition":{"atom":23,"min":0,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number_dots","atom":30}},{"Sequence":{"atoms":[18,31]}},{"Entity":{"atom":42}},{"Entity":{"atom":40}},{"Entity":{"atom":36}},{"Str":{"pattern":"-"}},{"Entity":{"atom":20}},{"Repetition":{"atom":37,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"subpart_number","atom":38}},{"Sequence":{"atoms":[35,39]}},{"Repetition":{"atom":34,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"subpart","atom":41}},{"Repetition":{"atom":33,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,4,17,43]}},{"Named":{"name":"base","atom":44}},{"Entity":{"atom":47}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Annex"}},{"Str":{"pattern":"ANNEX"}},{"Alternative":{"atoms":[48,49]}},{"Named":{"name":"annex_marker","atom":50}},{"Entity":{"atom":47}},{"Entity":{"atom":54}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Named":{"name":"annex_letter","atom":53}},{"Entity":{"atom":57}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Lookahead":{"atom":56,"positive":false}},{"Sequence":{"atoms":[52,55,58]}},{"Repetition":{"atom":59,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":76}},{"Entity":{"atom":47}},{"Str":{"pattern":"Ed"}},{"Entity":{"atom":47}},{"Entity":{"atom":74}},{"Entity":{"atom":20}},{"Repetition":{"atom":66,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":25}},{"Entity":{"atom":20}},{"Repetition":{"atom":69,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[68,70]}},{"Repetition":{"atom":71,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[67,72]}},{"Named":{"name":"edition_value","atom":73}},{"Sequence":{"atoms":[62,63,64,65]}},{"Named":{"name":"edition","atom":75}},{"Entity":{"atom":83}},{"Entity":{"atom":79}},{"Str":{"pattern":":"}},{"Str":{"pattern":"ed"}},{"Entity":{"atom":74}},{"Sequence":{"atoms":[78,80,81]}},{"Named":{"name":"edition","atom":82}},{"Alternative":{"atoms":[61,77]}},{"Repetition":{"atom":84,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":100}},{"Entity":{"atom":47}},{"Repetition":{"atom":87,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"("}},{"Str":{"pattern":"E"}},{"Str":{"pattern":"F"}},{"Str":{"pattern":"S"}},{"Str":{"pattern":"C"}},{"Str":{"pattern":"A"}},{"Str":{"pattern":"R"}},{"Alternative":{"atoms":[90,91,92,93,94,95]}},{"Named":{"name":"language","atom":96}},{"Str":{"pattern":")"}},{"Sequence":{"atoms":[88,89,97,98]}},{"Named":{"name":"language_group","atom":99}},{"Repetition":{"atom":86,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[45,46,51,60,85,101]}},{"Entity":{"atom":117}},{"Entity":{"atom":3}},{"Entity":{"atom":110}},{"Entity":{"atom":16}},{"Entity":{"atom":32}},{"Entity":{"atom":42}},{"Repetition":{"atom":108,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[106,107,109]}},{"Entity":{"atom":76}},{"Entity":{"atom":83}},{"Alternative":{"atoms":[111,112]}},{"Repetition":{"atom":113,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":100}},{"Repetition":{"atom":115,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[104,105,114,116]}},{"Alternative":{"atoms":[0,103]}}],"root":118},"bindings":[{"capture":"type_letter","path":"type_letter","type":"string","card":null,"preprocess":null},{"capture":"doc_number","path":"doc_number","type":"string","card":null,"preprocess":null},{"capture":"dotted_segment","path":"doc_number_dots[].dotted_segment","type":"string","card":null,"preprocess":null},{"capture":"subpart_number","path":"subpart[].subpart_number","type":"string","card":null,"preprocess":null},{"capture":"edition_value","path":"edition_value","type":"string","card":null,"preprocess":null},{"capture":"language","path":"language","type":"string","card":null,"preprocess":null},{"capture":"annex_marker","path":"annex_marker","type":"string","card":null,"preprocess":null},{"capture":"annex_letter","path":"annex_letter","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule identifier: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"G1040","expect":{}},{"entry":"identifier","kind":"accept","input":"GA1040","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S1070 Ed 2.0","expect":{}},{"entry":"identifier","kind":"accept","input":"R1016:ed2.0(F)","expect":{}},{"entry":"identifier","kind":"accept","input":"C0103-1 Ed 3.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA L2.1.11 Ed 2","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA G1128 Annex A Ed 1.6","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA G1045 Annex Ed 1","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA A12-01 (E)","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}},{"entry":"identifier","kind":"example","input":"G1040","expect":{"type_letter":"G","doc_number":"1040"}},{"entry":"identifier","kind":"example","input":"GA01.01","expect":{"type_letter":"GA","doc_number":"01","doc_number_dots":[{"dotted_segment":"01"}]}},{"entry":"identifier","kind":"example","input":"C0103-1","expect":{"type_letter":"C","doc_number":"0103","subpart":[{"subpart_number":"1"}]}},{"entry":"identifier","kind":"example","input":"IALA S1070 Ed 2.0","expect":{"type_letter":"S","doc_number":"1070","edition_value":"2.0"}},{"entry":"identifier","kind":"example","input":"IALA G1128 Annex A Ed 1.6","expect":{"type_letter":"G","doc_number":"1128","annex_marker":"Annex","annex_letter":"A","edition_value":"1.6"}}],"docs":{},"source":"# Port of lib/pubid/iala/parser.rb: [IALA ]<type><number>[.dots][-subs]\n# [ Ed X.Y | :edX.Y] [(L)], plus the Annex-to-base form. The annex\n# letter guard (!lower) keeps \"Ed 1\" from mis-capturing.\n#\n# Edition-2 conversion with typed model bindings. Deviations from the\n# v1 tree:\n# - the dotted continuation and the dash subpart repeat capture-bearing\n# rule refs (the itu `parts` shape): a repetition over a capture-less\n# unit harvested as a bare span binds differently per engine, so the\n# bindings read the inner captures through the array paths\n# `doc_number_dots[].dotted_segment` and `subpart[].subpart_number`.\n# The dotted segment gains its own capture (`dotted_segment`); the\n# subpart keeps its `subpart_number` capture, hoisted out of the\n# inline repetition into a rule ref of its own.\n# - the annex base composite stays unbound. Every capture inside it\n# (type_letter, doc_number, …) is the only occurrence of its name on\n# the annex path, so the binding harvest hoists it to the top level:\n# the builder reads one flat map for the plain and the annex form\n# alike and dispatches on :annex_marker. edition_value and language\n# hoist out of their edition/language_group composites the same way.\n\ngrammar PubidIala version \"0.1.0\" edition 2 {\n type_letter = (\"GA\" / \"S\" / \"R\" / \"G\" / \"M\" / \"C\" / \"A\" / \"L\" / \"X\" / \"P\") as type_letter\n doc_number = (1*digit) as doc_number\n dotted_number = dot (1*digit) as dotted_segment\n number_with_dots = doc_number (*dotted_number) as doc_number_dots\n subpart_number = dash (1*digit) as subpart_number\n subpart = (1*subpart_number) as subpart\n code = type_letter number_with_dots [subpart]\n edition_value = (1*digit *(dot 1*digit)) as edition_value\n edition_human = (space \"Ed\" space edition_value) as edition\n edition_compact = (colon \"ed\" edition_value) as edition\n language_group = ([space] \"(\" (\"E\" / \"F\" / \"S\" / \"C\" / \"A\" / \"R\") as language \")\") as language_group\n annex_identifier = {\n ((publisher type_letter number_with_dots [subpart]) as base)\n space\n (\"Annex\" / \"ANNEX\") as annex_marker\n [ (space upper as annex_letter !lower) ]\n [edition_human / edition_compact]\n [language_group]\n }\n plain_identifier = {\n publisher code [edition_human / edition_compact] [language_group]\n }\n identifier = {\n annex_identifier\n / plain_identifier\n }\n publisher = [\"IALA \"]\n upper = %x41-5A\n lower = %x61-7A\n digit = %x30-39\n dash = \"-\"\n colon = \":\"\n dot = \".\"\n space = \" \"\n entry identifier: identifier\n\n bindings identifier {\n type_letter -> type_letter (string)\n doc_number -> doc_number (string)\n dotted_segment -> doc_number_dots[].dotted_segment (string)\n subpart_number -> subpart[].subpart_number (string)\n edition_value -> edition_value (string)\n language -> language (string)\n annex_marker -> annex_marker (string)\n annex_letter -> annex_letter (string)\n }\n\n test {\n accept \"G1040\"\n accept \"GA1040\"\n accept \"IALA S1070 Ed 2.0\"\n accept \"R1016:ed2.0(F)\"\n accept \"C0103-1 Ed 3.0\"\n accept \"IALA L2.1.11 Ed 2\"\n accept \"IALA G1128 Annex A Ed 1.6\"\n accept \"IALA G1045 Annex Ed 1\"\n accept \"IALA A12-01 (E)\"\n reject \"nonsense\"\n example \"G1040\" { type_letter: \"G\", doc_number: \"1040\" }\n example \"GA01.01\" {\n type_letter: \"GA\",\n doc_number: \"01\",\n doc_number_dots: [ { dotted_segment: \"01\" } ],\n }\n example \"C0103-1\" {\n type_letter: \"C\",\n doc_number: \"0103\",\n subpart: [ { subpart_number: \"1\" } ],\n }\n example \"IALA S1070 Ed 2.0\" {\n type_letter: \"S\",\n doc_number: \"1070\",\n edition_value: \"2.0\",\n }\n example \"IALA G1128 Annex A Ed 1.6\" {\n type_letter: \"G\",\n doc_number: \"1128\",\n annex_marker: \"Annex\",\n annex_letter: \"A\",\n edition_value: \"1.6\",\n }\n }\n}\n","source_hash":"876c56b59effe0fff6067618955aa411a9d5287848c677b093aacc830562d000","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:bfeb1b06d5a84459e59ff6642e7013c2e95b6ccdc9eb6b6da4d6f0bda7ca85a2","checksum":"sha256:90ef4e159318190b7269b51bbacb6e94145fb0b5f2e336c6821318d539bac76a","validated":{"lint_errors":0,"lint_warnings":1,"tests_total":15,"tests_failures":0,"self_test":true}}
|
|
1
|
+
{"bindings":null,"version":"0.2.0","grammar":"PubidIala","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":105}},{"Entity":{"atom":3}},{"Str":{"pattern":"IALA "}},{"Repetition":{"atom":2,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":16}},{"Str":{"pattern":"GA"}},{"Str":{"pattern":"S"}},{"Str":{"pattern":"R"}},{"Str":{"pattern":"G"}},{"Str":{"pattern":"M"}},{"Str":{"pattern":"C"}},{"Str":{"pattern":"A"}},{"Str":{"pattern":"L"}},{"Str":{"pattern":"X"}},{"Str":{"pattern":"P"}},{"Alternative":{"atoms":[5,6,7,8,9,10,11,12,13,14]}},{"Named":{"name":"type_letter","atom":15}},{"Entity":{"atom":32}},{"Entity":{"atom":22}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number","atom":21}},{"Entity":{"atom":29}},{"Entity":{"atom":25}},{"Str":{"pattern":"."}},{"Entity":{"atom":20}},{"Repetition":{"atom":26,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"dotted_segment","atom":27}},{"Sequence":{"atoms":[24,28]}},{"Repetition":{"atom":23,"min":0,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number_dots","atom":30}},{"Sequence":{"atoms":[18,31]}},{"Entity":{"atom":42}},{"Entity":{"atom":40}},{"Entity":{"atom":36}},{"Str":{"pattern":"-"}},{"Entity":{"atom":20}},{"Repetition":{"atom":37,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"subpart_number","atom":38}},{"Sequence":{"atoms":[35,39]}},{"Repetition":{"atom":34,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"subpart","atom":41}},{"Repetition":{"atom":33,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,4,17,43]}},{"Named":{"name":"base","atom":44}},{"Entity":{"atom":47}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Annex"}},{"Str":{"pattern":"ANNEX"}},{"Alternative":{"atoms":[48,49]}},{"Named":{"name":"annex_marker","atom":50}},{"Entity":{"atom":47}},{"Entity":{"atom":54}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Entity":{"atom":20}},{"Repetition":{"atom":55,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[53,56]}},{"Named":{"name":"annex_letter","atom":57}},{"Entity":{"atom":60}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Lookahead":{"atom":59,"positive":false}},{"Sequence":{"atoms":[52,58,61]}},{"Repetition":{"atom":62,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":79}},{"Entity":{"atom":47}},{"Str":{"pattern":"Ed"}},{"Entity":{"atom":47}},{"Entity":{"atom":77}},{"Entity":{"atom":20}},{"Repetition":{"atom":69,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":25}},{"Entity":{"atom":20}},{"Repetition":{"atom":72,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[71,73]}},{"Repetition":{"atom":74,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[70,75]}},{"Named":{"name":"edition_value","atom":76}},{"Sequence":{"atoms":[65,66,67,68]}},{"Named":{"name":"edition","atom":78}},{"Entity":{"atom":86}},{"Entity":{"atom":82}},{"Str":{"pattern":":"}},{"Str":{"pattern":"ed"}},{"Entity":{"atom":77}},{"Sequence":{"atoms":[81,83,84]}},{"Named":{"name":"edition","atom":85}},{"Alternative":{"atoms":[64,80]}},{"Repetition":{"atom":87,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":103}},{"Entity":{"atom":47}},{"Repetition":{"atom":90,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"("}},{"Str":{"pattern":"E"}},{"Str":{"pattern":"F"}},{"Str":{"pattern":"S"}},{"Str":{"pattern":"C"}},{"Str":{"pattern":"A"}},{"Str":{"pattern":"R"}},{"Alternative":{"atoms":[93,94,95,96,97,98]}},{"Named":{"name":"language","atom":99}},{"Str":{"pattern":")"}},{"Sequence":{"atoms":[91,92,100,101]}},{"Named":{"name":"language_group","atom":102}},{"Repetition":{"atom":89,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[45,46,51,63,88,104]}},{"Entity":{"atom":120}},{"Entity":{"atom":3}},{"Entity":{"atom":113}},{"Entity":{"atom":16}},{"Entity":{"atom":32}},{"Entity":{"atom":42}},{"Repetition":{"atom":111,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[109,110,112]}},{"Entity":{"atom":79}},{"Entity":{"atom":86}},{"Alternative":{"atoms":[114,115]}},{"Repetition":{"atom":116,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":103}},{"Repetition":{"atom":118,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[107,108,117,119]}},{"Entity":{"atom":168}},{"Entity":{"atom":3}},{"Entity":{"atom":137}},{"Str":{"pattern":"S"}},{"Str":{"pattern":"s"}},{"Alternative":{"atoms":[124,125]}},{"Entity":{"atom":36}},{"Entity":{"atom":136}},{"Str":{"pattern":"200"}},{"Lookahead":{"atom":129,"positive":false}},{"Str":{"pattern":"2"}},{"Entity":{"atom":20}},{"Entity":{"atom":20}},{"Sequence":{"atoms":[131,132,133]}},{"Sequence":{"atoms":[130,134]}},{"Named":{"name":"s100_number","atom":135}},{"Sequence":{"atoms":[126,127,128]}},{"Entity":{"atom":47}},{"Str":{"pattern":"Annex"}},{"Str":{"pattern":"ANNEX"}},{"Alternative":{"atoms":[139,140]}},{"Named":{"name":"annex_marker","atom":141}},{"Entity":{"atom":47}},{"Entity":{"atom":54}},{"Entity":{"atom":20}},{"Repetition":{"atom":145,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[144,146]}},{"Named":{"name":"annex_letter","atom":147}},{"Entity":{"atom":60}},{"Lookahead":{"atom":149,"positive":false}},{"Sequence":{"atoms":[143,148,150]}},{"Repetition":{"atom":151,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":79}},{"Entity":{"atom":86}},{"Entity":{"atom":163}},{"Entity":{"atom":47}},{"Str":{"pattern":"Ed"}},{"Entity":{"atom":47}},{"Sequence":{"atoms":[157,158]}},{"Repetition":{"atom":159,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":77}},{"Sequence":{"atoms":[156,160,161]}},{"Named":{"name":"edition","atom":162}},{"Alternative":{"atoms":[153,154,155]}},{"Repetition":{"atom":164,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":103}},{"Repetition":{"atom":166,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[122,123,138,142,152,165,167]}},{"Entity":{"atom":179}},{"Entity":{"atom":3}},{"Entity":{"atom":137}},{"Entity":{"atom":79}},{"Entity":{"atom":86}},{"Entity":{"atom":163}},{"Alternative":{"atoms":[172,173,174]}},{"Repetition":{"atom":175,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":103}},{"Repetition":{"atom":177,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[170,171,176,178]}},{"Entity":{"atom":209}},{"Str":{"pattern":"IALA "}},{"Entity":{"atom":204}},{"Entity":{"atom":192}},{"Entity":{"atom":60}},{"Repetition":{"atom":184,"min":0,"max":2,"tag":"Repetition"}},{"Entity":{"atom":20}},{"Repetition":{"atom":186,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":60}},{"Entity":{"atom":20}},{"Alternative":{"atoms":[188,189]}},{"Lookahead":{"atom":190,"positive":false}},{"Sequence":{"atoms":[185,187,191]}},{"Lookahead":{"atom":183,"positive":false}},{"Entity":{"atom":198}},{"Entity":{"atom":60}},{"Entity":{"atom":20}},{"Alternative":{"atoms":[195,196]}},{"Repetition":{"atom":197,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":36}},{"Entity":{"atom":198}},{"Sequence":{"atoms":[199,200]}},{"Repetition":{"atom":201,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[193,194,202]}},{"Named":{"name":"slug","atom":203}},{"Entity":{"atom":79}},{"Repetition":{"atom":205,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":103}},{"Repetition":{"atom":207,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[181,182,206,208]}},{"Alternative":{"atoms":[0,106,121,169,180]}}],"root":210},"bindings":[{"capture":"type_letter","path":"type_letter","type":"string","card":null,"preprocess":null},{"capture":"doc_number","path":"doc_number","type":"string","card":null,"preprocess":null},{"capture":"dotted_segment","path":"doc_number_dots[].dotted_segment","type":"string","card":null,"preprocess":null},{"capture":"subpart_number","path":"subpart[].subpart_number","type":"string","card":null,"preprocess":null},{"capture":"s100_number","path":"s100_number","type":"string","card":null,"preprocess":null},{"capture":"edition_value","path":"edition_value","type":"string","card":null,"preprocess":null},{"capture":"language","path":"language","type":"string","card":null,"preprocess":null},{"capture":"annex_marker","path":"annex_marker","type":"string","card":null,"preprocess":null},{"capture":"annex_letter","path":"annex_letter","type":"string","card":null,"preprocess":null},{"capture":"slug","path":"slug","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule identifier: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 1 and 4 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 1 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 2 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 2 and 4 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 2 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 3 and 4 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 3 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 4 and 5 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"G1040","expect":{}},{"entry":"identifier","kind":"accept","input":"GA1040","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S1070 Ed 2.0","expect":{}},{"entry":"identifier","kind":"accept","input":"R1016:ed2.0(F)","expect":{}},{"entry":"identifier","kind":"accept","input":"C0103-1 Ed 3.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA L2.1.11 Ed 2","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA G1128 Annex A Ed 1.6","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA G1045 Annex Ed 1","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA A12-01 (E)","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA arctic-seminar-report","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA 13th-vts-symposium-report (E)","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA iala-style-guide Ed 1.0 (E)","expect":{}},{"entry":"identifier","kind":"accept","input":"S-201 2.0.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-201 2.0.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-201 Ed 2.0.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-201:ed2.0.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-201","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA s-201 2.0.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-201 ANNEX B2","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-201 Annex A 1.0.0","expect":{}},{"entry":"identifier","kind":"accept","input":"IALA S-230 1.0.0 (E)","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}},{"entry":"identifier","kind":"reject","input":"arctic-seminar-report","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA Arctic-Seminar-Report","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA -arctic-seminar-report","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA arctic seminar report","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA arctic","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA arctic-","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA arctic--report","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA s1070","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA c0103-1","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA 1070 Ed 2.0","expect":{}},{"entry":"identifier","kind":"reject","input":"S-411 1.2.1","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA S-411 1.2.1","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA S-200 1.0.0","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA S-30 2.0","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA S-2011 2.0.0","expect":{}},{"entry":"identifier","kind":"reject","input":"IALA S-201 Ed","expect":{}},{"entry":"identifier","kind":"example","input":"G1040","expect":{"type_letter":"G","doc_number":"1040"}},{"entry":"identifier","kind":"example","input":"GA01.01","expect":{"type_letter":"GA","doc_number":"01","doc_number_dots":[{"dotted_segment":"01"}]}},{"entry":"identifier","kind":"example","input":"C0103-1","expect":{"type_letter":"C","doc_number":"0103","subpart":[{"subpart_number":"1"}]}},{"entry":"identifier","kind":"example","input":"IALA S1070 Ed 2.0","expect":{"type_letter":"S","doc_number":"1070","edition_value":"2.0"}},{"entry":"identifier","kind":"example","input":"IALA G1128 Annex A Ed 1.6","expect":{"type_letter":"G","doc_number":"1128","annex_marker":"Annex","annex_letter":"A","edition_value":"1.6"}},{"entry":"identifier","kind":"example","input":"IALA arctic-seminar-report (E)","expect":{"slug":"arctic-seminar-report","language":"E"}},{"entry":"identifier","kind":"example","input":"IALA S-201 2.0.0","expect":{"s100_number":"201","edition_value":"2.0.0"}},{"entry":"identifier","kind":"example","input":"IALA S-201 ANNEX B2","expect":{"s100_number":"201","annex_marker":"ANNEX","annex_letter":"B2"}},{"entry":"identifier","kind":"example","input":"IALA iala-world-wide-radio-navigation-plan Ed 2","expect":{"slug":"iala-world-wide-radio-navigation-plan","edition_value":"2"}}],"docs":{},"source":"# Port of lib/pubid/iala/parser.rb: [IALA ]<type><number>[.dots][-subs]\n# [ Ed X.Y | :edX.Y] [(L)], plus the Annex-to-base form. The annex\n# letter guard (!lower) keeps \"Ed 1\" from mis-capturing.\n#\n# The S-100-family product specifications (the IHO-granted S-201..S-299\n# range, iala.int/technical/data-modelling/iala-s-200-development-status):\n# the hyphenated lexical form \"S-201\" with the S-100 dotted x.y.z\n# edition on the BARE face (\"IALA S-201 2.0.0\", the site's own citation\n# form); \"Ed 2.0.0\" and the compact \":ed2.0.0\" parse as normalizing\n# aliases. The hundreds digit is fixed to 2 by the grant, so WMO's and\n# IHO's own S-series (\"S-411 1.2.1\") never parse here. The alternative\n# sits above slug_identifier so the lower-case spelling (\"IALA s-201\")\n# binds the typed form instead of the codeless slug. The S-100 annex\n# wrapper takes the sub-numbered annex letters the package attests\n# (\"Annex A\", \"ANNEX B2\", \"Annex D1\"), which widens the shared annex\n# letter rule to an optional digit for the legacy series as well.\n#\n# Edition-2 conversion with typed model bindings. Deviations from the\n# v1 tree:\n# - the dotted continuation and the dash subpart repeat capture-bearing\n# rule refs (the itu `parts` shape): a repetition over a capture-less\n# unit harvested as a bare span binds differently per engine, so the\n# bindings read the inner captures through the array paths\n# `doc_number_dots[].dotted_segment` and `subpart[].subpart_number`.\n# The dotted segment gains its own capture (`dotted_segment`); the\n# subpart keeps its `subpart_number` capture, hoisted out of the\n# inline repetition into a rule ref of its own.\n# - the annex base composite stays unbound. Every capture inside it\n# (type_letter, doc_number, …) is the only occurrence of its name on\n# the annex path, so the binding harvest hoists it to the top level:\n# the builder reads one flat map for the plain and the annex form\n# alike and dispatches on :annex_marker. edition_value and language\n# hoist out of their edition/language_group composites the same way.\n#\n# The codeless (slug) form: iala.int lists some publications (reports\n# and proceedings, the style guide, history books, radio plans) with no\n# code, and relaton gives them the product-URL slug as docid, e.g.\n# \"IALA arctic-seminar-report (E)\". slug_identifier is the last\n# alternative, so every typed code keeps priority; a typed code starts\n# upper-case and a slug lower-case or with a digit, so the two never\n# overlap. The \"IALA \" prefix is mandatory here (it is optional for a\n# typed code): without it any lower-case word would parse. The slug has\n# no space, so it never takes the trailing \" Ed <edition>\" or \" (<L>)\".\n# A slug is two or more hyphen-joined [a-z0-9] runs (every corpus slug\n# is), and its first run must not look like a code (0-2 letters and\n# digits: \"s1070\", \"ga01\", \"1070\"), so a lower-case or letterless typo\n# of a typed code (\"IALA s1070\", \"IALA c0103-1\", \"IALA 1070 Ed 2.0\")\n# still fails instead of parsing as a codeless publication.\n\ngrammar PubidIala version \"0.2.0\" edition 2 {\n type_letter = (\"GA\" / \"S\" / \"R\" / \"G\" / \"M\" / \"C\" / \"A\" / \"L\" / \"X\" / \"P\") as type_letter\n doc_number = (1*digit) as doc_number\n dotted_number = dot (1*digit) as dotted_segment\n number_with_dots = doc_number (*dotted_number) as doc_number_dots\n subpart_number = dash (1*digit) as subpart_number\n subpart = (1*subpart_number) as subpart\n code = type_letter number_with_dots [subpart]\n s100_number = (!\"200\" (\"2\" digit digit)) as s100_number\n s100_code = ((\"S\" / \"s\") dash s100_number)\n edition_value = (1*digit *(dot 1*digit)) as edition_value\n edition_human = (space \"Ed\" space edition_value) as edition\n edition_compact = (colon \"ed\" edition_value) as edition\n s100_edition = (space [\"Ed\" space] edition_value) as edition\n language_group = ([space] \"(\" (\"E\" / \"F\" / \"S\" / \"C\" / \"A\" / \"R\") as language \")\") as language_group\n annex_identifier = {\n ((publisher type_letter number_with_dots [subpart]) as base)\n space\n (\"Annex\" / \"ANNEX\") as annex_marker\n [ (space (upper [digit]) as annex_letter !lower) ]\n [edition_human / edition_compact]\n [language_group]\n }\n plain_identifier = {\n publisher code [edition_human / edition_compact] [language_group]\n }\n s100_annex_identifier = {\n publisher s100_code\n space\n (\"Annex\" / \"ANNEX\") as annex_marker\n [ (space (upper [digit]) as annex_letter !lower) ]\n [edition_human / edition_compact / s100_edition]\n [language_group]\n }\n s100_identifier = {\n publisher s100_code\n [edition_human / edition_compact / s100_edition]\n [language_group]\n }\n slug_segment = 1*(lower / digit)\n slug_code_like = *2lower 1*digit !(lower / digit)\n slug = (!slug_code_like slug_segment 1*(dash slug_segment)) as slug\n slug_identifier = {\n \"IALA \" slug [edition_human] [language_group]\n }\n identifier = {\n annex_identifier\n / plain_identifier\n / s100_annex_identifier\n / s100_identifier\n / slug_identifier\n }\n publisher = [\"IALA \"]\n upper = %x41-5A\n lower = %x61-7A\n digit = %x30-39\n dash = \"-\"\n colon = \":\"\n dot = \".\"\n space = \" \"\n entry identifier: identifier\n\n bindings identifier {\n type_letter -> type_letter (string)\n doc_number -> doc_number (string)\n dotted_segment -> doc_number_dots[].dotted_segment (string)\n subpart_number -> subpart[].subpart_number (string)\n s100_number -> s100_number (string)\n edition_value -> edition_value (string)\n language -> language (string)\n annex_marker -> annex_marker (string)\n annex_letter -> annex_letter (string)\n slug -> slug (string)\n }\n\n test {\n accept \"G1040\"\n accept \"GA1040\"\n accept \"IALA S1070 Ed 2.0\"\n accept \"R1016:ed2.0(F)\"\n accept \"C0103-1 Ed 3.0\"\n accept \"IALA L2.1.11 Ed 2\"\n accept \"IALA G1128 Annex A Ed 1.6\"\n accept \"IALA G1045 Annex Ed 1\"\n accept \"IALA A12-01 (E)\"\n accept \"IALA arctic-seminar-report\"\n accept \"IALA 13th-vts-symposium-report (E)\"\n accept \"IALA iala-style-guide Ed 1.0 (E)\"\n accept \"S-201 2.0.0\"\n accept \"IALA S-201 2.0.0\"\n accept \"IALA S-201 Ed 2.0.0\"\n accept \"IALA S-201:ed2.0.0\"\n accept \"IALA S-201\"\n accept \"IALA s-201 2.0.0\"\n accept \"IALA S-201 ANNEX B2\"\n accept \"IALA S-201 Annex A 1.0.0\"\n accept \"IALA S-230 1.0.0 (E)\"\n reject \"nonsense\"\n reject \"arctic-seminar-report\"\n reject \"IALA Arctic-Seminar-Report\"\n reject \"IALA -arctic-seminar-report\"\n reject \"IALA arctic seminar report\"\n reject \"IALA arctic\"\n reject \"IALA arctic-\"\n reject \"IALA arctic--report\"\n reject \"IALA s1070\"\n reject \"IALA c0103-1\"\n reject \"IALA 1070 Ed 2.0\"\n reject \"S-411 1.2.1\"\n reject \"IALA S-411 1.2.1\"\n reject \"IALA S-200 1.0.0\"\n reject \"IALA S-30 2.0\"\n reject \"IALA S-2011 2.0.0\"\n reject \"IALA S-201 Ed\"\n example \"G1040\" { type_letter: \"G\", doc_number: \"1040\" }\n example \"GA01.01\" {\n type_letter: \"GA\",\n doc_number: \"01\",\n doc_number_dots: [ { dotted_segment: \"01\" } ],\n }\n example \"C0103-1\" {\n type_letter: \"C\",\n doc_number: \"0103\",\n subpart: [ { subpart_number: \"1\" } ],\n }\n example \"IALA S1070 Ed 2.0\" {\n type_letter: \"S\",\n doc_number: \"1070\",\n edition_value: \"2.0\",\n }\n example \"IALA G1128 Annex A Ed 1.6\" {\n type_letter: \"G\",\n doc_number: \"1128\",\n annex_marker: \"Annex\",\n annex_letter: \"A\",\n edition_value: \"1.6\",\n }\n example \"IALA arctic-seminar-report (E)\" {\n slug: \"arctic-seminar-report\",\n language: \"E\",\n }\n example \"IALA S-201 2.0.0\" {\n s100_number: \"201\",\n edition_value: \"2.0.0\",\n }\n example \"IALA S-201 ANNEX B2\" {\n s100_number: \"201\",\n annex_marker: \"ANNEX\",\n annex_letter: \"B2\",\n }\n example \"IALA iala-world-wide-radio-navigation-plan Ed 2\" {\n slug: \"iala-world-wide-radio-navigation-plan\",\n edition_value: \"2\",\n }\n }\n}\n","source_hash":"4bc93bf63b1692f346ce1cb273eff7adc50fc36a2d9c9904cda4e5457dacbae1","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:f21ad5b10665dcb1c4cc0d266e9b20359baab33900b2422a87c9ab0ace3c80eb","checksum":"sha256:c6e3329aa3e2bba2504bededcc333568c5672898e614099111dc72e5747b5d80","validated":{"lint_errors":0,"lint_warnings":10,"tests_total":47,"tests_failures":0,"self_test":true}}
|