@pubid/pubid 0.1.69 → 0.1.70
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/README.md +75 -1
- package/dist/flavors/ieee/artifact_tree.js +1 -1
- package/dist/flavors/ieee/implementation.d.ts +16 -0
- package/dist/flavors/ieee/implementation.js +2195 -0
- package/dist/flavors/ieee/index.js +18 -2181
- package/dist/flavors/ieee/worker.d.ts +7 -0
- package/dist/flavors/ieee/worker.js +31 -0
- package/dist/flavors/index.js +1 -1
- package/dist/flavors/nist/implementation.d.ts +5 -0
- package/dist/flavors/nist/implementation.js +1326 -0
- package/dist/flavors/nist/index.js +14 -1330
- package/dist/flavors/nist/worker.d.ts +3 -0
- package/dist/flavors/nist/worker.js +24 -0
- package/dist/flavors/oiml/implementation.d.ts +2 -1
- package/dist/flavors/oiml/implementation.js +2 -3
- package/dist/flavors/oiml/index.d.ts +2 -0
- package/dist/flavors/oiml/index.js +10 -0
- package/dist/flavors/oiml/worker.d.ts +2 -0
- package/dist/flavors/oiml/worker.js +14 -0
- package/dist/parg/artifacts/ieee.d.ts +2 -0
- package/dist/parg/artifacts/ieee.js +5 -0
- package/dist/parg/artifacts/nist.d.ts +2 -0
- package/dist/parg/artifacts/nist.js +5 -0
- package/dist/parg/runtime.d.ts +1 -13
- package/dist/parg/runtime.js +4 -36
- package/dist/parg/shape.d.ts +13 -0
- package/dist/parg/shape.js +39 -0
- package/dist/parg/worker.d.ts +9 -0
- package/dist/parg/worker.js +32 -0
- package/dist/register-types.d.ts +7 -1
- package/dist/register-types.js +7 -1
- package/package.json +7 -2
|
@@ -1,2191 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
//! The node entry for the ieee flavor: the fs-backed PARG runtime and
|
|
2
|
+
//! the grammar-barrel co-publisher routing wired into the flavor's
|
|
3
|
+
//! pure implementation. The implementation (./implementation.js) is
|
|
4
|
+
//! environment-agnostic; the worker entry (./worker.js) composes the
|
|
5
|
+
//! same code over parsanol's browser engine and the bundled artifact
|
|
6
|
+
//! (pubid/pubid-ts#232).
|
|
2
7
|
import { PubidRuntime } from "../../parg/runtime.js";
|
|
3
|
-
import { artifactToBuilderTree } from "./artifact_tree.js";
|
|
4
8
|
import { grammarImplementation } from "../index.js";
|
|
5
|
-
import {
|
|
6
|
-
import { preParse, preprocessIeee } from "./preprocessor.js";
|
|
7
|
-
import { applyUpdateCodes } from "./update_codes.js";
|
|
8
|
-
import { AdoptedStandardClass, AieeClass, AmendmentClass, ConformanceClass, CorrigendumClass, CsaDualPublishedClass, DualPublishedClass, IecIeeeCopublishedClass, IeeeCode, IeeeDraft, IeeeRelationship, IeeeTypedStage, InterpretationClass, IreClass, JointDevelopmentClass, MultiNumberedClass, NescDraftClass, NescEditionClass, NescHandbookClass, NescPreprintClass, NescRedlineClass, NescStandardClass, DRAFT_MONTH_NAMES, ProjectDraftIdentifierClass, SiStandardClass, StandardClass, locateStage, } from "./model.js";
|
|
9
|
-
/**
|
|
10
|
-
* Port of lib/pubid/ieee/{builder}.rb + Identifier.parse orchestration
|
|
11
|
-
* (pre-parser dispatch, adopted/dual constructors, sub-builders).
|
|
12
|
-
*/
|
|
13
|
-
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
14
|
-
const extractValue = (value) => {
|
|
15
|
-
if (value === undefined || value === null)
|
|
16
|
-
return undefined;
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
if (value.length === 0)
|
|
19
|
-
return undefined;
|
|
20
|
-
const joined = value.join("");
|
|
21
|
-
return joined.length > 0 ? joined : undefined;
|
|
22
|
-
}
|
|
23
|
-
const strValue = String(value).trim();
|
|
24
|
-
return strValue.length > 0 ? strValue : undefined;
|
|
25
|
-
};
|
|
26
|
-
function mergeParsedArray(parsedArray) {
|
|
27
|
-
return Object.assign({}, ...parsedArray);
|
|
28
|
-
}
|
|
29
|
-
const asHash = (v) => (Array.isArray(v) ? mergeParsedArray(v) : v);
|
|
30
|
-
const SI_STAGES = [
|
|
31
|
-
{ abbr: ["SI"], stage_code: "published", type_code: "SI" },
|
|
32
|
-
{ abbr: ["PSI"], stage_code: "draft", type_code: "SI" },
|
|
33
|
-
];
|
|
34
|
-
// --- Builder -----------------------------------------------------------------
|
|
35
|
-
class IeeeBuilder {
|
|
36
|
-
originalInput = "";
|
|
37
|
-
build(parsed) {
|
|
38
|
-
const d = Array.isArray(parsed) ? mergeParsedArray(parsed) : parsed;
|
|
39
|
-
if (d["ieee_portion"] !== undefined && d["csa_portion"] !== undefined) {
|
|
40
|
-
return this.buildCsaDualPublished(d);
|
|
41
|
-
}
|
|
42
|
-
if (d["s_number"] !== undefined)
|
|
43
|
-
return this.buildSDesignation(d);
|
|
44
|
-
if (d["first_aiee"] !== undefined && d["second_aiee"] !== undefined) {
|
|
45
|
-
return this.buildCombinedAiee(d);
|
|
46
|
-
}
|
|
47
|
-
if (d["content"] !== undefined)
|
|
48
|
-
return this.buildIecIeeCopublished(d);
|
|
49
|
-
if (d["nesc"] !== undefined)
|
|
50
|
-
return this.buildNesc(asHash(d["nesc"]));
|
|
51
|
-
if (d["aiee"] !== undefined)
|
|
52
|
-
return this.buildAiee(asHash(d["aiee"]));
|
|
53
|
-
if (d["ire"] !== undefined)
|
|
54
|
-
return this.buildIre(asHash(d["ire"]));
|
|
55
|
-
if (d["si_type"] !== undefined)
|
|
56
|
-
return this.buildSiPsi(d);
|
|
57
|
-
return this.buildSingleIdentifier(d, false);
|
|
58
|
-
}
|
|
59
|
-
// --- single identifier -----------------------------------------------------
|
|
60
|
-
// Deep-first collection of every :subpart node under a raw
|
|
61
|
-
// part_subpart_year wrapper (hash or array, any nesting).
|
|
62
|
-
collectSubparts(node, out = []) {
|
|
63
|
-
if (isObj(node)) {
|
|
64
|
-
for (const [key, value] of Object.entries(node)) {
|
|
65
|
-
if (key === "subpart")
|
|
66
|
-
out.push(value);
|
|
67
|
-
else
|
|
68
|
-
this.collectSubparts(value, out);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (Array.isArray(node)) {
|
|
72
|
-
for (const item of node)
|
|
73
|
-
this.collectSubparts(item, out);
|
|
74
|
-
}
|
|
75
|
-
return out;
|
|
76
|
-
}
|
|
77
|
-
// The part/subpart/year captures ride the raw part_subpart_year wrapper
|
|
78
|
-
// (parsanol-ruby#399: the repeated-subpart flat spread clobbers to the
|
|
79
|
-
// last value, so the run does not bind top-level). Hoist the wrapper's
|
|
80
|
-
// part/year and deep-collect its interior subparts, so every consumer —
|
|
81
|
-
// and every raw subtree built through here (the CSA dual's
|
|
82
|
-
// ieee_portion, the multi-numbered primary, the supplement bases) —
|
|
83
|
-
// sees the flat keys it has always read (the reference's
|
|
84
|
-
// unwrap_part_subpart_year).
|
|
85
|
-
unwrapPartSubpartYear(node) {
|
|
86
|
-
const run = node["part_subpart_year"];
|
|
87
|
-
if (run === undefined)
|
|
88
|
-
return;
|
|
89
|
-
const nodes = Array.isArray(run) ? run : [run];
|
|
90
|
-
const flat = {};
|
|
91
|
-
for (const item of nodes) {
|
|
92
|
-
if (isObj(item))
|
|
93
|
-
Object.assign(flat, item);
|
|
94
|
-
}
|
|
95
|
-
if (flat["part"] !== undefined)
|
|
96
|
-
node["part"] = flat["part"];
|
|
97
|
-
if (flat["year"] !== undefined)
|
|
98
|
-
node["year"] = flat["year"];
|
|
99
|
-
if (node["subpart"] === undefined) {
|
|
100
|
-
const collected = this.collectSubparts(run);
|
|
101
|
-
if (collected.length > 0)
|
|
102
|
-
node["subpart"] = collected;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// The edition-2 wasm tree → the native engine's flat shape — the
|
|
106
|
-
// normalization prelude the reference's build_single_identifier runs
|
|
107
|
-
// before every dispatch (builder.rb: the scalar surfacing, the
|
|
108
|
-
// composite rename, the wrapper unwrap, the draft-array repairs and
|
|
109
|
-
// the dash-date hoist).
|
|
110
|
-
normalizeParsedHash(parsedHash) {
|
|
111
|
-
// The wasm bound map captures the optional rev_sep for every printed
|
|
112
|
-
// boundary; the reference's native engine binds it on the bare-REV
|
|
113
|
-
// ("-REV/D1.7" keeps "-") and lettered-revision branches
|
|
114
|
-
// ("-REVmc" keeps "-") and declines it on every numeric revision
|
|
115
|
-
// spelling (".Rev 3", "/rev43", "-rev1", "_Rev2", " Rev 8" — the
|
|
116
|
-
// rev_numbered route, parsanol-ruby#394 family), so the render glues
|
|
117
|
-
// the numeric lettered revisions on those rows.
|
|
118
|
-
if (parsedHash["rev_sep"] !== undefined) {
|
|
119
|
-
const revision = extractValue(parsedHash["revision"]) ?? "";
|
|
120
|
-
if (/^[0-9]+$/.test(revision)) {
|
|
121
|
-
delete parsedHash["rev_sep"];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// The grammar binds the bare top-level draft clause as
|
|
125
|
-
// draft_version_scalar (string) — surface it under the key the rest
|
|
126
|
-
// of the builder has always read.
|
|
127
|
-
if (parsedHash["draft_version"] === undefined && parsedHash["draft_version_scalar"] !== undefined) {
|
|
128
|
-
parsedHash["draft_version"] = parsedHash["draft_version_scalar"];
|
|
129
|
-
delete parsedHash["draft_version_scalar"];
|
|
130
|
-
}
|
|
131
|
-
// The composite draft rule binds draft_version_composite (raw)
|
|
132
|
-
// inside the draft elements; rename it under the interior key the
|
|
133
|
-
// draft-element walks read.
|
|
134
|
-
const draftElems0 = Array.isArray(parsedHash["draft"])
|
|
135
|
-
? parsedHash["draft"]
|
|
136
|
-
: [parsedHash["draft"]];
|
|
137
|
-
for (const e of draftElems0) {
|
|
138
|
-
if (isObj(e) && e["draft_version"] === undefined && e["draft_version_composite"] !== undefined) {
|
|
139
|
-
e["draft_version"] = e["draft_version_composite"];
|
|
140
|
-
delete e["draft_version_composite"];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
this.unwrapPartSubpartYear(parsedHash);
|
|
144
|
-
// A revision element INSIDE the draft array is the draft rule's own
|
|
145
|
-
// split artifact (the version's trailing ".1" segment) — the spine
|
|
146
|
-
// captured the same value; drop it.
|
|
147
|
-
if (Array.isArray(parsedHash["draft"]) && parsedHash["revision"] !== undefined) {
|
|
148
|
-
const artifact = parsedHash["draft"].some((e) => isObj(e) && e["revision"] !== undefined &&
|
|
149
|
-
String(extractValue(e["revision"]) ?? "") === String(extractValue(parsedHash["revision"]) ?? ""));
|
|
150
|
-
if (artifact)
|
|
151
|
-
delete parsedHash["revision"];
|
|
152
|
-
}
|
|
153
|
-
// The edition-2 tree materializes a multi-segment draft version
|
|
154
|
-
// ("D2.1.1") as per-token nodes carrying no draft_version key (the
|
|
155
|
-
// v1 tree degraded such a clause to a whole-clause LEAF string when
|
|
156
|
-
// no draft date follows, and to a date-only hash when it does).
|
|
157
|
-
// Normalize to the v1 shape before the stage derivation and draft
|
|
158
|
-
// handling read it.
|
|
159
|
-
if (Array.isArray(parsedHash["draft"])) {
|
|
160
|
-
const elems = parsedHash["draft"].filter(isObj);
|
|
161
|
-
if (elems.length > 0 && elems.every((e) => e["draft_version"] === undefined)) {
|
|
162
|
-
const hasDate = elems.some((e) => e["draft_date_month"] !== undefined || e["draft_date_year"] !== undefined);
|
|
163
|
-
if (hasDate) {
|
|
164
|
-
const dateElems = elems.filter((e) => e["draft_date_month"] !== undefined || e["draft_date_year"] !== undefined || e["draft_date_day"] !== undefined);
|
|
165
|
-
parsedHash["draft"] = Object.assign({}, ...dateElems);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
parsedHash["draft"] = elems
|
|
169
|
-
.flatMap((e) => Object.values(e))
|
|
170
|
-
.map((v) => String(extractValue(v) ?? ""))
|
|
171
|
-
.join("");
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const drafts = Array.isArray(parsedHash["draft"])
|
|
176
|
-
? parsedHash["draft"]
|
|
177
|
-
: [parsedHash["draft"]].filter((v) => v !== undefined);
|
|
178
|
-
// The edition-2 grammar renames the nested draft-version dash
|
|
179
|
-
// captures (draft_version_dash_year/month); hoist them to the
|
|
180
|
-
// element level the dash walk reads, and drop the wrapper key.
|
|
181
|
-
for (const d of drafts) {
|
|
182
|
-
if (!isObj(d) || !isObj(d["draft_version"]))
|
|
183
|
-
continue;
|
|
184
|
-
const dv = d["draft_version"];
|
|
185
|
-
if (dv["draft_version_dash_year"] !== undefined || dv["dash_year"] !== undefined) {
|
|
186
|
-
d["dash_year"] = dv["draft_version_dash_year"] ?? dv["dash_year"];
|
|
187
|
-
}
|
|
188
|
-
if (dv["draft_version_dash_month"] !== undefined || dv["dash_month"] !== undefined) {
|
|
189
|
-
d["dash_month"] = dv["draft_version_dash_month"] ?? dv["dash_month"];
|
|
190
|
-
}
|
|
191
|
-
delete d["draft_version"];
|
|
192
|
-
}
|
|
193
|
-
// The dash host: the top-level spine, else a draft element carrying
|
|
194
|
-
// its own dash date (draft_date_dash_year/month on the edition-2
|
|
195
|
-
// grammar, dash_year/month on v1 — read both spellings).
|
|
196
|
-
let dash = parsedHash["dash_year"] !== undefined ? parsedHash : undefined;
|
|
197
|
-
if (dash === undefined) {
|
|
198
|
-
for (const d of drafts) {
|
|
199
|
-
if (isObj(d) && (d["draft_date_dash_year"] !== undefined || d["dash_year"] !== undefined)) {
|
|
200
|
-
dash = d;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// A numeric month trailing a draft is the draft's own date: it
|
|
206
|
-
// embeds in the designator ("D09, 04 2011" -> "D09-2011-04") rather
|
|
207
|
-
// than printing the long-format comma face — pubid ruling
|
|
208
|
-
// 2026-10-13.
|
|
209
|
-
if (dash === undefined && parsedHash["draft"] !== undefined) {
|
|
210
|
-
const mVal = extractValue((parsedHash["month"] ?? parsedHash["trailing_month"]));
|
|
211
|
-
const yVal = extractValue((parsedHash["year"] ?? parsedHash["trailing_year"]));
|
|
212
|
-
if (mVal !== undefined && /^\d{1,2}$/.test(mVal) && yVal !== undefined) {
|
|
213
|
-
const host = drafts.find((d) => isObj(d) && d["draft_version"] !== undefined);
|
|
214
|
-
if (host !== undefined && isObj(host)) {
|
|
215
|
-
const hv = host["draft_version"];
|
|
216
|
-
const joined = Array.isArray(hv)
|
|
217
|
-
? hv.map((v) => extractValue(v) ?? "").join("")
|
|
218
|
-
: String(extractValue(hv) ?? "");
|
|
219
|
-
host["draft_version"] = [joined, yVal, mVal].filter((s) => s !== "").join("-");
|
|
220
|
-
delete parsedHash["month"];
|
|
221
|
-
delete parsedHash["year"];
|
|
222
|
-
delete parsedHash["trailing_month"];
|
|
223
|
-
delete parsedHash["trailing_year"];
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (dash === undefined)
|
|
228
|
-
return;
|
|
229
|
-
// The draft's own dash date embeds onto the draft even when a base
|
|
230
|
-
// identity year is present ("…-2011/D4-2015-07"); only the root-year
|
|
231
|
-
// assignment waits for an unoccupied year slot.
|
|
232
|
-
const objs = drafts.filter(isObj);
|
|
233
|
-
const joined = objs
|
|
234
|
-
.map((e) => e["draft_version"])
|
|
235
|
-
.filter((v) => v !== undefined)
|
|
236
|
-
.map((v) => (Array.isArray(v) ? v.map((x) => extractValue(x) ?? "").join("") : String(extractValue(v) ?? "")))
|
|
237
|
-
.join("");
|
|
238
|
-
const dashY = extractValue((dash["dash_year"] ?? dash["draft_date_dash_year"]));
|
|
239
|
-
const dashM = extractValue((dash["dash_month"] ?? dash["draft_date_dash_month"]));
|
|
240
|
-
const clearDash = () => {
|
|
241
|
-
delete dash["dash_year"];
|
|
242
|
-
delete dash["dash_month"];
|
|
243
|
-
delete dash["draft_date_dash_year"];
|
|
244
|
-
delete dash["draft_date_dash_month"];
|
|
245
|
-
};
|
|
246
|
-
const embed = () => {
|
|
247
|
-
const host = drafts.find((d) => isObj(d) && d["draft_version"] !== undefined);
|
|
248
|
-
if (host === undefined || !isObj(host))
|
|
249
|
-
return undefined;
|
|
250
|
-
const hv = host["draft_version"];
|
|
251
|
-
const vJoined = Array.isArray(hv)
|
|
252
|
-
? hv.map((v) => extractValue(v) ?? "").join("")
|
|
253
|
-
: String(extractValue(hv) ?? "");
|
|
254
|
-
host["draft_version"] = [vJoined, dashY, dashM]
|
|
255
|
-
.filter((s) => s !== undefined)
|
|
256
|
-
.join("-");
|
|
257
|
-
return host;
|
|
258
|
-
};
|
|
259
|
-
const bareJointDraft = parsedHash["joint_publishers"] !== undefined &&
|
|
260
|
-
parsedHash["part"] === undefined && parsedHash["iso_stage"] === undefined &&
|
|
261
|
-
objs.some((e) => e["draft_version"] !== undefined);
|
|
262
|
-
const dashLed = joined.startsWith("-");
|
|
263
|
-
if (bareJointDraft && dashLed) {
|
|
264
|
-
parsedHash["part"] = { value: dashY };
|
|
265
|
-
}
|
|
266
|
-
else if (dashM !== undefined && embed() !== undefined) {
|
|
267
|
-
clearDash();
|
|
268
|
-
}
|
|
269
|
-
else if ((dashM !== undefined || dashLed) && parsedHash["year"] === undefined) {
|
|
270
|
-
parsedHash["year"] = dashY;
|
|
271
|
-
parsedHash["month"] = dashM;
|
|
272
|
-
}
|
|
273
|
-
else if (embed() !== undefined) {
|
|
274
|
-
clearDash();
|
|
275
|
-
// the hyphenated "/D-2-2007" spelling's year the spine captured at
|
|
276
|
-
// top level is the draft's own — vacate it
|
|
277
|
-
if (extractValue(parsedHash["year"]) === dashY)
|
|
278
|
-
delete parsedHash["year"];
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
parsedHash["year"] = dashY;
|
|
282
|
-
parsedHash["month"] = dashM;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
buildSingleIdentifier(parsed, buildingSecondary) {
|
|
286
|
-
const parsedHash = asHash(parsed);
|
|
287
|
-
// The edition-2 wasm tree → the native engine's flat shape, before
|
|
288
|
-
// every dispatch reads it (the reference's prelude).
|
|
289
|
-
this.normalizeParsedHash(parsedHash);
|
|
290
|
-
if (!buildingSecondary && parsedHash["primary_identifier"] !== undefined &&
|
|
291
|
-
(parsedHash["secondary_crossref"] !== undefined || parsedHash["secondary_joint"] !== undefined)) {
|
|
292
|
-
return this.buildMultiNumbered(parsedHash);
|
|
293
|
-
}
|
|
294
|
-
if (parsedHash["base"] !== undefined && parsedHash["cor_number"] !== undefined) {
|
|
295
|
-
return this.buildCorrigendumSupplement(parsedHash);
|
|
296
|
-
}
|
|
297
|
-
// A corrigendum capture that is a bare STRING matched the marker
|
|
298
|
-
// without its ordinal - never a valid complete parse (the reference
|
|
299
|
-
// rejects "…Corrigendum/D1").
|
|
300
|
-
if (typeof parsedHash["corrigendum"] === "string") {
|
|
301
|
-
throw new ParseFailed("corrigendum marker without ordinal", 0);
|
|
302
|
-
}
|
|
303
|
-
if (isObj(parsedHash["corrigendum"]) && parsedHash["base"] === undefined) {
|
|
304
|
-
// A corrigendum marker without its ordinal is not a marker - the
|
|
305
|
-
// reference never completes such a parse ("…Corrigendum/D1").
|
|
306
|
-
const cor = asHash(parsedHash["corrigendum"]);
|
|
307
|
-
if (cor["cor_number"] === undefined && cor["cor_year"] === undefined) {
|
|
308
|
-
throw new ParseFailed("corrigendum marker without ordinal", 0);
|
|
309
|
-
}
|
|
310
|
-
return this.buildFlatCorrigendum(parsedHash);
|
|
311
|
-
}
|
|
312
|
-
if (parsedHash["base"] !== undefined && parsedHash["amd_number"] !== undefined) {
|
|
313
|
-
return this.buildAmendmentSupplement(parsedHash);
|
|
314
|
-
}
|
|
315
|
-
if (isObj(parsedHash["amendment"]) && parsedHash["base"] === undefined) {
|
|
316
|
-
return this.buildFlatAmendment(parsedHash);
|
|
317
|
-
}
|
|
318
|
-
if (parsedHash["base"] !== undefined &&
|
|
319
|
-
(parsedHash["int_year"] !== undefined || parsedHash["interpretation"] !== undefined)) {
|
|
320
|
-
return this.buildInterpretationSupplement(parsedHash);
|
|
321
|
-
}
|
|
322
|
-
if (parsedHash["interpretation"] !== undefined && parsedHash["base"] === undefined) {
|
|
323
|
-
return this.buildFlatInterpretation(parsedHash);
|
|
324
|
-
}
|
|
325
|
-
if (parsedHash["base"] !== undefined && parsedHash["conf_number"] !== undefined) {
|
|
326
|
-
return this.buildConformanceSupplement(parsedHash);
|
|
327
|
-
}
|
|
328
|
-
if (parsedHash["joint_publishers"] !== undefined || parsedHash["iso_stage"] !== undefined) {
|
|
329
|
-
return this.buildJointDevelopment(parsedHash);
|
|
330
|
-
}
|
|
331
|
-
// The ORDINAL-LESS D= designator on a multi-publisher row is the
|
|
332
|
-
// joint compound form ("ISO/IEC/IEEE P16326:2017/D=WD.4a"); the
|
|
333
|
-
// ordinal compound ("D8=DIS.3") is a project draft whatever the
|
|
334
|
-
// publishers — the D-ordinal is the draft, the stage the target.
|
|
335
|
-
if (parsedHash["draft_iso_stage"] !== undefined) {
|
|
336
|
-
const draftHash = parsedHash["draft"] !== undefined
|
|
337
|
-
? asHash(parsedHash["draft"])
|
|
338
|
-
: undefined;
|
|
339
|
-
const hasOrdinal = extractValue(parsedHash["draft_version"]) !== undefined ||
|
|
340
|
-
extractValue(draftHash?.["draft_version"]) !== undefined;
|
|
341
|
-
if (!hasOrdinal) {
|
|
342
|
-
const pubData = parsedHash["publishers"] !== undefined
|
|
343
|
-
? asHash(parsedHash["publishers"])
|
|
344
|
-
: undefined;
|
|
345
|
-
const copubs = pubData?.["copublishers"] !== undefined
|
|
346
|
-
? (Array.isArray(pubData["copublishers"]) ? pubData["copublishers"] : [pubData["copublishers"]])
|
|
347
|
-
: [];
|
|
348
|
-
if (copubs.length > 0)
|
|
349
|
-
return this.buildJointDevelopment(parsedHash);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
const attributes = this.extractAttributes(parsedHash);
|
|
353
|
-
if (parsedHash["relationship_type"] !== undefined || parsedHash["relationship_clause"] !== undefined) {
|
|
354
|
-
attributes["relationships"] = this.buildRelationships(parsedHash);
|
|
355
|
-
}
|
|
356
|
-
const klass = this.determineIdentifierClass(attributes);
|
|
357
|
-
// ProjectDraftIdentifier#initialize strips the leading P off the code
|
|
358
|
-
// string (the project marker lives in the stage, not the columns).
|
|
359
|
-
if (klass === ProjectDraftIdentifierClass) {
|
|
360
|
-
// The strip happens on the CODE STRING before Code.parse (Ruby
|
|
361
|
-
// ProjectDraftIdentifier#initialize), so "PIEEP62" -> prefix I.
|
|
362
|
-
const codeStr = attributes["__code"];
|
|
363
|
-
if (codeStr !== undefined && codeStr.startsWith("P")) {
|
|
364
|
-
const codeObj = IeeeCode.parse(codeStr.slice(1));
|
|
365
|
-
delete attributes["prefix"];
|
|
366
|
-
delete attributes["parts"];
|
|
367
|
-
delete attributes["separator"];
|
|
368
|
-
attributes["number"] = codeObj?.number;
|
|
369
|
-
if (codeObj?.prefix !== undefined)
|
|
370
|
-
attributes["prefix"] = codeObj.prefix;
|
|
371
|
-
if (codeObj !== undefined && codeObj.parts.length > 0)
|
|
372
|
-
attributes["parts"] = codeObj.parts;
|
|
373
|
-
if (codeObj?.originalSeparator !== undefined)
|
|
374
|
-
attributes["separator"] = codeObj.originalSeparator;
|
|
375
|
-
if (codeObj !== undefined)
|
|
376
|
-
attributes["__code_obj"] = codeObj;
|
|
377
|
-
// P = project (the document is a draft): the marker is
|
|
378
|
-
// identity-bearing, so stripping the letter must not strip the
|
|
379
|
-
// fact (docs/IEEE-DRAFT-STAGES.md §1.1).
|
|
380
|
-
attributes["project_marker"] = true;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
delete attributes["__code"];
|
|
384
|
-
this.renameSupplementKeys(attributes);
|
|
385
|
-
// The parse path carries the freshly parsed Code (per-part
|
|
386
|
-
// separators — the reference's `code:` string → Components::Code.parse
|
|
387
|
-
// in base #initialize); the column-only rebuild stays the from_hash
|
|
388
|
-
// face.
|
|
389
|
-
const built = new klass(attributes);
|
|
390
|
-
if (attributes["__code_obj"] instanceof IeeeCode) {
|
|
391
|
-
built["__code_obj"] = attributes["__code_obj"];
|
|
392
|
-
}
|
|
393
|
-
return built;
|
|
394
|
-
}
|
|
395
|
-
renameSupplementKeys(attributes) {
|
|
396
|
-
const ordinal = attributes["cor_number"] ?? attributes["amd_number"] ?? attributes["conf_number"];
|
|
397
|
-
delete attributes["cor_number"];
|
|
398
|
-
delete attributes["amd_number"];
|
|
399
|
-
delete attributes["conf_number"];
|
|
400
|
-
if (ordinal !== undefined)
|
|
401
|
-
attributes["number"] = ordinal;
|
|
402
|
-
const year = attributes["cor_year"] ?? attributes["amd_year"] ?? attributes["conf_year"] ?? attributes["int_year"];
|
|
403
|
-
delete attributes["cor_year"];
|
|
404
|
-
delete attributes["amd_year"];
|
|
405
|
-
delete attributes["conf_year"];
|
|
406
|
-
delete attributes["int_year"];
|
|
407
|
-
if (year !== undefined)
|
|
408
|
-
attributes["year"] = year;
|
|
409
|
-
}
|
|
410
|
-
determineIdentifierClass(attributes) {
|
|
411
|
-
if (attributes["publisher"] === "AIEE")
|
|
412
|
-
return AieeClass;
|
|
413
|
-
// A stage-bearing row is a joint development whatever its type
|
|
414
|
-
// code: the stage is the printed identity ("IEEE P15026.2/FDIS",
|
|
415
|
-
// pubid#203) and only the joint model carries iso_stage and the D=
|
|
416
|
-
// designator (the reference's chooser).
|
|
417
|
-
if (attributes["iso_stage"] !== undefined ||
|
|
418
|
-
(attributes["ieee_draft"] ?? "").startsWith("D=")) {
|
|
419
|
-
return JointDevelopmentClass;
|
|
420
|
-
}
|
|
421
|
-
const typeCode = attributes["type"];
|
|
422
|
-
if (typeCode === "P")
|
|
423
|
-
return ProjectDraftIdentifierClass;
|
|
424
|
-
if (typeCode === "SI" || typeCode === "PSI")
|
|
425
|
-
return SiStandardClass;
|
|
426
|
-
if (attributes["interpretation"] === true || attributes["int_year"] !== undefined) {
|
|
427
|
-
return InterpretationClass;
|
|
428
|
-
}
|
|
429
|
-
if (attributes["conf_number"] !== undefined)
|
|
430
|
-
return ConformanceClass;
|
|
431
|
-
if (attributes["cor_number"] !== undefined)
|
|
432
|
-
return CorrigendumClass;
|
|
433
|
-
if (attributes["amd_number"] !== undefined)
|
|
434
|
-
return AmendmentClass;
|
|
435
|
-
if (attributes["adoption"] !== undefined)
|
|
436
|
-
return AdoptedStandardClass;
|
|
437
|
-
return StandardClass;
|
|
438
|
-
}
|
|
439
|
-
// --- extract_attributes ----------------------------------------------------
|
|
440
|
-
extractAttributes(parsed) {
|
|
441
|
-
const attributes = {};
|
|
442
|
-
if (parsed["publishers"] !== undefined) {
|
|
443
|
-
const pubData = asHash(parsed["publishers"]);
|
|
444
|
-
attributes["publisher"] = extractValue(pubData["publisher"]);
|
|
445
|
-
if (pubData["copublishers"] !== undefined) {
|
|
446
|
-
const copubs = Array.isArray(pubData["copublishers"])
|
|
447
|
-
? pubData["copublishers"]
|
|
448
|
-
: [pubData["copublishers"]];
|
|
449
|
-
// A capture may carry its own separators ("/IEC/ISO" — a joint
|
|
450
|
-
// token glued to the leading slash); the collection renders
|
|
451
|
-
// join("/"), so entries hold bare orgs.
|
|
452
|
-
attributes["copublisher"] = copubs
|
|
453
|
-
.map((cp) => extractValue(asHash(cp)["copublisher"]))
|
|
454
|
-
.filter((cp) => cp !== undefined)
|
|
455
|
-
.flatMap((c) => c.replace(/^\//, "").split("/"))
|
|
456
|
-
.filter((c) => c !== "");
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
else if (parsed["publisher"] !== undefined) {
|
|
460
|
-
attributes["publisher"] = extractValue(parsed["publisher"]);
|
|
461
|
-
}
|
|
462
|
-
const codeParts = [];
|
|
463
|
-
if (parsed["part"] !== undefined)
|
|
464
|
-
codeParts.push(extractValue(parsed["part"]) ?? "");
|
|
465
|
-
if (parsed["subpart"] !== undefined) {
|
|
466
|
-
const subparts = Array.isArray(parsed["subpart"]) ? parsed["subpart"] : [parsed["subpart"]];
|
|
467
|
-
for (const sp of subparts) {
|
|
468
|
-
const v = extractValue(sp);
|
|
469
|
-
if (v !== undefined)
|
|
470
|
-
codeParts.push(v);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
let codeStr = extractValue(parsed["number"]);
|
|
474
|
-
let typeValue = extractValue(parsed["type"]);
|
|
475
|
-
const draftStatusValue = extractValue(parsed["draft_status"]);
|
|
476
|
-
if (typeValue === undefined && this.originalInput !== "" && /IEEE\s+P/.test(this.originalInput)) {
|
|
477
|
-
typeValue = "P";
|
|
478
|
-
}
|
|
479
|
-
if (typeValue === undefined && this.originalInput !== "" && /ANSI\s+P/.test(this.originalInput)) {
|
|
480
|
-
typeValue = "P";
|
|
481
|
-
// The P is identity on a non-IEEE-led publisher too (the C1
|
|
482
|
-
// ruling): record the marker so the render prepends it —
|
|
483
|
-
// "ANSI PN42.34/D9a, 2015" round-trips.
|
|
484
|
-
attributes["project_marker"] = true;
|
|
485
|
-
}
|
|
486
|
-
if (codeStr !== undefined && codeStr.startsWith("P") && this.originalInput.includes("/CSA")) {
|
|
487
|
-
const pubData = parsed["publishers"] !== undefined ? asHash(parsed["publishers"]) : undefined;
|
|
488
|
-
const hasCsaCopub = pubData?.["copublishers"] !== undefined
|
|
489
|
-
? (Array.isArray(pubData["copublishers"]) ? pubData["copublishers"] : [pubData["copublishers"]])
|
|
490
|
-
.some((cp) => (extractValue(asHash(cp)["copublisher"]) ?? "").includes("CSA"))
|
|
491
|
-
: this.originalInput.includes("/CSA");
|
|
492
|
-
if (hasCsaCopub)
|
|
493
|
-
codeStr = codeStr.replace(/^P/, "");
|
|
494
|
-
}
|
|
495
|
-
if (codeStr !== undefined && codeParts.length > 0) {
|
|
496
|
-
// Captures carry their own separator when present (the artifact's
|
|
497
|
-
// part/subpart bind ".18" / "-10"); join verbatim like the
|
|
498
|
-
// reference's extract_attributes — a dashed "62271-37-082" stays
|
|
499
|
-
// dashed.
|
|
500
|
-
codeStr += codeParts.join("");
|
|
501
|
-
}
|
|
502
|
-
if (codeStr !== undefined && parsed["year"] === undefined && codeParts.length === 0) {
|
|
503
|
-
const m = /^(.+)-(\d{4})$/.exec(codeStr);
|
|
504
|
-
if (m !== null) {
|
|
505
|
-
const potentialYear = Number.parseInt(m[2], 10);
|
|
506
|
-
if (potentialYear >= 1884 && potentialYear <= 2099) {
|
|
507
|
-
codeStr = m[1];
|
|
508
|
-
parsed["year"] = m[2];
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
const codeObj = codeStr !== undefined ? IeeeCode.parse(codeStr) : undefined;
|
|
513
|
-
if (codeStr !== undefined)
|
|
514
|
-
attributes["__code"] = codeStr;
|
|
515
|
-
if (codeObj !== undefined) {
|
|
516
|
-
attributes["__code_obj"] = codeObj;
|
|
517
|
-
attributes["number"] = codeObj.number;
|
|
518
|
-
if (codeObj.prefix !== undefined)
|
|
519
|
-
attributes["prefix"] = codeObj.prefix;
|
|
520
|
-
if (codeObj.parts.length > 0)
|
|
521
|
-
attributes["parts"] = codeObj.parts;
|
|
522
|
-
if (codeObj.originalSeparator !== undefined)
|
|
523
|
-
attributes["separator"] = codeObj.originalSeparator;
|
|
524
|
-
}
|
|
525
|
-
if (parsed["year"] !== undefined) {
|
|
526
|
-
attributes["year"] = extractValue(parsed["year"]);
|
|
527
|
-
}
|
|
528
|
-
else if (parsed["edition_year"] !== undefined) {
|
|
529
|
-
attributes["year"] = extractValue(parsed["edition_year"]);
|
|
530
|
-
}
|
|
531
|
-
else if (parsed["trailing_year"] !== undefined) {
|
|
532
|
-
attributes["year"] = extractValue(parsed["trailing_year"]);
|
|
533
|
-
if (parsed["trailing_month"] !== undefined) {
|
|
534
|
-
attributes["month"] = extractValue(parsed["trailing_month"]);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
if (parsed["edition_month"] !== undefined) {
|
|
538
|
-
attributes["edition_month"] = extractValue(parsed["edition_month"]);
|
|
539
|
-
}
|
|
540
|
-
// The historical "No"-prefixed spellings ("IEEE No148, April 1959")
|
|
541
|
-
// are plain standards - No normalizes to Std so the render prints
|
|
542
|
-
// "IEEE Std 148" and the stage lookup resolves. AIEE keeps its No.
|
|
543
|
-
if (typeValue !== undefined && /^No\.?$/.test(typeValue) &&
|
|
544
|
-
/^IEEE\s/.test(this.originalInput)) {
|
|
545
|
-
typeValue = "Std";
|
|
546
|
-
}
|
|
547
|
-
// The canonical type word is the short form (C2 ruling):
|
|
548
|
-
// "IEEE Standard 495-2007" and "IEEE Std 495-2007" are the same
|
|
549
|
-
// identifier. A DRAFT type word never reaches the wire (the
|
|
550
|
-
// draft-ness rides draft_status + the draft component; "Draft Std"
|
|
551
|
-
// is banned from canonical output) - it still feeds
|
|
552
|
-
// determineStageAbbr below (the version-less D1 fabrication).
|
|
553
|
-
if (typeValue === "Standard")
|
|
554
|
-
typeValue = "Std";
|
|
555
|
-
if (typeValue !== undefined && !/^Draft/.test(typeValue))
|
|
556
|
-
attributes["type"] = typeValue;
|
|
557
|
-
const typedStageAbbr = this.determineStageAbbr(typeValue, parsed);
|
|
558
|
-
if (typedStageAbbr !== undefined) {
|
|
559
|
-
const record = locateStage(typedStageAbbr);
|
|
560
|
-
if (record !== undefined)
|
|
561
|
-
attributes["typed_stage"] = new IeeeTypedStage(record);
|
|
562
|
-
}
|
|
563
|
-
attributes["draft_status"] = draftStatusValue;
|
|
564
|
-
for (const key of ["edition", "revision", "rev_sep"]) {
|
|
565
|
-
const value = extractValue(parsed[key]);
|
|
566
|
-
if (value !== undefined)
|
|
567
|
-
attributes[key] = value;
|
|
568
|
-
}
|
|
569
|
-
if (parsed["rev_bare"] !== undefined)
|
|
570
|
-
attributes["rev_bare"] = true;
|
|
571
|
-
if (attributes["edition_month"] === undefined) {
|
|
572
|
-
const month = extractValue(parsed["month"]);
|
|
573
|
-
if (month !== undefined)
|
|
574
|
-
attributes["month"] = month;
|
|
575
|
-
}
|
|
576
|
-
const day = extractValue(parsed["day"]);
|
|
577
|
-
if (day !== undefined)
|
|
578
|
-
attributes["day"] = day;
|
|
579
|
-
this.handleDraft(parsed, attributes);
|
|
580
|
-
this.foldDraftDateTail(attributes);
|
|
581
|
-
// The bare-IEEE fdraft clause (pubid#203): a slash-led stage word
|
|
582
|
-
// after the code ("IEEE P15026.2/FDIS, August 2010") rides the D=
|
|
583
|
-
// designator with the IEEE date convention ("D=FDIS-201008"); the
|
|
584
|
-
// ISO face is not elected (the reference's fdraft rule).
|
|
585
|
-
const fdraft = parsed["fdraft"];
|
|
586
|
-
if (fdraft !== undefined && typeof fdraft === "object" && !Array.isArray(fdraft)) {
|
|
587
|
-
const fdStage = extractValue(fdraft["fdraft_stage"]);
|
|
588
|
-
if (fdStage !== undefined) {
|
|
589
|
-
// fdraft's month/year rename with the fdraft_ prefix on the
|
|
590
|
-
// edition-2 grammar (nested-only); the v1 spellings stay as the
|
|
591
|
-
// fallback.
|
|
592
|
-
const fdYear = extractValue((fdraft["fdraft_year"] ?? fdraft["year"]));
|
|
593
|
-
const fdMonth = extractValue((fdraft["fdraft_month"] ?? fdraft["month"]));
|
|
594
|
-
let date = "";
|
|
595
|
-
if (fdYear !== undefined) {
|
|
596
|
-
date = `-${fdYear}`;
|
|
597
|
-
const monthNum = fdMonth !== undefined
|
|
598
|
-
? DRAFT_MONTH_NAMES[String(fdMonth).replace(/\.$/, "")]
|
|
599
|
-
: undefined;
|
|
600
|
-
if (monthNum !== undefined)
|
|
601
|
-
date += monthNum.padStart(2, "0");
|
|
602
|
-
}
|
|
603
|
-
attributes["publishers"] ??= [attributes["publisher"] ?? "IEEE"];
|
|
604
|
-
attributes["ieee_draft"] = `D=${fdStage}${date}`;
|
|
605
|
-
const fdRecord = locateStage(fdStage);
|
|
606
|
-
if (fdRecord !== undefined)
|
|
607
|
-
attributes["typed_stage"] = new IeeeTypedStage(fdRecord);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
this.applyDefaultDraftVersion(attributes, typeValue);
|
|
611
|
-
this.handleKeyedHash(parsed, "corrigendum", attributes, "cor_number", "cor_year");
|
|
612
|
-
this.handleKeyedHash(parsed, "amendment", attributes, "amd_number", "amd_year");
|
|
613
|
-
this.handleKeyedHash(parsed, "conformance", attributes, "conf_number", "conf_year");
|
|
614
|
-
this.handleAshraeCopub(parsed, attributes);
|
|
615
|
-
this.handleIeeeCrossref(parsed, attributes);
|
|
616
|
-
this.handleReaffirmed(parsed, attributes);
|
|
617
|
-
this.handleParameters(parsed, attributes);
|
|
618
|
-
if (parsed["nickname"] !== undefined) {
|
|
619
|
-
attributes["nickname"] = extractValue(parsed["nickname"]);
|
|
620
|
-
}
|
|
621
|
-
if (parsed["interpretation"] !== undefined)
|
|
622
|
-
attributes["interpretation"] = true;
|
|
623
|
-
if (parsed["redline"] !== undefined)
|
|
624
|
-
attributes["redline"] = true;
|
|
625
|
-
// Glued identity year-month provenance (gem#520): the input tail is
|
|
626
|
-
// the glued "-YYYY-MM" on a draft-free, revision-free identity.
|
|
627
|
-
if (attributes["month"] !== undefined && attributes["year"] !== undefined &&
|
|
628
|
-
attributes["draft"] === undefined && attributes["revision"] === undefined &&
|
|
629
|
-
/-\d{4}-\d{2}$/.test(this.originalInput ?? "")) {
|
|
630
|
-
attributes["month_glued"] = true;
|
|
631
|
-
}
|
|
632
|
-
return attributes;
|
|
633
|
-
}
|
|
634
|
-
determineStageAbbr(typeValue, parsed) {
|
|
635
|
-
// An explicit joint stage on the draft ("=DFDIS.3") IS the stage —
|
|
636
|
-
// it outranks the ordinal ladder, which classifies IEEE-internal
|
|
637
|
-
// drafts only (docs/IEEE-DRAFT-STAGES.md §1.3).
|
|
638
|
-
let draftVersionPresent = false;
|
|
639
|
-
if (parsed["draft"] !== undefined) {
|
|
640
|
-
let draftData = parsed["draft"];
|
|
641
|
-
if (Array.isArray(draftData)) {
|
|
642
|
-
draftData = mergeParsedArray(draftData);
|
|
643
|
-
}
|
|
644
|
-
// A verbatim draft designator string is a version in itself.
|
|
645
|
-
if (!isObj(draftData))
|
|
646
|
-
draftVersionPresent = true;
|
|
647
|
-
if (isObj(draftData) && draftData["draft_iso_stage"] !== undefined) {
|
|
648
|
-
const stage = extractValue(draftData["draft_iso_stage"]) ?? "";
|
|
649
|
-
// The doubled-D alias ("DFDIS") carries its own draft marker;
|
|
650
|
-
// the stage is what remains.
|
|
651
|
-
const rest = stage.slice(1);
|
|
652
|
-
return stage.startsWith("D") && ["PWI", "NP", "WD", "CD", "CDV", "DIS", "FDIS"].includes(rest)
|
|
653
|
-
? rest
|
|
654
|
-
: stage;
|
|
655
|
-
}
|
|
656
|
-
if (isObj(draftData) && draftData["draft_version"] !== undefined) {
|
|
657
|
-
draftVersionPresent = true;
|
|
658
|
-
const dv = draftData["draft_version"];
|
|
659
|
-
const version = Array.isArray(dv) ? dv.map((v) => extractValue(v) ?? "").join("") : extractValue(dv);
|
|
660
|
-
if (version !== undefined) {
|
|
661
|
-
// A draft version that IS an ISO stage token ("/DCD1" and
|
|
662
|
-
// "/CD1" both capture "CD1") takes that stage on a plain IEEE
|
|
663
|
-
// document (docs/IEEE-DRAFT-STAGES.md §1.3, "DDIS" = DIS); a
|
|
664
|
-
// joint ISO-led stage-word draft keeps its generic project
|
|
665
|
-
// stage.
|
|
666
|
-
const pubs = parsed["publishers"];
|
|
667
|
-
const copubs = isObj(pubs) ? pubs["copublishers"] : undefined;
|
|
668
|
-
const joint = copubs !== undefined && (Array.isArray(copubs) ? copubs.length > 0 : true);
|
|
669
|
-
const stageMatch = /^(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)\d*$/.exec(version);
|
|
670
|
-
if (!joint && stageMatch !== null)
|
|
671
|
-
return stageMatch[1];
|
|
672
|
-
// relaton's hyphenated "/D-2" spelling captures the dash inside
|
|
673
|
-
// draft_version; the stage registry keys on "D2". A date-embedded
|
|
674
|
-
// version ("3-2017-07") keys on its leading ordinal.
|
|
675
|
-
const draftAbbr = `D${version.replace(/^-/, "").replace(/-\d{4}(-\d{2})?$/, "")}`;
|
|
676
|
-
const stage = locateStage(draftAbbr);
|
|
677
|
-
if (stage !== undefined && stage.abbr.includes(draftAbbr))
|
|
678
|
-
return draftAbbr;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
if (typeValue !== undefined) {
|
|
683
|
-
if (typeValue.startsWith("P"))
|
|
684
|
-
return "P";
|
|
685
|
-
if (typeValue === "Std")
|
|
686
|
-
return "Std";
|
|
687
|
-
if (typeValue === "Draft Std" && !draftVersionPresent && parsed["digit_draft"] === undefined) {
|
|
688
|
-
return "D1";
|
|
689
|
-
}
|
|
690
|
-
if (/^No\.?$/.test(typeValue))
|
|
691
|
-
return typeValue;
|
|
692
|
-
}
|
|
693
|
-
return "Std";
|
|
694
|
-
}
|
|
695
|
-
handleDraft(parsed, attributes) {
|
|
696
|
-
let draftData = parsed["draft"] ?? parsed["digit_draft"];
|
|
697
|
-
if (draftData === undefined)
|
|
698
|
-
return;
|
|
699
|
-
if (Array.isArray(draftData)) {
|
|
700
|
-
const hashes = draftData.filter((e) => isObj(e));
|
|
701
|
-
const versions = hashes
|
|
702
|
-
.map((e) => e["draft_version"])
|
|
703
|
-
.filter((v) => v !== undefined);
|
|
704
|
-
const merged = Object.assign({}, ...hashes);
|
|
705
|
-
if (versions.length > 0)
|
|
706
|
-
merged["draft_version"] = versions;
|
|
707
|
-
draftData = merged;
|
|
708
|
-
}
|
|
709
|
-
let version;
|
|
710
|
-
let revision;
|
|
711
|
-
let isoStage;
|
|
712
|
-
let isoIteration;
|
|
713
|
-
let month;
|
|
714
|
-
let year;
|
|
715
|
-
let day;
|
|
716
|
-
let commaBeforeMonth = false;
|
|
717
|
-
if (isObj(draftData)) {
|
|
718
|
-
if (draftData["draft_version"] !== undefined) {
|
|
719
|
-
const dv = draftData["draft_version"];
|
|
720
|
-
version = Array.isArray(dv) ? dv.map((v) => extractValue(v) ?? "").join("") : extractValue(dv);
|
|
721
|
-
// The reference's designator normalization (gem#552): a leading
|
|
722
|
-
// hyphen drops, and a three-digit-plus zero-padded designator
|
|
723
|
-
// sheds its zero ("/013.0" -> "13.0" — the 2026-10-19 ruling;
|
|
724
|
-
// the strip is scoped to the dotted designator class — "D043"/
|
|
725
|
-
// "D09"/"D0.16" keep their conventional widths).
|
|
726
|
-
if (version !== undefined)
|
|
727
|
-
version = version.replace(/^-/, "").replace(/^0(?=\d+\.\d)/, "");
|
|
728
|
-
}
|
|
729
|
-
// The dotted ordinal stays part of the designator (the #601
|
|
730
|
-
// convergence): a split field would make the parse and from_hash
|
|
731
|
-
// paths build different Draft objects on wire-identical rows.
|
|
732
|
-
// #to_s renders version + revision identically, so the whole tail
|
|
733
|
-
// rides the version on every route.
|
|
734
|
-
if (draftData["revision"] !== undefined && version !== undefined) {
|
|
735
|
-
const tail = extractValue(draftData["revision"])?.replace(/^\./, "");
|
|
736
|
-
if (tail !== undefined && tail !== "")
|
|
737
|
-
version = `${version}.${tail}`;
|
|
738
|
-
}
|
|
739
|
-
isoStage = extractValue(draftData["draft_iso_stage"]);
|
|
740
|
-
isoIteration = extractValue(draftData["draft_iso_iteration"]);
|
|
741
|
-
// FDIS/CDV/… are ISO/IEC stage tokens, not draft ordinals (C1
|
|
742
|
-
// ruling, testsuite#2). "/DDIS" and "/DFCD" are hallucinated
|
|
743
|
-
// concatenations — the designator D does not merge onto a stage
|
|
744
|
-
// word. The draft of a stage rides the iso_stage slot, which
|
|
745
|
-
// Draft#to_s renders as the D= designator face ("…/D=DIS-2020").
|
|
746
|
-
// The glued month-name date ("-June2010", the 2026-10-19 FCD
|
|
747
|
-
// ruling) rides the designator's date slot with the month numeric.
|
|
748
|
-
// The edition-2 grammar renames draft_date's nested month/year/day
|
|
749
|
-
// captures with the draft_date_ prefix (kept off the identity
|
|
750
|
-
// keys); the v1 spellings stay as the fallback.
|
|
751
|
-
const monthSlice = draftData["draft_date_month"] ?? draftData["month"];
|
|
752
|
-
month = extractValue(monthSlice);
|
|
753
|
-
const yearSlice = draftData["draft_date_year"] ?? draftData["year"];
|
|
754
|
-
year = yearSlice !== undefined ? extractValue(yearSlice) : undefined;
|
|
755
|
-
const daySlice = draftData["draft_date_day"] ?? draftData["day"];
|
|
756
|
-
day = daySlice !== undefined ? extractValue(daySlice) : undefined;
|
|
757
|
-
if (version !== undefined) {
|
|
758
|
-
// The stage iteration rides glued onto the word ("DIS2" — the
|
|
759
|
-
// lossless face, pubid#477; the 2026-10-19 DIS2 ruling).
|
|
760
|
-
const stageDate = /^(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)(\d+)?(?:-([A-Za-z]+)(\d{4}))?$/.exec(version);
|
|
761
|
-
if (stageDate !== null) {
|
|
762
|
-
isoStage = stageDate[1] + (stageDate[2] ?? "");
|
|
763
|
-
if (stageDate[3] !== undefined) {
|
|
764
|
-
month = DRAFT_MONTH_NAMES[stageDate[3]] !== undefined ? stageDate[3] : month;
|
|
765
|
-
year = stageDate[4];
|
|
766
|
-
}
|
|
767
|
-
version = undefined;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
// The apostrophe-year catalogue convention ("P1484.20.1/D7,
|
|
771
|
-
// May 07"): the 2-digit year expands with the <30 pivot so the
|
|
772
|
-
// hash carries an unambiguous year (the reference's builder).
|
|
773
|
-
if (year !== undefined && /^\d{2}$/.test(year)) {
|
|
774
|
-
year = `${Number(year) < 30 ? 20 : 19}${year}`;
|
|
775
|
-
}
|
|
776
|
-
if (this.originalInput !== "" && month !== undefined) {
|
|
777
|
-
commaBeforeMonth = new RegExp(`,\\s+${month.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i")
|
|
778
|
-
.test(this.originalInput);
|
|
779
|
-
}
|
|
780
|
-
if (version !== undefined && this.originalInput !== "" &&
|
|
781
|
-
new RegExp(`\\s+/D${version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i").test(this.originalInput)) {
|
|
782
|
-
attributes["space_before_draft"] = true;
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
// A degraded wire leaf carries the whole draft clause verbatim
|
|
787
|
-
// ("/D2.1.1" — the three-segment designator the engine cannot
|
|
788
|
-
// structure): IeeeDraft.parse is the inverse of render, so it
|
|
789
|
-
// strips the prefix instead of double-appending it.
|
|
790
|
-
const reparsed = IeeeDraft.parse(extractValue(draftData) ?? "");
|
|
791
|
-
if (reparsed !== undefined) {
|
|
792
|
-
attributes["draft"] = reparsed.render();
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
// A REV-carrying draft embeds its print date into the designator
|
|
797
|
-
// with the month canonicalized numeric (pubid ruling 2026-10-14):
|
|
798
|
-
// "P802.11-REVmc/D8.0, Aug 2016" renders ".../D8.0-2016-08".
|
|
799
|
-
// Drafts without a REV keep the comma face.
|
|
800
|
-
if ((attributes["revision"] !== undefined || attributes["rev_bare"] === true ||
|
|
801
|
-
attributes["cor_number"] !== undefined || attributes["cor_year"] !== undefined) &&
|
|
802
|
-
month !== undefined && year !== undefined && version !== undefined) {
|
|
803
|
-
const monthNumber = DRAFT_MONTH_NAMES[String(month).replace(/\.$/, "")];
|
|
804
|
-
if (monthNumber !== undefined) {
|
|
805
|
-
// The canonical face zero-pads ("D8.0-2016-08"), matching the
|
|
806
|
-
// reference's REV_MONTH_NUMBERS.
|
|
807
|
-
version = `${version}-${year}-${monthNumber.padStart(2, "0")}`;
|
|
808
|
-
month = year = day = undefined;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
if (version !== undefined || isoStage !== undefined ||
|
|
812
|
-
(isObj(draftData) && draftData["draft_iso_stage"] !== undefined)) {
|
|
813
|
-
const draftObj = new IeeeDraft({
|
|
814
|
-
version,
|
|
815
|
-
revision,
|
|
816
|
-
iso_stage: isoStage,
|
|
817
|
-
iso_iteration: isoIteration,
|
|
818
|
-
month,
|
|
819
|
-
year,
|
|
820
|
-
day,
|
|
821
|
-
comma_before_month: commaBeforeMonth,
|
|
822
|
-
});
|
|
823
|
-
attributes["draft"] = draftObj.render();
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
// A draft-date that routed to the identity slots (the grammar's
|
|
827
|
-
// month/year captures beside a bare draft ordinal) folds onto the
|
|
828
|
-
// draft designator: a REV-carrier embeds it numerically
|
|
829
|
-
// ("P1310Rev3/D2, February 2011" renders "D2-2011-02" — the
|
|
830
|
-
// reference's builder), a plain draft keeps the printed face routed
|
|
831
|
-
// through the draft's own parse so the month canonicalizes to the
|
|
832
|
-
// crawl abbreviation ("D08, September 2018" renders "D08, Sept,
|
|
833
|
-
// 2018"; a space-faced input stays space-faced).
|
|
834
|
-
foldDraftDateTail(attributes) {
|
|
835
|
-
const month = attributes["month"];
|
|
836
|
-
const year = attributes["year"];
|
|
837
|
-
const draft = attributes["draft"];
|
|
838
|
-
if (typeof month !== "string" || typeof year !== "string" ||
|
|
839
|
-
typeof draft !== "string" || !/^\/D[^ =,]+$/.test(draft)) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
const draftNum = draft.slice(2);
|
|
843
|
-
if (attributes["revision"] !== undefined || attributes["rev_bare"] === true) {
|
|
844
|
-
const monthNum = DRAFT_MONTH_NAMES[String(month).replace(/\.$/, "")];
|
|
845
|
-
if (monthNum === undefined)
|
|
846
|
-
return;
|
|
847
|
-
attributes["draft"] =
|
|
848
|
-
new IeeeDraft({ version: `${draftNum}-${year}-${monthNum.padStart(2, "0")}` }).render();
|
|
849
|
-
}
|
|
850
|
-
else {
|
|
851
|
-
const escaped = month.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
852
|
-
const commaFace = this.originalInput !== "" &&
|
|
853
|
-
new RegExp(`,\\s+${escaped}`, "i").test(this.originalInput);
|
|
854
|
-
const reparsed = IeeeDraft.parse(`${draftNum}${commaFace ? ", " : " "}${month} ${year}`);
|
|
855
|
-
if (reparsed === undefined)
|
|
856
|
-
return;
|
|
857
|
-
attributes["draft"] = reparsed.render();
|
|
858
|
-
}
|
|
859
|
-
delete attributes["month"];
|
|
860
|
-
delete attributes["year"];
|
|
861
|
-
}
|
|
862
|
-
applyDefaultDraftVersion(attributes, typeValue) {
|
|
863
|
-
if (attributes["draft"] !== undefined)
|
|
864
|
-
return;
|
|
865
|
-
if (typeValue !== "Draft Std")
|
|
866
|
-
return;
|
|
867
|
-
// The reference stores the fabricated designator comma-joined with the
|
|
868
|
-
// identity year ("D1, 2012" — the gem's Draft#to_s), not space-joined.
|
|
869
|
-
attributes["draft"] = attributes["year"] === undefined
|
|
870
|
-
? "D1"
|
|
871
|
-
: `D1, ${attributes["year"]}`;
|
|
872
|
-
}
|
|
873
|
-
handleKeyedHash(parsed, key, attributes, numberKey, yearKey) {
|
|
874
|
-
if (isObj(parsed[key])) {
|
|
875
|
-
const data = parsed[key];
|
|
876
|
-
attributes[numberKey] = extractValue(data[numberKey]);
|
|
877
|
-
if (data[yearKey] !== undefined)
|
|
878
|
-
attributes[yearKey] = extractValue(data[yearKey]);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
handleAshraeCopub(parsed, attributes) {
|
|
882
|
-
if (isObj(parsed["ashrae_copub"])) {
|
|
883
|
-
const data = parsed["ashrae_copub"];
|
|
884
|
-
attributes["ashrae_number"] = extractValue(data["ashrae_number"]);
|
|
885
|
-
if (data["ashrae_year"] !== undefined) {
|
|
886
|
-
attributes["ashrae_year"] = extractValue(data["ashrae_year"]);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
handleIeeeCrossref(parsed, attributes) {
|
|
891
|
-
if (parsed["ieee_crossref"] !== undefined) {
|
|
892
|
-
const raw = extractValue(parsed["ieee_crossref"]) ?? "";
|
|
893
|
-
attributes["crossref"] = `/C${raw.replace(/^\//, "")}`;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
handleReaffirmed(parsed, attributes) {
|
|
897
|
-
if (isObj(parsed["reaffirmed"])) {
|
|
898
|
-
// The edition-2 grammar renames the nested year capture
|
|
899
|
-
// (reaffirmed_year) so the reaffirmation year cannot leak onto the
|
|
900
|
-
// identity year key; the v1 spelling stays as the fallback.
|
|
901
|
-
const reaf = parsed["reaffirmed"];
|
|
902
|
-
const value = reaf["reaffirmed_year"] ?? reaf["year"];
|
|
903
|
-
if (value !== undefined)
|
|
904
|
-
attributes["reaffirmed"] = extractValue(value);
|
|
905
|
-
}
|
|
906
|
-
else if (parsed["reaffirmed"] !== undefined) {
|
|
907
|
-
attributes["reaffirmed"] = extractValue(parsed["reaffirmed"]);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
handleParameters(parsed, attributes) {
|
|
911
|
-
if (!isObj(parsed["parameters"]))
|
|
912
|
-
return;
|
|
913
|
-
const paramData = parsed["parameters"];
|
|
914
|
-
for (const key of ["parenthetical_content", "revision_of", "amendment_to", "adoption", "note"]) {
|
|
915
|
-
const value = extractValue(paramData[key]);
|
|
916
|
-
if (value !== undefined)
|
|
917
|
-
attributes[key] = value;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
parseIdentifierList(listData) {
|
|
921
|
-
if (listData === undefined || listData === null)
|
|
922
|
-
return [];
|
|
923
|
-
const entries = Array.isArray(listData) ? listData : [listData];
|
|
924
|
-
const idStrings = [];
|
|
925
|
-
for (const entry of entries) {
|
|
926
|
-
if (isObj(entry) && entry["id"] !== undefined) {
|
|
927
|
-
idStrings.push(String(entry["id"]).trim());
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
return idStrings.map((idStr) => {
|
|
931
|
-
try {
|
|
932
|
-
return ieeeParse(idStr);
|
|
933
|
-
}
|
|
934
|
-
catch {
|
|
935
|
-
return new StandardClass({ parenthetical_content: idStr });
|
|
936
|
-
}
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
relationshipFrom(relData) {
|
|
940
|
-
if (!isObj(relData["relationship_type"]))
|
|
941
|
-
return undefined;
|
|
942
|
-
const firstKey = Object.keys(relData["relationship_type"])[0];
|
|
943
|
-
if (firstKey === undefined)
|
|
944
|
-
return undefined;
|
|
945
|
-
let amendments = [];
|
|
946
|
-
if (relData["amendments"] !== undefined && !isObj(relData["amendments"])) {
|
|
947
|
-
amendments = this.parseIdentifierList(relData["amendments"]);
|
|
948
|
-
}
|
|
949
|
-
return new IeeeRelationship(firstKey, this.parseIdentifierList(relData["related_ids"]), amendments, isObj(relData["amendments"]) && relData["amendments"]["approved_amendments"] !== undefined);
|
|
950
|
-
}
|
|
951
|
-
buildRelationships(parsedHash) {
|
|
952
|
-
const relationships = [];
|
|
953
|
-
if (parsedHash["relationship_type"] !== undefined || parsedHash["relationship_clause"] !== undefined) {
|
|
954
|
-
const rel = this.relationshipFrom(parsedHash);
|
|
955
|
-
if (rel !== undefined)
|
|
956
|
-
relationships.push(rel);
|
|
957
|
-
}
|
|
958
|
-
if (parsedHash["additional_rels"] !== undefined) {
|
|
959
|
-
const additional = Array.isArray(parsedHash["additional_rels"])
|
|
960
|
-
? parsedHash["additional_rels"]
|
|
961
|
-
: [parsedHash["additional_rels"]];
|
|
962
|
-
for (const relData of additional) {
|
|
963
|
-
if (isObj(relData)) {
|
|
964
|
-
const rel = this.relationshipFrom(relData);
|
|
965
|
-
if (rel !== undefined)
|
|
966
|
-
relationships.push(rel);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
return relationships;
|
|
971
|
-
}
|
|
972
|
-
// --- supplements and wrappers ----------------------------------------------
|
|
973
|
-
reconstructBaseString(baseData) {
|
|
974
|
-
// The part/subpart/year captures sit one level down, inside the raw
|
|
975
|
-
// part_subpart_year wrapper — hoist them before the flat reads.
|
|
976
|
-
this.unwrapPartSubpartYear(baseData);
|
|
977
|
-
const baseParts = [];
|
|
978
|
-
if (baseData["publishers"] !== undefined) {
|
|
979
|
-
const pubData = asHash(baseData["publishers"]);
|
|
980
|
-
let publisherStr = extractValue(pubData["publisher"]) ?? "";
|
|
981
|
-
if (pubData["copublishers"] !== undefined && pubData["copublishers"] !== "") {
|
|
982
|
-
const copubs = Array.isArray(pubData["copublishers"])
|
|
983
|
-
? pubData["copublishers"]
|
|
984
|
-
: [pubData["copublishers"]];
|
|
985
|
-
const copubStrs = copubs
|
|
986
|
-
.map((cp) => extractValue(asHash(cp)["copublisher"]))
|
|
987
|
-
.filter((cp) => cp !== undefined);
|
|
988
|
-
if (copubStrs.length > 0)
|
|
989
|
-
publisherStr += `/${copubStrs.join("/")}`;
|
|
990
|
-
}
|
|
991
|
-
baseParts.push(publisherStr);
|
|
992
|
-
}
|
|
993
|
-
if (baseData["type"] !== undefined) {
|
|
994
|
-
baseParts.push(extractValue(baseData["type"]) ?? "");
|
|
995
|
-
}
|
|
996
|
-
let numberStr = extractValue(baseData["number"]) ?? "";
|
|
997
|
-
const baseSep = extractValue(baseData["part_sep"]) ?? ".";
|
|
998
|
-
if (baseData["part"] !== undefined) {
|
|
999
|
-
const pv = extractValue(baseData["part"]) ?? "";
|
|
1000
|
-
numberStr += /^[._-]/.test(pv) ? pv : `${baseSep}${pv}`;
|
|
1001
|
-
}
|
|
1002
|
-
if (baseData["subpart"] !== undefined) {
|
|
1003
|
-
const subparts = Array.isArray(baseData["subpart"]) ? baseData["subpart"] : [baseData["subpart"]];
|
|
1004
|
-
for (const sp of subparts) {
|
|
1005
|
-
const v = extractValue(sp);
|
|
1006
|
-
if (v !== undefined)
|
|
1007
|
-
numberStr += /^[._-]/.test(v) ? v : `${baseSep}${v}`;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
if (baseData["year"] !== undefined) {
|
|
1011
|
-
numberStr += `-${extractValue(baseData["year"]) ?? ""}`;
|
|
1012
|
-
}
|
|
1013
|
-
baseParts.push(numberStr);
|
|
1014
|
-
return baseParts.join(" ");
|
|
1015
|
-
}
|
|
1016
|
-
buildCorrigendumSupplement(parsedHash) {
|
|
1017
|
-
const base = ieeeParseSingle(this.reconstructBaseString(asHash(parsedHash["base"])));
|
|
1018
|
-
const corNumber = extractValue(parsedHash["cor_number"]);
|
|
1019
|
-
const corYear = extractValue(parsedHash["cor_year"]);
|
|
1020
|
-
return new CorrigendumClass({
|
|
1021
|
-
base, number: corNumber, year: corYear,
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
buildFlatCorrigendum(parsedHash) {
|
|
1025
|
-
const corData = parsedHash["corrigendum"];
|
|
1026
|
-
const corNumber = extractValue(corData["cor_number"]);
|
|
1027
|
-
const corYear = corData["cor_year"] !== undefined ? extractValue(corData["cor_year"]) : undefined;
|
|
1028
|
-
const baseHash = { ...parsedHash };
|
|
1029
|
-
delete baseHash["corrigendum"];
|
|
1030
|
-
const base = this.buildSingleIdentifier(baseHash, false);
|
|
1031
|
-
return new CorrigendumClass({
|
|
1032
|
-
base, number: corNumber, year: corYear,
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
buildFlatAmendment(parsedHash) {
|
|
1036
|
-
const amdData = parsedHash["amendment"];
|
|
1037
|
-
const amdNumber = extractValue(amdData["amd_number"]);
|
|
1038
|
-
const amdYear = amdData["amd_year"] !== undefined ? extractValue(amdData["amd_year"]) : undefined;
|
|
1039
|
-
const baseHash = { ...parsedHash };
|
|
1040
|
-
delete baseHash["amendment"];
|
|
1041
|
-
const base = this.buildSingleIdentifier(baseHash, false);
|
|
1042
|
-
return new AmendmentClass({
|
|
1043
|
-
base, number: amdNumber, year: amdYear,
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
buildFlatInterpretation(parsedHash) {
|
|
1047
|
-
const intYear = parsedHash["trailing_year"] !== undefined
|
|
1048
|
-
? extractValue(parsedHash["trailing_year"])
|
|
1049
|
-
: undefined;
|
|
1050
|
-
const baseHash = { ...parsedHash };
|
|
1051
|
-
delete baseHash["interpretation"];
|
|
1052
|
-
delete baseHash["trailing_month"];
|
|
1053
|
-
delete baseHash["trailing_year"];
|
|
1054
|
-
const base = this.buildSingleIdentifier(baseHash, false);
|
|
1055
|
-
return new InterpretationClass({
|
|
1056
|
-
base, year: intYear,
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
buildInterpretationSupplement(parsedHash) {
|
|
1060
|
-
const base = ieeeParseSingle(this.reconstructBaseString(asHash(parsedHash["base"])));
|
|
1061
|
-
const intYear = extractValue(parsedHash["int_year"]);
|
|
1062
|
-
return new InterpretationClass({
|
|
1063
|
-
base, year: intYear,
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
buildAmendmentSupplement(parsedHash) {
|
|
1067
|
-
const base = ieeeParseSingle(this.reconstructBaseString(asHash(parsedHash["base"])));
|
|
1068
|
-
return new AmendmentClass({
|
|
1069
|
-
base,
|
|
1070
|
-
number: extractValue(parsedHash["amd_number"]),
|
|
1071
|
-
year: extractValue(parsedHash["amd_year"]),
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
buildConformanceSupplement(parsedHash) {
|
|
1075
|
-
const base = ieeeParseSingle(this.reconstructBaseString(asHash(parsedHash["base"])));
|
|
1076
|
-
return new ConformanceClass({
|
|
1077
|
-
base,
|
|
1078
|
-
number: extractValue(parsedHash["conf_number"]),
|
|
1079
|
-
year: extractValue(parsedHash["conf_year"]),
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
buildJointDevelopment(parsed) {
|
|
1083
|
-
const attributes = {};
|
|
1084
|
-
if (parsed["joint_publishers"] !== undefined) {
|
|
1085
|
-
const jointPubStr = extractValue(parsed["joint_publishers"]) ?? "";
|
|
1086
|
-
const pubs = jointPubStr.split("/");
|
|
1087
|
-
attributes["publishers"] = pubs;
|
|
1088
|
-
attributes["publisher"] = pubs[0];
|
|
1089
|
-
attributes["copublisher"] = pubs.slice(1);
|
|
1090
|
-
}
|
|
1091
|
-
else if (parsed["publishers"] !== undefined) {
|
|
1092
|
-
// Stage-bearing rows the artifact routes without a
|
|
1093
|
-
// joint_publishers capture ("ISO/IEC/IEEE P26511/D8=DDIS.3"):
|
|
1094
|
-
// the publishers hash carries the same information.
|
|
1095
|
-
const pubData = asHash(parsed["publishers"]);
|
|
1096
|
-
const lead = extractValue(pubData["publisher"]) ?? "";
|
|
1097
|
-
const copubs = pubData["copublishers"] !== undefined
|
|
1098
|
-
? (Array.isArray(pubData["copublishers"])
|
|
1099
|
-
? pubData["copublishers"]
|
|
1100
|
-
: [pubData["copublishers"]])
|
|
1101
|
-
.map((cp) => extractValue(asHash(cp)["copublisher"]))
|
|
1102
|
-
.filter((cp) => cp !== undefined)
|
|
1103
|
-
: [];
|
|
1104
|
-
attributes["publishers"] = [lead, ...copubs];
|
|
1105
|
-
attributes["publisher"] = lead;
|
|
1106
|
-
attributes["copublisher"] = copubs;
|
|
1107
|
-
}
|
|
1108
|
-
const codeParts = [];
|
|
1109
|
-
if (parsed["part"] !== undefined)
|
|
1110
|
-
codeParts.push(extractValue(parsed["part"]) ?? "");
|
|
1111
|
-
// The part/subpart captures carry their printed separator
|
|
1112
|
-
// (separator-in-capture); the subpart rides after the part
|
|
1113
|
-
// ("P65700.19.03", "60079-30-2" — the reference's joint code
|
|
1114
|
-
// assembly).
|
|
1115
|
-
if (parsed["subpart"] !== undefined) {
|
|
1116
|
-
const subs = Array.isArray(parsed["subpart"]) ? parsed["subpart"] : [parsed["subpart"]];
|
|
1117
|
-
for (const sp of subs)
|
|
1118
|
-
codeParts.push(extractValue(sp) ?? "");
|
|
1119
|
-
}
|
|
1120
|
-
let codeStr = extractValue(parsed["number"]);
|
|
1121
|
-
if (codeStr !== undefined && codeParts.length > 0) {
|
|
1122
|
-
// The ISO/IEC label's part may be dash-joined ("8802-9") - keep the
|
|
1123
|
-
// printed separator. Separator-carrying captures (the artifact's
|
|
1124
|
-
// part binds ".2") join verbatim.
|
|
1125
|
-
const sep = parsed["iec_label_dash"] !== undefined ? "-" : ".";
|
|
1126
|
-
codeStr += codeParts.map((cp) => /^[._-]/.test(cp) ? cp : `${sep}${cp}`).join("");
|
|
1127
|
-
}
|
|
1128
|
-
// P = project (a draft): identity-bearing, preserved as spelled.
|
|
1129
|
-
if (parsed["project_marker"] !== undefined && codeStr !== undefined) {
|
|
1130
|
-
codeStr = `P${codeStr}`;
|
|
1131
|
-
}
|
|
1132
|
-
if (codeStr !== undefined) {
|
|
1133
|
-
const codeObj = IeeeCode.parse(codeStr);
|
|
1134
|
-
if (codeObj !== undefined) {
|
|
1135
|
-
attributes["__code_obj"] = codeObj;
|
|
1136
|
-
attributes["number"] = codeObj.number;
|
|
1137
|
-
if (codeObj.prefix !== undefined)
|
|
1138
|
-
attributes["prefix"] = codeObj.prefix;
|
|
1139
|
-
if (codeObj.parts.length > 0)
|
|
1140
|
-
attributes["parts"] = codeObj.parts;
|
|
1141
|
-
if (codeObj.originalSeparator !== undefined)
|
|
1142
|
-
attributes["separator"] = codeObj.originalSeparator;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
if (parsed["year"] !== undefined) {
|
|
1146
|
-
attributes["year"] = extractValue(parsed["year"]);
|
|
1147
|
-
}
|
|
1148
|
-
else if (parsed["edition_year"] !== undefined) {
|
|
1149
|
-
attributes["year"] = extractValue(parsed["edition_year"]);
|
|
1150
|
-
}
|
|
1151
|
-
if (parsed["month"] !== undefined)
|
|
1152
|
-
attributes["month"] = extractValue(parsed["month"]);
|
|
1153
|
-
if (parsed["draft_year"] !== undefined) {
|
|
1154
|
-
if (attributes["year"] === undefined)
|
|
1155
|
-
attributes["year"] = extractValue(parsed["draft_year"]);
|
|
1156
|
-
if (attributes["month"] === undefined)
|
|
1157
|
-
attributes["month"] = extractValue(parsed["draft_month"]);
|
|
1158
|
-
}
|
|
1159
|
-
// A status word ("Unapproved") marks the draft (pubid#318).
|
|
1160
|
-
const jointDraftStatus = extractValue(parsed["draft_status"]);
|
|
1161
|
-
if (jointDraftStatus !== undefined)
|
|
1162
|
-
attributes["draft_status"] = jointDraftStatus;
|
|
1163
|
-
// A dash_year tail ("/D-3-2007") is the identity year when the
|
|
1164
|
-
// slots are otherwise empty — the ISO face prints it colon-joined
|
|
1165
|
-
// ("ISO/IEC/IEEE FDIS P15288:2007", the reference's 9258 flow).
|
|
1166
|
-
if (attributes["year"] === undefined && parsed["dash_year"] !== undefined) {
|
|
1167
|
-
const dashYear = (extractValue(parsed["dash_year"]) ?? "").replace(/^[-:]/, "");
|
|
1168
|
-
if (/^\d{4}$/.test(dashYear))
|
|
1169
|
-
attributes["year"] = dashYear;
|
|
1170
|
-
}
|
|
1171
|
-
// The IEEE-led tail word-stage ("IEEE/ISO/IEC P15026-3/CD,
|
|
1172
|
-
// December 2021") composes the D= designator with the glued
|
|
1173
|
-
// 6-digit date — the identity its D= twin spelling parses to (the
|
|
1174
|
-
// corpus canonical: joint-development, lead IEEE, stage P). The
|
|
1175
|
-
// ISO-led lists converge to the published-Std identity (the issue
|
|
1176
|
-
// #216 semantics). The zero-width printed_month_year capture
|
|
1177
|
-
// carries "" — truthy in the reference (nil-check), falsy in JS:
|
|
1178
|
-
// test presence, not truth.
|
|
1179
|
-
if (parsed["tail_iso_stage"] !== undefined &&
|
|
1180
|
-
parsed["printed_month_year"] !== undefined &&
|
|
1181
|
-
parsed["part"] !== undefined) {
|
|
1182
|
-
const stage = extractValue(parsed["tail_iso_stage"]);
|
|
1183
|
-
const year = extractValue(parsed["year"]) ?? "";
|
|
1184
|
-
const monthName = (extractValue(parsed["month"]) ?? "").replace(/\.$/, "");
|
|
1185
|
-
const monthNum = DRAFT_MONTH_NAMES[monthName];
|
|
1186
|
-
if (stage !== undefined && monthNum !== undefined) {
|
|
1187
|
-
attributes["ieee_draft"] = `D=${stage}-${year}${monthNum.padStart(2, "0")}`;
|
|
1188
|
-
parsed["year"] = undefined;
|
|
1189
|
-
parsed["month"] = undefined;
|
|
1190
|
-
parsed["printed_month_year"] = undefined;
|
|
1191
|
-
delete attributes["year"];
|
|
1192
|
-
delete attributes["month"];
|
|
1193
|
-
// The ISO-led lists converge to the published-Std identity; the
|
|
1194
|
-
// IEEE-led lists stay the live project draft (stage P).
|
|
1195
|
-
if (attributes["publisher"] !== "IEEE") {
|
|
1196
|
-
parsed["iso_published"] = { value: "" };
|
|
1197
|
-
const stdRecord = locateStage("Std");
|
|
1198
|
-
if (stdRecord !== undefined) {
|
|
1199
|
-
attributes["typed_stage"] = new IeeeTypedStage(stdRecord);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
if (parsed["edition"] !== undefined)
|
|
1205
|
-
attributes["edition"] = extractValue(parsed["edition"]);
|
|
1206
|
-
if (parsed["edition_month"] !== undefined) {
|
|
1207
|
-
attributes["edition_month"] = extractValue(parsed["edition_month"]);
|
|
1208
|
-
}
|
|
1209
|
-
if (parsed["draft_version"] !== undefined) {
|
|
1210
|
-
const draftVer = (extractValue(parsed["draft_version"]) ?? "").replace(/^D/, "");
|
|
1211
|
-
// FCD is an ISO stage (the 2026-10-19 ruling): a glued month-name
|
|
1212
|
-
// date rides the designator's date slot with the month numeric —
|
|
1213
|
-
// the D= designator face, never the "DFCD" glue.
|
|
1214
|
-
const stageDate = /^(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)(\d+)?(?:-([A-Za-z]+)(\d{4}))?$/.exec(draftVer);
|
|
1215
|
-
if (stageDate !== null) {
|
|
1216
|
-
const monthNum = stageDate[3] !== undefined ? DRAFT_MONTH_NAMES[stageDate[3]] : undefined;
|
|
1217
|
-
const stageWord = stageDate[1] + (stageDate[2] ?? "");
|
|
1218
|
-
attributes["ieee_draft"] =
|
|
1219
|
-
stageDate[3] !== undefined && monthNum !== undefined
|
|
1220
|
-
? `D=${stageWord}-${stageDate[4]}${monthNum.padStart(2, "0")}`
|
|
1221
|
-
: `D=${stageWord}`;
|
|
1222
|
-
delete attributes["draft"];
|
|
1223
|
-
delete attributes["year"];
|
|
1224
|
-
delete attributes["month"];
|
|
1225
|
-
}
|
|
1226
|
-
else if (draftVer !== "") {
|
|
1227
|
-
// A date trailing the draft (", June 2010") belongs to the draft
|
|
1228
|
-
// component (canonical month, comma form); the identity
|
|
1229
|
-
// year/month the promotion filled from the same captures are
|
|
1230
|
-
// vacated. Stage-first ISO rows are exempt: their canonical is
|
|
1231
|
-
// the ISO face, which prints the date from the identity slots
|
|
1232
|
-
// (", March 2017", pubid#216).
|
|
1233
|
-
if (parsed["draft_month"] !== undefined && parsed["iso_stage"] === undefined) {
|
|
1234
|
-
const dm = extractValue(parsed["draft_month"]) ?? "";
|
|
1235
|
-
const dy = extractValue(parsed["draft_year"]) ?? "";
|
|
1236
|
-
const monthNum = DRAFT_MONTH_NAMES[dm.replace(/\.$/, "")];
|
|
1237
|
-
if (JSON.stringify(attributes["publishers"]) === JSON.stringify(["IEEE", "CSA"]) &&
|
|
1238
|
-
monthNum !== undefined && dy !== "") {
|
|
1239
|
-
// The joint IEEE/CSA drafts glue their date into the
|
|
1240
|
-
// designator with the month numeric (pubid ruling
|
|
1241
|
-
// 2026-10-14: no comma dates on these rows).
|
|
1242
|
-
const glued = new IeeeDraft({
|
|
1243
|
-
version: `${draftVer}-${dy}-${monthNum.padStart(2, "0")}`,
|
|
1244
|
-
});
|
|
1245
|
-
attributes["draft"] = glued.render();
|
|
1246
|
-
}
|
|
1247
|
-
else {
|
|
1248
|
-
const draftObj = new IeeeDraft({
|
|
1249
|
-
version: draftVer,
|
|
1250
|
-
month: dm === "" ? undefined : dm,
|
|
1251
|
-
year: dy === "" ? undefined : dy,
|
|
1252
|
-
comma_before_month: true,
|
|
1253
|
-
});
|
|
1254
|
-
attributes["draft"] = draftObj.render();
|
|
1255
|
-
}
|
|
1256
|
-
if (parsed["year"] === undefined)
|
|
1257
|
-
delete attributes["year"];
|
|
1258
|
-
if (parsed["month"] === undefined)
|
|
1259
|
-
delete attributes["month"];
|
|
1260
|
-
}
|
|
1261
|
-
else if (parsed["draft_year"] !== undefined && parsed["iso_stage"] === undefined) {
|
|
1262
|
-
// The comma-year tail captures its separator (", 2013") —
|
|
1263
|
-
// strip it (the #471 separator-in-capture rule). The stored
|
|
1264
|
-
// form keeps the comma so it re-parses through the same tail.
|
|
1265
|
-
const draftYear = (extractValue(parsed["draft_year"]) ?? "").replace(/^[, ]+/, "");
|
|
1266
|
-
// Compose through the render so a designator-word version
|
|
1267
|
-
// ("ED1") keeps its word instead of concatenating D ("DED1").
|
|
1268
|
-
attributes["draft"] =
|
|
1269
|
-
new IeeeDraft({ version: draftVer, year: draftYear }).render();
|
|
1270
|
-
if (parsed["year"] === undefined)
|
|
1271
|
-
delete attributes["year"];
|
|
1272
|
-
}
|
|
1273
|
-
else if (JSON.stringify(attributes["publishers"]) === JSON.stringify(["IEEE", "CSA"]) &&
|
|
1274
|
-
parsed["iso_stage"] === undefined &&
|
|
1275
|
-
/^(19|20)\d\d$/.test(extractValue(parsed["year"]) ?? "") &&
|
|
1276
|
-
/^\d{1,2}$/.test(extractValue(parsed["month"]) ?? "")) {
|
|
1277
|
-
// The glued face re-parses with the date in the identity
|
|
1278
|
-
// slots ("D2-2016-09" -> year/month + a bare D2): it
|
|
1279
|
-
// normalizes back onto the draft-embedded date so the
|
|
1280
|
-
// round trip closes on the CSA canonical.
|
|
1281
|
-
const glued = new IeeeDraft({
|
|
1282
|
-
version: `${draftVer}-${extractValue(parsed["year"])}-${extractValue(parsed["month"])}`,
|
|
1283
|
-
});
|
|
1284
|
-
attributes["draft"] = glued.render();
|
|
1285
|
-
delete attributes["year"];
|
|
1286
|
-
delete attributes["month"];
|
|
1287
|
-
}
|
|
1288
|
-
else {
|
|
1289
|
-
attributes["ieee_draft"] = `D${draftVer}`;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
// The "(E)" edition marker of an ISO/IEC label rides on the joint
|
|
1294
|
-
// reference as parenthetical_content - either from the trailing
|
|
1295
|
-
// parenthetical slot (the double-label form) or the mid-rule slot
|
|
1296
|
-
// before an amendment tail.
|
|
1297
|
-
const parenthetical = parsed["parameters"];
|
|
1298
|
-
if (parenthetical !== undefined && typeof parenthetical === "object" && !Array.isArray(parenthetical)) {
|
|
1299
|
-
const content = parenthetical["parenthetical_content"];
|
|
1300
|
-
if (content !== undefined)
|
|
1301
|
-
attributes["parenthetical_content"] = extractValue(content);
|
|
1302
|
-
}
|
|
1303
|
-
if (attributes["parenthetical_content"] === undefined && parsed["edition_marker"] !== undefined) {
|
|
1304
|
-
attributes["parenthetical_content"] = extractValue(parsed["edition_marker"]);
|
|
1305
|
-
}
|
|
1306
|
-
// A joint ISO-print redline is a distinct document of the same standard
|
|
1307
|
-
// (pubid#215) - same flag semantics as the generic path.
|
|
1308
|
-
if (parsed["redline"] !== undefined)
|
|
1309
|
-
attributes["redline"] = true;
|
|
1310
|
-
// The joint stage-draft clause (docs/IEEE-DRAFT-STAGES.md §1.3):
|
|
1311
|
-
// variant 1's compound tail composes onto the IEEE ordinal
|
|
1312
|
-
// ("D5=DIS.3"); variant 1b is the ordinal-less stage draft whose
|
|
1313
|
-
// date rides inside the designator ("D=CDV:2020"). The doubled-D
|
|
1314
|
-
// alias spelling echoes as spelled.
|
|
1315
|
-
if (parsed["draft_iso_stage"] !== undefined) {
|
|
1316
|
-
// The doubled-D alias ("=DDIS") is notation: the designator carries
|
|
1317
|
-
// its own D-ordinal, the stage is the bare ISO/IEC token.
|
|
1318
|
-
const rawStage = `${extractValue(parsed["draft_stage_d"]) ?? ""}${extractValue(parsed["draft_iso_stage"]) ?? ""}`;
|
|
1319
|
-
const stageText = rawStage.startsWith("D") &&
|
|
1320
|
-
["PWI", "NP", "WD", "CD", "CDV", "DIS", "FDIS"].includes(rawStage.slice(1))
|
|
1321
|
-
? rawStage.slice(1)
|
|
1322
|
-
: rawStage;
|
|
1323
|
-
const jointVersion = extractValue(parsed["draft_version"]) ??
|
|
1324
|
-
(parsed["draft"] !== undefined
|
|
1325
|
-
? extractValue(asHash(parsed["draft"])["draft_version"])
|
|
1326
|
-
: undefined);
|
|
1327
|
-
let jointDraft = jointVersion !== undefined
|
|
1328
|
-
? `D${jointVersion.replace(/^D/, "")}=${stageText}`
|
|
1329
|
-
: `D=${stageText}`;
|
|
1330
|
-
if (parsed["draft_iso_iteration"] !== undefined) {
|
|
1331
|
-
jointDraft += `.${extractValue(parsed["draft_iso_iteration"])}`;
|
|
1332
|
-
}
|
|
1333
|
-
if (parsed["draft_stage_year"] !== undefined) {
|
|
1334
|
-
// The capture carries its separator verbatim (":2020" /
|
|
1335
|
-
// "-201112" - the #471 separator-in-capture rule): the ruby
|
|
1336
|
-
// builder appends it raw, so the face keeps the printed form.
|
|
1337
|
-
jointDraft += extractValue(parsed["draft_stage_year"]) ?? "";
|
|
1338
|
-
}
|
|
1339
|
-
attributes["ieee_draft"] = jointDraft;
|
|
1340
|
-
}
|
|
1341
|
-
// The catalogue-PRINTED joint form (dash-year / ", Month YYYY" /
|
|
1342
|
-
// date-trailing-the-draft / date-less parenthetical): a Standard
|
|
1343
|
-
// carrying publisher/copublisher renders it as printed; the colon-year
|
|
1344
|
-
// spelling stays the ISO-style JointDevelopment. Stage-WORD drafts
|
|
1345
|
-
// (letters, not a D-number) stay joint - their canonical renders drop
|
|
1346
|
-
// the P and keep the joint spelling.
|
|
1347
|
-
const numericDraft = parsed["draft_version"] !== undefined &&
|
|
1348
|
-
/^\d/.test(extractValue(parsed["draft_version"]) ?? "");
|
|
1349
|
-
// P + a /D designator (any draft capture) is a DRAFT, never a
|
|
1350
|
-
// printed Std (the owner's 2026-10-24 ruling) -- the joint/
|
|
1351
|
-
// project-draft family owns the row whatever date trails the
|
|
1352
|
-
// designator. The ruling extends to the P-less joint rows
|
|
1353
|
-
// (pubid#597): a numeric /D designator alone is project status
|
|
1354
|
-
// too -- the row is a draft AND takes the P, so the marker is set
|
|
1355
|
-
// below when the source spelling lacked it.
|
|
1356
|
-
const pWithDraft = (parsed["project_marker"] !== undefined || numericDraft) &&
|
|
1357
|
-
(parsed["draft_version"] !== undefined || parsed["draft_iso_stage"] !== undefined ||
|
|
1358
|
-
parsed["draft_month"] !== undefined || parsed["draft_year"] !== undefined);
|
|
1359
|
-
if (pWithDraft && parsed["project_marker"] === undefined) {
|
|
1360
|
-
attributes["project_marker"] = true;
|
|
1361
|
-
parsed["project_marker"] = "P";
|
|
1362
|
-
}
|
|
1363
|
-
if (
|
|
1364
|
-
// The bound tree spreads the raw iso_published interior flat, so a
|
|
1365
|
-
// stage-first joint row carries a top-level iso_stage — the stage
|
|
1366
|
-
// word keeps the joint ISO face (the reference's iso_stage.nil? gate).
|
|
1367
|
-
parsed["iso_published"] !== undefined && parsed["iso_stage"] === undefined && !pWithDraft &&
|
|
1368
|
-
(parsed["printed_dash_year"] !== undefined || parsed["printed_month_year"] !== undefined ||
|
|
1369
|
-
(numericDraft && parsed["draft_month"] !== undefined) ||
|
|
1370
|
-
(parsed["year"] === undefined && parsed["parameters"] !== undefined &&
|
|
1371
|
-
typeof parsed["parameters"] === "object" && !Array.isArray(parsed["parameters"]) &&
|
|
1372
|
-
parsed["parameters"]["parenthetical_content"] !== undefined))) {
|
|
1373
|
-
const sep = parsed["part_dash"] !== undefined ? "-" : ".";
|
|
1374
|
-
// The part capture carries its own separator (C1
|
|
1375
|
-
// separator-in-capture); join verbatim, synthesizing one only
|
|
1376
|
-
// for a bare capture — the reference's printed_joint rule.
|
|
1377
|
-
const partVal = extractValue(parsed["part"]);
|
|
1378
|
-
let printedCode = extractValue(parsed["number"]) ?? "";
|
|
1379
|
-
if (partVal !== undefined) {
|
|
1380
|
-
printedCode += /^[._-]/.test(partVal) ? partVal : `${sep}${partVal}`;
|
|
1381
|
-
}
|
|
1382
|
-
// the subpart carries its separator too (C1 separator-in-capture);
|
|
1383
|
-
// the two-party rows split "-57-1202"-class parts into both
|
|
1384
|
-
const subVal = parsed["subpart"] !== undefined ? extractValue(parsed["subpart"]) : undefined;
|
|
1385
|
-
if (subVal !== undefined && subVal !== "")
|
|
1386
|
-
printedCode += subVal;
|
|
1387
|
-
// P = project: the marker is identity, preserved as spelled.
|
|
1388
|
-
if (parsed["project_marker"] !== undefined)
|
|
1389
|
-
printedCode = `P${printedCode}`;
|
|
1390
|
-
const printedAttrs = {
|
|
1391
|
-
publisher: attributes["publisher"],
|
|
1392
|
-
copublisher: attributes["copublisher"],
|
|
1393
|
-
typed_stage: locateStage("Std") !== undefined ? new IeeeTypedStage(locateStage("Std")) : undefined,
|
|
1394
|
-
};
|
|
1395
|
-
let printedDraft = attributes["ieee_draft"];
|
|
1396
|
-
let finalCode = printedCode;
|
|
1397
|
-
if (parsed["printed_dash_year"] !== undefined && parsed["month"] !== undefined) {
|
|
1398
|
-
// A dash-year-month date glues onto the printed code before any
|
|
1399
|
-
// draft - the render's month slot would lose the printed form.
|
|
1400
|
-
finalCode = `${printedCode}-${attributes["year"]}-${attributes["month"]}`;
|
|
1401
|
-
}
|
|
1402
|
-
else if (parsed["printed_dash_year"] !== undefined) {
|
|
1403
|
-
// A bare dash-year is the identity year - an attribute.
|
|
1404
|
-
printedAttrs["year"] = attributes["year"];
|
|
1405
|
-
}
|
|
1406
|
-
else if (parsed["printed_month_year"] !== undefined) {
|
|
1407
|
-
printedAttrs["year"] = attributes["year"];
|
|
1408
|
-
printedAttrs["month"] = attributes["month"];
|
|
1409
|
-
}
|
|
1410
|
-
else if (parsed["draft_month"] !== undefined) {
|
|
1411
|
-
// The date trails the draft itself ("D31, Aug 2010"): the
|
|
1412
|
-
// normalization ledger strips the ordinal draft on the printed
|
|
1413
|
-
// joint face and surfaces the date as the printed date.
|
|
1414
|
-
printedAttrs["year"] = extractValue(parsed["draft_year"]);
|
|
1415
|
-
printedAttrs["month"] = extractValue(parsed["draft_month"]);
|
|
1416
|
-
}
|
|
1417
|
-
const codeObj = IeeeCode.parse(finalCode);
|
|
1418
|
-
if (codeObj !== undefined) {
|
|
1419
|
-
printedAttrs["__code_obj"] = codeObj;
|
|
1420
|
-
printedAttrs["number"] = codeObj.number;
|
|
1421
|
-
if (codeObj.prefix !== undefined)
|
|
1422
|
-
printedAttrs["prefix"] = codeObj.prefix;
|
|
1423
|
-
if (codeObj.parts.length > 0)
|
|
1424
|
-
printedAttrs["parts"] = codeObj.parts;
|
|
1425
|
-
if (codeObj.originalSeparator !== undefined)
|
|
1426
|
-
printedAttrs["separator"] = codeObj.originalSeparator;
|
|
1427
|
-
}
|
|
1428
|
-
if (printedDraft !== undefined)
|
|
1429
|
-
printedAttrs["draft"] = printedDraft;
|
|
1430
|
-
if (attributes["edition"] !== undefined)
|
|
1431
|
-
printedAttrs["edition"] = attributes["edition"];
|
|
1432
|
-
if (attributes["edition_month"] !== undefined)
|
|
1433
|
-
printedAttrs["edition_month"] = attributes["edition_month"];
|
|
1434
|
-
const params = parsed["parameters"];
|
|
1435
|
-
if (params !== undefined && typeof params === "object" && !Array.isArray(params) &&
|
|
1436
|
-
params["parenthetical_content"] !== undefined) {
|
|
1437
|
-
printedAttrs["parenthetical_content"] = extractValue(params["parenthetical_content"]);
|
|
1438
|
-
}
|
|
1439
|
-
for (const k of Object.keys(printedAttrs)) {
|
|
1440
|
-
if (printedAttrs[k] === undefined)
|
|
1441
|
-
delete printedAttrs[k];
|
|
1442
|
-
}
|
|
1443
|
-
const printed = new StandardClass(printedAttrs);
|
|
1444
|
-
if (printedAttrs["__code_obj"] instanceof IeeeCode) {
|
|
1445
|
-
printed["__code_obj"] = printedAttrs["__code_obj"];
|
|
1446
|
-
}
|
|
1447
|
-
return printed;
|
|
1448
|
-
}
|
|
1449
|
-
// A stage word with a glued year tail ("/D=CD2-201802") rides the
|
|
1450
|
-
// D= designator with the IEEE lead (the reference's builder, the
|
|
1451
|
-
// pubid#203 class) — the tail's capture carries its separator. The
|
|
1452
|
-
// date-less form ("/D=CD1") elects the same face only when the input
|
|
1453
|
-
// spells the designator (the reference's original_input gate) — the
|
|
1454
|
-
// stage-first rows keep their ISO rendering.
|
|
1455
|
-
// The designation route ("IEEE P24748-4/D=FDIS") has no
|
|
1456
|
-
// publishers group; IEEE is the sole publisher of the D=
|
|
1457
|
-
// designator face, and the elections below read the builder-local
|
|
1458
|
-
// slots.
|
|
1459
|
-
if (attributes["publisher"] === undefined)
|
|
1460
|
-
attributes["publisher"] = "IEEE";
|
|
1461
|
-
if (attributes["copublisher"] === undefined)
|
|
1462
|
-
attributes["copublisher"] = [];
|
|
1463
|
-
// The model rebuilds publishers from publisher+copublisher when
|
|
1464
|
-
// the publishers group is absent (the reference initialize).
|
|
1465
|
-
if (attributes["publishers"] === undefined) {
|
|
1466
|
-
attributes["publishers"] = [attributes["publisher"],
|
|
1467
|
-
...(attributes["copublisher"] ?? [])];
|
|
1468
|
-
}
|
|
1469
|
-
const dEqInput = this.originalInput.includes("/D=");
|
|
1470
|
-
const stageWordForGate = extractValue(parsed["iso_stage"]) ?? "";
|
|
1471
|
-
if (parsed["iso_stage"] !== undefined &&
|
|
1472
|
-
(parsed["draft_stage_year"] !== undefined ||
|
|
1473
|
-
(dEqInput && /\d$/.test(stageWordForGate)))) {
|
|
1474
|
-
const stageWord = stageWordForGate;
|
|
1475
|
-
const pubs = (attributes["publishers"] ?? []);
|
|
1476
|
-
if (pubs.length === 0) {
|
|
1477
|
-
attributes["publishers"] = ["IEEE"];
|
|
1478
|
-
attributes["publisher"] = "IEEE";
|
|
1479
|
-
attributes["copublisher"] = [];
|
|
1480
|
-
}
|
|
1481
|
-
attributes["ieee_draft"] = `D=${stageWord}${extractValue(parsed["draft_stage_year"]) ?? ""}`;
|
|
1482
|
-
const stageRecord = locateStage(stageWord);
|
|
1483
|
-
if (stageRecord !== undefined) {
|
|
1484
|
-
attributes["typed_stage"] = new IeeeTypedStage(stageRecord);
|
|
1485
|
-
}
|
|
1486
|
-
attributes["lead_party"] = "IEEE";
|
|
1487
|
-
delete attributes["year"];
|
|
1488
|
-
delete attributes["month"];
|
|
1489
|
-
}
|
|
1490
|
-
if (parsed["iso_stage"] !== undefined) {
|
|
1491
|
-
// A bare-IEEE project carrying a stage never elects the ISO lead
|
|
1492
|
-
// (the reference's bare_ieee_project gate): the lead stays IEEE.
|
|
1493
|
-
const bareIeeeProject = parsed["project_marker"] !== undefined &&
|
|
1494
|
-
attributes["publisher"] === "IEEE" &&
|
|
1495
|
-
(attributes["copublisher"] ?? []).length === 0;
|
|
1496
|
-
if (!bareIeeeProject)
|
|
1497
|
-
attributes["lead_party"] = "ISO";
|
|
1498
|
-
let stageAbbr = extractValue(parsed["iso_stage"]);
|
|
1499
|
-
// The bare-IEEE project row carries the stage on the D=
|
|
1500
|
-
// designator with the IEEE date convention ("D=FDIS-201008",
|
|
1501
|
-
// pubid#203); the ISO stage-word face is not elected.
|
|
1502
|
-
if (bareIeeeProject && parsed["draft_stage_year"] === undefined) {
|
|
1503
|
-
let date = "";
|
|
1504
|
-
const y = attributes["year"];
|
|
1505
|
-
const m = String(attributes["month"] ?? "");
|
|
1506
|
-
if (y !== undefined) {
|
|
1507
|
-
date = `-${y}`;
|
|
1508
|
-
if (m !== "") {
|
|
1509
|
-
const monthNum = /^\d+$/.test(m) ? Number(m) : DRAFT_MONTH_NAMES[String(m).replace(/\.$/, "")];
|
|
1510
|
-
if (monthNum !== undefined)
|
|
1511
|
-
date += String(monthNum).padStart(2, "0");
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
attributes["ieee_draft"] = `D=${stageAbbr}${date}`;
|
|
1515
|
-
const record = stageAbbr !== undefined ? locateStage(stageAbbr) : undefined;
|
|
1516
|
-
if (record !== undefined)
|
|
1517
|
-
attributes["typed_stage"] = new IeeeTypedStage(record);
|
|
1518
|
-
attributes["lead_party"] = "IEEE";
|
|
1519
|
-
delete attributes["year"];
|
|
1520
|
-
delete attributes["month"];
|
|
1521
|
-
}
|
|
1522
|
-
// The IEC "/V<version>" iteration rides glued onto the stage word
|
|
1523
|
-
// ("_CDV/V3" -> "CDV3") — the family's lossless spelling (the
|
|
1524
|
-
// reference's builder, pubid#477).
|
|
1525
|
-
const stageIteration = extractValue(parsed["iso_stage_iteration"]);
|
|
1526
|
-
if (stageAbbr !== undefined && stageIteration !== undefined) {
|
|
1527
|
-
stageAbbr += stageIteration;
|
|
1528
|
-
}
|
|
1529
|
-
if (!bareIeeeProject)
|
|
1530
|
-
attributes["iso_stage"] = stageAbbr;
|
|
1531
|
-
if (stageAbbr !== undefined && !bareIeeeProject) {
|
|
1532
|
-
const record = locateStage(stageAbbr);
|
|
1533
|
-
if (record !== undefined)
|
|
1534
|
-
attributes["typed_stage"] = new IeeeTypedStage(record);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
else if (parsed["iso_published"] !== undefined) {
|
|
1538
|
-
attributes["lead_party"] = "ISO";
|
|
1539
|
-
}
|
|
1540
|
-
else {
|
|
1541
|
-
attributes["lead_party"] = "IEEE";
|
|
1542
|
-
attributes["type"] = "P";
|
|
1543
|
-
if ((parsed["draft_iso_stage"] !== undefined ||
|
|
1544
|
-
parsed["tail_iso_stage"] !== undefined) &&
|
|
1545
|
-
attributes["publisher"] === "ISO") {
|
|
1546
|
-
// The ISO-led D= designator (the issue #216 convergence) is
|
|
1547
|
-
// the stage-tracked draft of a published standard - the typed
|
|
1548
|
-
// stage reads Std/published.
|
|
1549
|
-
const stdRecord = locateStage("Std");
|
|
1550
|
-
if (stdRecord !== undefined) {
|
|
1551
|
-
attributes["typed_stage"] = new IeeeTypedStage(stdRecord);
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
else {
|
|
1555
|
-
const record = locateStage("P");
|
|
1556
|
-
if (record !== undefined)
|
|
1557
|
-
attributes["typed_stage"] = new IeeeTypedStage(record);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
// A plain IEEE-designator draft on joint publishers ("/D8, June
|
|
1561
|
-
// 2010") carries no ISO stage machinery: it builds as the project
|
|
1562
|
-
// draft its bare-IEEE twin and the D= designator rows already pin
|
|
1563
|
-
// (pubid#430) rather than the joint-development model.
|
|
1564
|
-
if (attributes["draft"] !== undefined &&
|
|
1565
|
-
parsed["iso_stage"] === undefined &&
|
|
1566
|
-
parsed["iec_stage"] === undefined &&
|
|
1567
|
-
parsed["amd_number"] === undefined) {
|
|
1568
|
-
const pubs = (attributes["publishers"] ?? []);
|
|
1569
|
-
const projectAttrs = {
|
|
1570
|
-
draft: attributes["draft"],
|
|
1571
|
-
};
|
|
1572
|
-
// The comma-year tail rides the draft verbatim ("D4, 2019" — the
|
|
1573
|
-
// reference keeps the comma face on the joint project drafts; the
|
|
1574
|
-
// year never promotes to the identity slots).
|
|
1575
|
-
// The code columns (number/parts/separator/prefix) are the
|
|
1576
|
-
// ProjectDraft render/hash face; the spelled P is the project
|
|
1577
|
-
// marker (identity), whatever the lead publisher.
|
|
1578
|
-
for (const k of ["number", "prefix", "parts", "separator"]) {
|
|
1579
|
-
// A "P" prefix is the project marker itself (the generic path
|
|
1580
|
-
// deletes it on the strip) - it must not ride the code columns.
|
|
1581
|
-
if (attributes[k] !== undefined && !(k === "prefix" && attributes[k] === "P")) {
|
|
1582
|
-
projectAttrs[k] = attributes[k];
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
// The ruling (pubid#597): a joint row with a numeric /D designator
|
|
1586
|
-
// is a draft AND takes the P project marker, whatever the source
|
|
1587
|
-
// spelling printed -- the marker rides the identifier even when
|
|
1588
|
-
// the row reached it without one.
|
|
1589
|
-
projectAttrs["project_marker"] = true;
|
|
1590
|
-
if (pubs.length > 0) {
|
|
1591
|
-
projectAttrs["publisher"] = pubs[0];
|
|
1592
|
-
if (pubs.length > 1)
|
|
1593
|
-
projectAttrs["copublisher"] = pubs.slice(1);
|
|
1594
|
-
}
|
|
1595
|
-
if (attributes["draft_status"] !== undefined) {
|
|
1596
|
-
projectAttrs["draft_status"] = attributes["draft_status"];
|
|
1597
|
-
}
|
|
1598
|
-
// Ruby's draft_attrs[:code] = "P" + code re-strips in
|
|
1599
|
-
// ProjectDraftIdentifier#initialize and parses the stripped string —
|
|
1600
|
-
// rebuild the runtime code obj from the P-less columns the same way.
|
|
1601
|
-
const strippedCode = new IeeeCode({
|
|
1602
|
-
number: projectAttrs["number"],
|
|
1603
|
-
prefix: projectAttrs["prefix"],
|
|
1604
|
-
parts: projectAttrs["parts"],
|
|
1605
|
-
original_separator: projectAttrs["separator"],
|
|
1606
|
-
}).render();
|
|
1607
|
-
const strippedObj = IeeeCode.parse(strippedCode);
|
|
1608
|
-
if (strippedObj !== undefined)
|
|
1609
|
-
projectAttrs["__code_obj"] = strippedObj;
|
|
1610
|
-
const projectBuilt = new ProjectDraftIdentifierClass(projectAttrs);
|
|
1611
|
-
projectBuilt["__code_obj"] = strippedObj;
|
|
1612
|
-
return projectBuilt;
|
|
1613
|
-
}
|
|
1614
|
-
// The iso_published joint rows normalize the publisher order to
|
|
1615
|
-
// ISO-first (the reference: "IEEE/ISO/IEC 8802-3:2021/Amd 4-2021"
|
|
1616
|
-
// builds the base [ISO, IEC, IEEE], lead ISO); the CD-stage rows and
|
|
1617
|
-
// the IEEE-led project rows preserve the printed order (P90003 stays
|
|
1618
|
-
// IEEE/ISO/IEC).
|
|
1619
|
-
// The reorder is the PUBLISHED stage-less doctrine (pubid#317)
|
|
1620
|
-
// only: the project rows (the P marker) and every draft-bearing
|
|
1621
|
-
// row keep the printed publisher order (the 2026-10-24 corpus
|
|
1622
|
-
// faces, pubid#595).
|
|
1623
|
-
const draftBearing = parsed["project_marker"] !== undefined ||
|
|
1624
|
-
parsed["draft_version"] !== undefined ||
|
|
1625
|
-
parsed["draft"] !== undefined ||
|
|
1626
|
-
parsed["draft_iso_stage"] !== undefined ||
|
|
1627
|
-
parsed["draft_stage_year"] !== undefined;
|
|
1628
|
-
if (parsed["iso_published"] !== undefined && parsed["iso_stage"] === undefined &&
|
|
1629
|
-
!draftBearing && Array.isArray(attributes["publishers"])) {
|
|
1630
|
-
const pubs = attributes["publishers"];
|
|
1631
|
-
attributes["publishers"] = [...pubs.filter((p) => p !== "IEEE"), ...pubs.filter((p) => p === "IEEE")];
|
|
1632
|
-
attributes["publisher"] = attributes["publishers"][0];
|
|
1633
|
-
attributes["copublisher"] = attributes["publishers"].slice(1);
|
|
1634
|
-
}
|
|
1635
|
-
const joint = new JointDevelopmentClass(attributes);
|
|
1636
|
-
if (attributes["__code_obj"] instanceof IeeeCode) {
|
|
1637
|
-
joint["__code_obj"] = attributes["__code_obj"];
|
|
1638
|
-
}
|
|
1639
|
-
const jointIdentifier = joint;
|
|
1640
|
-
if (parsed["amd_number"] === undefined)
|
|
1641
|
-
return jointIdentifier;
|
|
1642
|
-
const amdYear = parsed["amd_year"] !== undefined ? extractValue(parsed["amd_year"]) : undefined;
|
|
1643
|
-
return new AmendmentClass({
|
|
1644
|
-
base: jointIdentifier,
|
|
1645
|
-
number: extractValue(parsed["amd_number"]),
|
|
1646
|
-
year: amdYear,
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
buildSiPsi(parsed) {
|
|
1650
|
-
const attributes = {};
|
|
1651
|
-
const siType = extractValue(parsed["si_type"]);
|
|
1652
|
-
// The bare top-level draft clause binds as draft_version_scalar
|
|
1653
|
-
// (string) — surface it under the key this builder reads (the
|
|
1654
|
-
// reference's build_si_psi_identifier).
|
|
1655
|
-
if (parsed["draft_version"] === undefined && parsed["draft_version_scalar"] !== undefined) {
|
|
1656
|
-
parsed["draft_version"] = parsed["draft_version_scalar"];
|
|
1657
|
-
delete parsed["draft_version_scalar"];
|
|
1658
|
-
}
|
|
1659
|
-
// Extract publishers (should be "IEEE/ASTM") — the SI rule's bare
|
|
1660
|
-
// publishers clause binds as publishers_scalar (string); the
|
|
1661
|
-
// composite joint rows deliver publishers (raw).
|
|
1662
|
-
const pubSrc = parsed["publishers"] ?? parsed["publishers_scalar"];
|
|
1663
|
-
if (pubSrc !== undefined) {
|
|
1664
|
-
const publishersStr = extractValue(pubSrc) ?? "";
|
|
1665
|
-
const pubs = publishersStr.split("/");
|
|
1666
|
-
attributes["publisher"] = pubs[0];
|
|
1667
|
-
if (pubs.length > 1)
|
|
1668
|
-
attributes["copublisher"] = pubs.slice(1);
|
|
1669
|
-
}
|
|
1670
|
-
const codeStr = extractValue(parsed["number"]);
|
|
1671
|
-
if (codeStr !== undefined) {
|
|
1672
|
-
const codeObj = IeeeCode.parse(codeStr);
|
|
1673
|
-
if (codeObj !== undefined) {
|
|
1674
|
-
attributes["__code_obj"] = codeObj;
|
|
1675
|
-
attributes["number"] = codeObj.number;
|
|
1676
|
-
if (codeObj.prefix !== undefined)
|
|
1677
|
-
attributes["prefix"] = codeObj.prefix;
|
|
1678
|
-
if (codeObj.parts.length > 0)
|
|
1679
|
-
attributes["parts"] = codeObj.parts;
|
|
1680
|
-
if (codeObj.originalSeparator !== undefined)
|
|
1681
|
-
attributes["separator"] = codeObj.originalSeparator;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
const stageRecord = SI_STAGES.find((ts) => siType !== undefined && ts.abbr.includes(siType));
|
|
1685
|
-
if (stageRecord !== undefined)
|
|
1686
|
-
attributes["typed_stage"] = new IeeeTypedStage(stageRecord);
|
|
1687
|
-
if (siType === "PSI" && parsed["draft_version"] !== undefined) {
|
|
1688
|
-
attributes["draft"] = new IeeeDraft({ version: extractValue(parsed["draft_version"]) ?? "" }).render();
|
|
1689
|
-
}
|
|
1690
|
-
if (parsed["year"] !== undefined)
|
|
1691
|
-
attributes["year"] = extractValue(parsed["year"]);
|
|
1692
|
-
if (parsed["month"] !== undefined)
|
|
1693
|
-
attributes["month"] = extractValue(parsed["month"]);
|
|
1694
|
-
if (parsed["relationship_type"] !== undefined || parsed["relationship_clause"] !== undefined) {
|
|
1695
|
-
attributes["relationships"] = this.buildRelationships(parsed);
|
|
1696
|
-
}
|
|
1697
|
-
this.handleParameters(parsed, attributes);
|
|
1698
|
-
const siBuilt = new SiStandardClass(attributes);
|
|
1699
|
-
if (attributes["__code_obj"] instanceof IeeeCode) {
|
|
1700
|
-
siBuilt["__code_obj"] = attributes["__code_obj"];
|
|
1701
|
-
}
|
|
1702
|
-
return siBuilt;
|
|
1703
|
-
}
|
|
1704
|
-
buildMultiNumbered(parsed) {
|
|
1705
|
-
const primaryId = this.buildSingleIdentifier(asHash(parsed["primary_identifier"]), false);
|
|
1706
|
-
let secondaryId;
|
|
1707
|
-
if (parsed["secondary_crossref"] !== undefined) {
|
|
1708
|
-
const crossref = extractValue(parsed["secondary_crossref"]) ?? "";
|
|
1709
|
-
secondaryId = new StandardClass({
|
|
1710
|
-
publisher: "IEEE",
|
|
1711
|
-
number: crossref.replace(/^\//, ""),
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
else if (parsed["secondary_joint"] !== undefined) {
|
|
1715
|
-
secondaryId = this.buildSingleIdentifier(asHash(parsed["secondary_joint"]), true);
|
|
1716
|
-
}
|
|
1717
|
-
return new MultiNumberedClass({
|
|
1718
|
-
primary_identifier: primaryId,
|
|
1719
|
-
secondary_identifier: secondaryId,
|
|
1720
|
-
});
|
|
1721
|
-
}
|
|
1722
|
-
buildCsaDualPublished(parsed) {
|
|
1723
|
-
const ieeeId = this.buildSingleIdentifier(asHash(parsed["ieee_portion"]), false);
|
|
1724
|
-
// The CSA portion normalizes "No." to the catalogue's "NO." spelling
|
|
1725
|
-
// (the Ruby CSA component uppercases it) so every alias renders the
|
|
1726
|
-
// same canonical form.
|
|
1727
|
-
const csaString = (extractValue(parsed["csa_portion"]) ?? "").replace(/\bNo\./, "NO.");
|
|
1728
|
-
return new CsaDualPublishedClass({
|
|
1729
|
-
ieee_identifier: ieeeId,
|
|
1730
|
-
csa_string: csaString,
|
|
1731
|
-
year: ieeeId.year,
|
|
1732
|
-
typed_stage: ieeeId.typed_stage,
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
buildSDesignation(parsed) {
|
|
1736
|
-
const attributes = {
|
|
1737
|
-
number: extractValue(parsed["s_number"]),
|
|
1738
|
-
publisher: extractValue(parsed["publisher"]) ?? "IEEE",
|
|
1739
|
-
type: "Std",
|
|
1740
|
-
};
|
|
1741
|
-
const stdRecord = locateStage("Std");
|
|
1742
|
-
if (stdRecord !== undefined)
|
|
1743
|
-
attributes["typed_stage"] = new IeeeTypedStage(stdRecord);
|
|
1744
|
-
if (parsed["ipcea_copub"] !== undefined) {
|
|
1745
|
-
attributes["crossref"] = extractValue(parsed["ipcea_copub"]);
|
|
1746
|
-
}
|
|
1747
|
-
this.handleParameters(parsed, attributes);
|
|
1748
|
-
return new StandardClass(attributes);
|
|
1749
|
-
}
|
|
1750
|
-
buildCombinedAiee(parsed) {
|
|
1751
|
-
const firstId = this.buildAiee(asHash(parsed["first_aiee"]));
|
|
1752
|
-
const secondId = this.buildAiee(asHash(parsed["second_aiee"]));
|
|
1753
|
-
return new DualPublishedClass({
|
|
1754
|
-
first_identifier: firstId,
|
|
1755
|
-
second_identifier: secondId,
|
|
1756
|
-
});
|
|
1757
|
-
}
|
|
1758
|
-
buildIecIeeCopublished(parsed) {
|
|
1759
|
-
const contentRaw = extractValue(parsed["content"]);
|
|
1760
|
-
let copublishedNumber;
|
|
1761
|
-
let draftInfo;
|
|
1762
|
-
let iecYear;
|
|
1763
|
-
let dateInfo;
|
|
1764
|
-
let relationships;
|
|
1765
|
-
if (contentRaw !== undefined) {
|
|
1766
|
-
// A bare (unparenthesised) revision narrative printed after the code
|
|
1767
|
-
// is the same relationship prose as the parenthetical form (C3
|
|
1768
|
-
// ruling) — rewrite it into the parenthetical shape so both
|
|
1769
|
-
// spellings collapse onto one canonical.
|
|
1770
|
-
let content = contentRaw;
|
|
1771
|
-
const bare = content.match(/^(.+?) (Revis(?:ion|on) (?:of|to) IEEE Std .+)$/);
|
|
1772
|
-
if (bare !== null)
|
|
1773
|
-
content = `${bare[1]} (${bare[2]})`;
|
|
1774
|
-
if (content.includes("IEC:")) {
|
|
1775
|
-
copublishedNumber = content.split(" IEC:")[0]?.trim();
|
|
1776
|
-
}
|
|
1777
|
-
else if (content.includes(", ")) {
|
|
1778
|
-
copublishedNumber = content.split(", ")[0]?.trim();
|
|
1779
|
-
}
|
|
1780
|
-
else if (content.includes(" (")) {
|
|
1781
|
-
copublishedNumber = content.split(" (")[0]?.trim();
|
|
1782
|
-
}
|
|
1783
|
-
else {
|
|
1784
|
-
copublishedNumber = content.trim();
|
|
1785
|
-
}
|
|
1786
|
-
if (copublishedNumber !== undefined && copublishedNumber.includes("/D")) {
|
|
1787
|
-
const parts = copublishedNumber.split("/D");
|
|
1788
|
-
copublishedNumber = parts[0];
|
|
1789
|
-
draftInfo = `/D${parts[1] ?? ""}`;
|
|
1790
|
-
}
|
|
1791
|
-
if (content.includes("IEC:")) {
|
|
1792
|
-
const iecPart = content.split("IEC:")[1];
|
|
1793
|
-
if (iecPart !== undefined)
|
|
1794
|
-
iecYear = iecPart.split(" ")[0];
|
|
1795
|
-
}
|
|
1796
|
-
// The parenthetical tail is classified, not swallowed (C3 ruling):
|
|
1797
|
-
// a "(Revision of IEEE Std ...)" narrative is a relationship, not
|
|
1798
|
-
// identity — it lands in `relationships` so the URN carries it as
|
|
1799
|
-
// the rel. segment and the canonical human drops it; an "(MM/DD)"
|
|
1800
|
-
// print date is non-identity and dropped; anything else keeps the
|
|
1801
|
-
// historical date_info rendering.
|
|
1802
|
-
if (content.includes(" (")) {
|
|
1803
|
-
const datePart = content.split(" (")[1];
|
|
1804
|
-
if (datePart !== undefined && datePart.includes(")")) {
|
|
1805
|
-
const tail = datePart.split(")")[0];
|
|
1806
|
-
const revision = tail !== undefined
|
|
1807
|
-
? tail.match(/^Revis(?:ion|on) (?:of|to) IEEE Std (.+)$/)
|
|
1808
|
-
: null;
|
|
1809
|
-
if (tail !== undefined && revision !== null) {
|
|
1810
|
-
let related;
|
|
1811
|
-
try {
|
|
1812
|
-
related = ieeeParseSingle(revision[1]);
|
|
1813
|
-
}
|
|
1814
|
-
catch {
|
|
1815
|
-
related = { toHuman: () => revision[1] };
|
|
1816
|
-
}
|
|
1817
|
-
relationships = [new IeeeRelationship("revision_of", [related], [])];
|
|
1818
|
-
}
|
|
1819
|
-
else if (tail !== undefined && /^\d{2}\/\d{2}$/.test(tail)) {
|
|
1820
|
-
// print date — non-identity, dropped
|
|
1821
|
-
}
|
|
1822
|
-
else if (tail !== undefined) {
|
|
1823
|
-
dateInfo = tail;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
const attrs = {};
|
|
1829
|
-
if (draftInfo !== undefined)
|
|
1830
|
-
attrs["draft_info"] = draftInfo;
|
|
1831
|
-
if (iecYear !== undefined)
|
|
1832
|
-
attrs["iec_year"] = iecYear;
|
|
1833
|
-
if (dateInfo !== undefined)
|
|
1834
|
-
attrs["date_info"] = dateInfo;
|
|
1835
|
-
if (relationships !== undefined)
|
|
1836
|
-
attrs["relationships"] = relationships;
|
|
1837
|
-
Object.assign(attrs, copublishedStructured(copublishedNumber));
|
|
1838
|
-
return new IecIeeeCopublishedClass(attrs);
|
|
1839
|
-
}
|
|
1840
|
-
// --- AIEE / IRE / NESC builders ---------------------------------------------
|
|
1841
|
-
buildAiee(parsed) {
|
|
1842
|
-
const attributes = { publisher: "AIEE" };
|
|
1843
|
-
const typeStr = extractValue(parsed["type"]);
|
|
1844
|
-
attributes["type"] = typeStr !== undefined && typeStr.startsWith("Standard") ? "No" : typeStr;
|
|
1845
|
-
const numberValue = parsed["number"];
|
|
1846
|
-
let codeStr;
|
|
1847
|
-
if (isObj(numberValue)) {
|
|
1848
|
-
const main = extractValue(numberValue["main_number"]);
|
|
1849
|
-
const paren = numberValue["parenthetical"];
|
|
1850
|
-
const alt = isObj(paren) ? extractValue(paren["alt_number"]) : undefined;
|
|
1851
|
-
codeStr = alt !== undefined && main !== undefined ? `${main} (${alt})` : main;
|
|
1852
|
-
}
|
|
1853
|
-
else {
|
|
1854
|
-
codeStr = extractValue(numberValue);
|
|
1855
|
-
}
|
|
1856
|
-
if (codeStr !== undefined) {
|
|
1857
|
-
const codeObj = IeeeCode.parse(codeStr);
|
|
1858
|
-
if (codeObj !== undefined) {
|
|
1859
|
-
attributes["__code_obj"] = codeObj;
|
|
1860
|
-
attributes["number"] = codeObj.number;
|
|
1861
|
-
if (codeObj.prefix !== undefined)
|
|
1862
|
-
attributes["prefix"] = codeObj.prefix;
|
|
1863
|
-
if (codeObj.parts.length > 0)
|
|
1864
|
-
attributes["parts"] = codeObj.parts;
|
|
1865
|
-
if (codeObj.originalSeparator !== undefined)
|
|
1866
|
-
attributes["separator"] = codeObj.originalSeparator;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
attributes["year"] = extractValue(parsed["year"]);
|
|
1870
|
-
const monthStr = extractValue(parsed["month"]);
|
|
1871
|
-
if (monthStr !== undefined)
|
|
1872
|
-
attributes["month"] = monthStr;
|
|
1873
|
-
const separatorStr = extractValue(parsed["separator"]);
|
|
1874
|
-
if (separatorStr !== undefined)
|
|
1875
|
-
attributes["date_separator"] = separatorStr;
|
|
1876
|
-
attributes["original_format"] = separatorStr !== undefined || monthStr !== undefined ? "long" : "short";
|
|
1877
|
-
const aieeBuilt = new AieeClass(attributes);
|
|
1878
|
-
if (attributes["__code_obj"] instanceof IeeeCode) {
|
|
1879
|
-
aieeBuilt["__code_obj"] = attributes["__code_obj"];
|
|
1880
|
-
}
|
|
1881
|
-
return aieeBuilt;
|
|
1882
|
-
}
|
|
1883
|
-
buildIre(parsed) {
|
|
1884
|
-
const attributes = {};
|
|
1885
|
-
attributes["publisher"] = extractValue(parsed["publisher"]);
|
|
1886
|
-
attributes["type"] = extractValue(parsed["type"]);
|
|
1887
|
-
const numberStr = extractValue(parsed["number"]);
|
|
1888
|
-
if (numberStr !== undefined) {
|
|
1889
|
-
const codeObj = IeeeCode.parse(numberStr);
|
|
1890
|
-
if (codeObj !== undefined) {
|
|
1891
|
-
attributes["number"] = codeObj.number;
|
|
1892
|
-
if (codeObj.prefix !== undefined)
|
|
1893
|
-
attributes["prefix"] = codeObj.prefix;
|
|
1894
|
-
if (codeObj.parts.length > 0)
|
|
1895
|
-
attributes["parts"] = codeObj.parts;
|
|
1896
|
-
if (codeObj.originalSeparator !== undefined)
|
|
1897
|
-
attributes["separator"] = codeObj.originalSeparator;
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
const yearStr = extractValue(parsed["year"]);
|
|
1901
|
-
if (yearStr !== undefined) {
|
|
1902
|
-
const yearInt = Number.parseInt(yearStr, 10);
|
|
1903
|
-
attributes["year"] = String(yearInt >= 12 && yearInt <= 63 ? yearInt + 1900 : yearInt);
|
|
1904
|
-
}
|
|
1905
|
-
const fullYearStr = extractValue(parsed["full_year"]);
|
|
1906
|
-
if (fullYearStr !== undefined)
|
|
1907
|
-
attributes["year"] = String(Number.parseInt(fullYearStr, 10));
|
|
1908
|
-
return new IreClass(attributes);
|
|
1909
|
-
}
|
|
1910
|
-
buildNesc(parsedHash) {
|
|
1911
|
-
// Ruby falls through the variant case on a non-matching value (the
|
|
1912
|
-
// nested name_first variant captures as a hash) and reaches Standard
|
|
1913
|
-
// via the code check; Edition is only the no-code fallback.
|
|
1914
|
-
let klass = NescEditionClass;
|
|
1915
|
-
if (parsedHash["preprint"] !== undefined) {
|
|
1916
|
-
// Preprint is a draft STAGE of the C2 code — checked before the
|
|
1917
|
-
// Standard route: the c2-preprint tree carries :code "C2" too.
|
|
1918
|
-
klass = NescPreprintClass;
|
|
1919
|
-
}
|
|
1920
|
-
else if (parsedHash["draft"] !== undefined) {
|
|
1921
|
-
klass = NescDraftClass;
|
|
1922
|
-
}
|
|
1923
|
-
else if (typeof parsedHash["variant"] === "string") {
|
|
1924
|
-
const variant = parsedHash["variant"];
|
|
1925
|
-
if (variant === "Handbook")
|
|
1926
|
-
klass = NescHandbookClass;
|
|
1927
|
-
else if (variant === "Redline")
|
|
1928
|
-
klass = NescRedlineClass;
|
|
1929
|
-
}
|
|
1930
|
-
if (klass === NescEditionClass && parsedHash["code"] !== undefined) {
|
|
1931
|
-
klass = NescStandardClass;
|
|
1932
|
-
}
|
|
1933
|
-
const attrs = { code: parsedHash["code"] ?? "C2" };
|
|
1934
|
-
const codeObj = IeeeCode.parse(String(attrs["code"]));
|
|
1935
|
-
if (codeObj !== undefined) {
|
|
1936
|
-
attrs["number"] = codeObj.number;
|
|
1937
|
-
if (codeObj.prefix !== undefined)
|
|
1938
|
-
attrs["prefix"] = codeObj.prefix;
|
|
1939
|
-
if (codeObj.parts.length > 0)
|
|
1940
|
-
attrs["parts"] = codeObj.parts;
|
|
1941
|
-
}
|
|
1942
|
-
if (parsedHash["year"] !== undefined)
|
|
1943
|
-
attrs["year"] = String(parsedHash["year"]);
|
|
1944
|
-
if (parsedHash["variant"] !== undefined)
|
|
1945
|
-
attrs["variant"] = String(parsedHash["variant"]);
|
|
1946
|
-
if (parsedHash["edition"] !== undefined)
|
|
1947
|
-
attrs["edition"] = String(parsedHash["edition"]);
|
|
1948
|
-
if (parsedHash["month"] !== undefined)
|
|
1949
|
-
attrs["month"] = String(parsedHash["month"]);
|
|
1950
|
-
if (parsedHash["name_registered"] !== undefined || parsedHash["abbr_registered"] !== undefined) {
|
|
1951
|
-
attrs["registered"] = true;
|
|
1952
|
-
}
|
|
1953
|
-
if (parsedHash["paren_abbr"] !== undefined) {
|
|
1954
|
-
attrs["abbr_suffix"] = true;
|
|
1955
|
-
if (parsedHash["paren_registered"] !== undefined)
|
|
1956
|
-
attrs["abbr_suffix_registered"] = true;
|
|
1957
|
-
}
|
|
1958
|
-
return new klass(attrs);
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
function copublishedStructured(copublishedNumber) {
|
|
1962
|
-
if (copublishedNumber === undefined || copublishedNumber === "")
|
|
1963
|
-
return {};
|
|
1964
|
-
const attrs = {};
|
|
1965
|
-
let remainder = copublishedNumber;
|
|
1966
|
-
let year;
|
|
1967
|
-
let yearSep;
|
|
1968
|
-
const yearMatch = /([-:])((?:19|20)\d\d)$/.exec(copublishedNumber);
|
|
1969
|
-
if (yearMatch !== null) {
|
|
1970
|
-
yearSep = yearMatch[1];
|
|
1971
|
-
year = yearMatch[2];
|
|
1972
|
-
remainder = copublishedNumber.slice(0, copublishedNumber.length - yearSep.length - year.length);
|
|
1973
|
-
}
|
|
1974
|
-
const all = remainder.match(/^[^.\-]+|[.\-][^.\-]+/g) ?? [];
|
|
1975
|
-
const parts = [];
|
|
1976
|
-
const separators = [];
|
|
1977
|
-
for (const token of all.slice(1)) {
|
|
1978
|
-
parts.push(token.slice(1));
|
|
1979
|
-
separators.push(token[0] ?? "");
|
|
1980
|
-
}
|
|
1981
|
-
attrs["number"] = all[0];
|
|
1982
|
-
if (parts.length > 0) {
|
|
1983
|
-
attrs["parts"] = parts;
|
|
1984
|
-
attrs["separators"] = separators;
|
|
1985
|
-
}
|
|
1986
|
-
if (year !== undefined) {
|
|
1987
|
-
attrs["year"] = year;
|
|
1988
|
-
if (yearSep !== "-")
|
|
1989
|
-
attrs["year_sep"] = yearSep;
|
|
1990
|
-
}
|
|
1991
|
-
return attrs;
|
|
1992
|
-
}
|
|
1993
|
-
// --- parse orchestration -------------------------------------------------------
|
|
9
|
+
import { ieeeParseImpl, makeIeeeGrammarImplementation, makeIeeeParseEngine, } from "./implementation.js";
|
|
1994
10
|
// The grammar runtime is the baked PARG artifact (pubid-grammar
|
|
1995
|
-
// artifacts/ieee.json via the parsanol engine)
|
|
1996
|
-
//
|
|
1997
|
-
// Only the preprocessor, builder, model and the AIEE sub-grammar root
|
|
1998
|
-
// (parseAieeDirect) remain hand-written.
|
|
11
|
+
// artifacts/ieee.json via the parsanol engine), loaded lazily from disk
|
|
12
|
+
// on the first parse and cached for the process.
|
|
1999
13
|
let cachedArtifactRuntime;
|
|
2000
|
-
function
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
// A rejected input binds to null (the parseShape contract threw) —
|
|
2008
|
-
// keep the throw so the reference's ParseFailed-keyed fallbacks fire.
|
|
2009
|
-
if (bound === null || bound === undefined)
|
|
2010
|
-
throw new ParseFailed("no match", 0);
|
|
2011
|
-
return artifactToBuilderTree(bound);
|
|
2012
|
-
}
|
|
2013
|
-
catch (e) {
|
|
2014
|
-
// The engine throws its own error class; the reference's fallback
|
|
2015
|
-
// logic keys on Parslet::ParseFailed, so normalize (the messageless
|
|
2016
|
-
// wasm throws included).
|
|
2017
|
-
throw new ParseFailed(e instanceof Error && e.message !== "" ? e.message : String(e), 0);
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
function ieeeParseSingle(input) {
|
|
2021
|
-
const normalized = applyUpdateCodes(input);
|
|
2022
|
-
// UpdateCodes may introduce the "; " double-label separator (the
|
|
2023
|
-
// ISO/IEC and IEEE labels of one document), but the dispatch ran on
|
|
2024
|
-
// the raw input - re-dispatch so the dual construction sees it.
|
|
2025
|
-
if (normalized !== input && normalized.includes("; ")) {
|
|
2026
|
-
const re = preParse(normalized);
|
|
2027
|
-
if (re.dispatch === "dual_semicolon")
|
|
2028
|
-
return buildDual(re.parts);
|
|
2029
|
-
}
|
|
2030
|
-
const cleaned = preprocessIeee(normalized);
|
|
2031
|
-
const tree = parseSource(cleaned);
|
|
2032
|
-
const builder = new IeeeBuilder();
|
|
2033
|
-
builder.originalInput = input;
|
|
2034
|
-
return builder.build(tree);
|
|
2035
|
-
}
|
|
2036
|
-
// The aiee_simple fallback parses WITHOUT the legacy update-codes table -
|
|
2037
|
-
// the Ruby reference routes "AIEE …" to the AIEE sub-parser only, so an
|
|
2038
|
-
// update-codes rewrite (e.g. "AIEE Nos 72 and 73 - 1932") must not make
|
|
2039
|
-
// a line parse that the reference rejects.
|
|
2040
|
-
function ieeeParseSingleNoCodes(input) {
|
|
2041
|
-
const tree = parseSource(preprocessIeee(input));
|
|
2042
|
-
const builder = new IeeeBuilder();
|
|
2043
|
-
builder.originalInput = input;
|
|
2044
|
-
return builder.build(tree);
|
|
2045
|
-
}
|
|
2046
|
-
// The aiee_simple fallback parses WITHOUT the legacy update-codes table -
|
|
2047
|
-
// the Ruby reference routes "AIEE …" to the AIEE sub-parser only, so an
|
|
2048
|
-
// update-codes rewrite (e.g. "AIEE Nos 72 and 73 - 1932") must not make
|
|
2049
|
-
// a line parse that the reference rejects.
|
|
2050
|
-
function parseAieeDirect(input) {
|
|
2051
|
-
const builder = new IeeeBuilder();
|
|
2052
|
-
builder.originalInput = input;
|
|
2053
|
-
const tree = parseGrammar({ rules: ieeeGrammar.rules, root: "aiee_identifier" }, input);
|
|
2054
|
-
return builder.buildAiee(asHash(tree));
|
|
2055
|
-
}
|
|
2056
|
-
function normalizeIecAdoption(part) {
|
|
2057
|
-
return part
|
|
2058
|
-
.replace(/\s+Edition\s+([0-9.]+)\s+([0-9-]+)/, ":$2 ED$1")
|
|
2059
|
-
.replace(/\s+Edition\s+([0-9.]+)\s*$/, " ED$1");
|
|
2060
|
-
}
|
|
2061
|
-
function buildDual(parts) {
|
|
2062
|
-
const first = ieeeParseSingle(parts[0]);
|
|
2063
|
-
const second = ieeeParseSingle(parts[1]);
|
|
2064
|
-
return new DualPublishedClass({
|
|
2065
|
-
first_identifier: first,
|
|
2066
|
-
second_identifier: second,
|
|
2067
|
-
});
|
|
2068
|
-
}
|
|
2069
|
-
function buildReaffirmed(input, reaffirmed) {
|
|
2070
|
-
const parsed = ieeeParseSingle(input);
|
|
2071
|
-
parsed["reaffirmed"] = reaffirmed;
|
|
2072
|
-
return parsed;
|
|
2073
|
-
}
|
|
2074
|
-
function buildDualWithReaffirmed(parts, reaffirmed) {
|
|
2075
|
-
const ieeeId = ieeeParseSingle(parts[0]);
|
|
2076
|
-
ieeeId["reaffirmed"] = reaffirmed;
|
|
2077
|
-
const ireId = ieeeParseSingle(parts[1]);
|
|
2078
|
-
return new DualPublishedClass({
|
|
2079
|
-
first_identifier: ieeeId,
|
|
2080
|
-
second_identifier: ireId,
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
function parseAdoptedPart(part) {
|
|
2084
|
-
if (part.startsWith("IEC")) {
|
|
2085
|
-
const impl = grammarImplementation("iec");
|
|
2086
|
-
if (impl === undefined)
|
|
2087
|
-
throw new ParseFailed("IEC implementation unavailable", 0);
|
|
2088
|
-
return impl.parse(normalizeIecAdoption(part));
|
|
2089
|
-
}
|
|
2090
|
-
if (part.startsWith("ANSI")) {
|
|
2091
|
-
const impl = grammarImplementation("ansi");
|
|
2092
|
-
if (impl === undefined)
|
|
2093
|
-
throw new ParseFailed("ANSI implementation unavailable", 0);
|
|
2094
|
-
return impl.parse(part);
|
|
2095
|
-
}
|
|
2096
|
-
return ieeeParseSingle(part);
|
|
2097
|
-
}
|
|
2098
|
-
function buildAdopted(parts) {
|
|
2099
|
-
const ieeeId = ieeeParseSingle(parts[0]);
|
|
2100
|
-
const adoptedParts = parts[1].split(",").map((p) => p.trim());
|
|
2101
|
-
const adoptedIds = adoptedParts.map(parseAdoptedPart);
|
|
2102
|
-
const AdoptedClass = AdoptedStandardClass;
|
|
2103
|
-
return new AdoptedClass({
|
|
2104
|
-
ieee_identifier: ieeeId,
|
|
2105
|
-
adopted_identifiers: adoptedIds,
|
|
14
|
+
function nodeEngine() {
|
|
15
|
+
return makeIeeeParseEngine({
|
|
16
|
+
parseAndBind(input) {
|
|
17
|
+
cachedArtifactRuntime ??= PubidRuntime.load("ieee");
|
|
18
|
+
return cachedArtifactRuntime.parseAndBind(input);
|
|
19
|
+
},
|
|
20
|
+
coPublished: (flavor) => grammarImplementation(flavor),
|
|
2106
21
|
});
|
|
2107
22
|
}
|
|
2108
|
-
// A sentinel for "the reference rejects this line outright" - distinct from
|
|
2109
|
-
// ParseFailed so ieeeParse's blanket retry (load-bearing for other forms)
|
|
2110
|
-
// does not resurrect it.
|
|
2111
|
-
class RejectedOutright extends Error {
|
|
2112
|
-
}
|
|
2113
23
|
export function ieeeParse(input) {
|
|
2114
|
-
|
|
2115
|
-
return ieeeParseDispatched(input);
|
|
2116
|
-
}
|
|
2117
|
-
catch (e) {
|
|
2118
|
-
if (e instanceof ParseFailed && !(e instanceof RejectedOutright))
|
|
2119
|
-
return ieeeParseSingle(input);
|
|
2120
|
-
if (e instanceof RejectedOutright)
|
|
2121
|
-
throw new ParseFailed(e.message, 0);
|
|
2122
|
-
throw e;
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
function ieeeParseDispatched(input) {
|
|
2126
|
-
const result = preParse(input);
|
|
2127
|
-
switch (result.dispatch) {
|
|
2128
|
-
case "aiee_simple":
|
|
2129
|
-
// Ruby: Aiee::Identifier.parse, with the WHOLE parse falling back to
|
|
2130
|
-
// parse_single on ParseFailed (forms the AIEE sub-grammar rejects,
|
|
2131
|
-
// e.g. "AIEE 15-May 1928", parse through the generic bucket).
|
|
2132
|
-
try {
|
|
2133
|
-
return parseAieeDirect(result.input);
|
|
2134
|
-
}
|
|
2135
|
-
catch {
|
|
2136
|
-
// Ruby: Aiee::Identifier.parse with no retry - an update-codes
|
|
2137
|
-
// rewrite must not make an AIEE-form line parse that the
|
|
2138
|
-
// reference rejects ("AIEE Nos 72 and 73 - 1932").
|
|
2139
|
-
try {
|
|
2140
|
-
return ieeeParseSingleNoCodes(input);
|
|
2141
|
-
}
|
|
2142
|
-
catch {
|
|
2143
|
-
throw new RejectedOutright(input);
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
case "iec_ieee_copublished":
|
|
2147
|
-
case "dual_semicolon":
|
|
2148
|
-
case "dual_space_separated":
|
|
2149
|
-
if (result.dispatch === "dual_semicolon" || result.dispatch === "dual_space_separated") {
|
|
2150
|
-
return buildDual(result.parts);
|
|
2151
|
-
}
|
|
2152
|
-
try {
|
|
2153
|
-
return ieeeParseSingle(result.input);
|
|
2154
|
-
}
|
|
2155
|
-
catch {
|
|
2156
|
-
return ieeeParseSingle(input);
|
|
2157
|
-
}
|
|
2158
|
-
case "dual_reaffirmed":
|
|
2159
|
-
return buildReaffirmed(result.input, result.metadata["reaffirmed"] ?? "");
|
|
2160
|
-
case "dual_ire":
|
|
2161
|
-
return buildDualWithReaffirmed(result.parts, result.metadata["reaffirmed"] ?? "");
|
|
2162
|
-
case "dual_and":
|
|
2163
|
-
case "dual_ampersand":
|
|
2164
|
-
return buildDual(result.parts);
|
|
2165
|
-
case "aiee_asa_adoption": {
|
|
2166
|
-
const aieeId = ieeeParseSingle(result.parts[0]);
|
|
2167
|
-
const asaId = ieeeParseSingle(result.parts[1]);
|
|
2168
|
-
const AdoptedClass = AdoptedStandardClass;
|
|
2169
|
-
return new AdoptedClass({
|
|
2170
|
-
ieee_identifier: aieeId,
|
|
2171
|
-
adopted_identifiers: [asaId],
|
|
2172
|
-
});
|
|
2173
|
-
}
|
|
2174
|
-
case "adopted":
|
|
2175
|
-
return buildAdopted(result.parts);
|
|
2176
|
-
default:
|
|
2177
|
-
try {
|
|
2178
|
-
return ieeeParseSingle(result.input);
|
|
2179
|
-
}
|
|
2180
|
-
catch {
|
|
2181
|
-
return ieeeParseSingle(input);
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
24
|
+
return ieeeParseImpl(nodeEngine(), input);
|
|
2184
25
|
}
|
|
2185
26
|
export function ieeeGrammarImplementation() {
|
|
2186
|
-
return
|
|
2187
|
-
parse(input) {
|
|
2188
|
-
return ieeeParse(input);
|
|
2189
|
-
},
|
|
2190
|
-
};
|
|
27
|
+
return makeIeeeGrammarImplementation(nodeEngine());
|
|
2191
28
|
}
|