@pubid/pubid 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifact/corpus.json.gz +0 -0
- package/dist/conformance/cli.js +5 -1
- package/dist/flavors/amca/grammar.d.ts +4 -0
- package/dist/flavors/amca/grammar.js +87 -0
- package/dist/flavors/amca/index.d.ts +4 -0
- package/dist/flavors/amca/index.js +76 -0
- package/dist/flavors/amca/model.d.ts +29 -0
- package/dist/flavors/amca/model.js +146 -0
- package/dist/flavors/ansi/index.d.ts +24 -0
- package/dist/flavors/ansi/index.js +147 -0
- package/dist/flavors/api/grammar.d.ts +4 -0
- package/dist/flavors/api/grammar.js +79 -0
- package/dist/flavors/api/index.d.ts +4 -0
- package/dist/flavors/api/index.js +71 -0
- package/dist/flavors/api/model.d.ts +27 -0
- package/dist/flavors/api/model.js +114 -0
- package/dist/flavors/ashrae/grammar.d.ts +2 -0
- package/dist/flavors/ashrae/grammar.js +667 -0
- package/dist/flavors/ashrae/index.d.ts +4 -0
- package/dist/flavors/ashrae/index.js +306 -0
- package/dist/flavors/ashrae/model.d.ts +87 -0
- package/dist/flavors/ashrae/model.js +335 -0
- package/dist/flavors/ashrae/preprocessor.d.ts +7 -0
- package/dist/flavors/ashrae/preprocessor.js +44 -0
- package/dist/flavors/asme/grammar.d.ts +2 -0
- package/dist/flavors/asme/grammar.js +200 -0
- package/dist/flavors/asme/index.d.ts +4 -0
- package/dist/flavors/asme/index.js +138 -0
- package/dist/flavors/asme/model.d.ts +34 -0
- package/dist/flavors/asme/model.js +123 -0
- package/dist/flavors/astm/grammar.d.ts +2 -0
- package/dist/flavors/astm/grammar.js +110 -0
- package/dist/flavors/astm/index.d.ts +2 -0
- package/dist/flavors/astm/index.js +127 -0
- package/dist/flavors/astm/model.d.ts +42 -0
- package/dist/flavors/astm/model.js +263 -0
- package/dist/flavors/bipm/index.d.ts +30 -0
- package/dist/flavors/bipm/index.js +434 -0
- package/dist/flavors/bsi/grammar.d.ts +4 -0
- package/dist/flavors/bsi/grammar.js +535 -0
- package/dist/flavors/bsi/index.d.ts +4 -0
- package/dist/flavors/bsi/index.js +941 -0
- package/dist/flavors/bsi/model.d.ts +127 -0
- package/dist/flavors/bsi/model.js +863 -0
- package/dist/flavors/calconnect/index.d.ts +21 -0
- package/dist/flavors/calconnect/index.js +113 -0
- package/dist/flavors/cen_cenelec/grammar.d.ts +4 -0
- package/dist/flavors/cen_cenelec/grammar.js +107 -0
- package/dist/flavors/cen_cenelec/index.d.ts +5 -0
- package/dist/flavors/cen_cenelec/index.js +263 -0
- package/dist/flavors/cen_cenelec/model.d.ts +45 -0
- package/dist/flavors/cen_cenelec/model.js +490 -0
- package/dist/flavors/cie/grammar.d.ts +5 -0
- package/dist/flavors/cie/grammar.js +127 -0
- package/dist/flavors/cie/index.d.ts +2 -0
- package/dist/flavors/cie/index.js +311 -0
- package/dist/flavors/cie/model.d.ts +122 -0
- package/dist/flavors/cie/model.js +464 -0
- package/dist/flavors/csa/grammar.d.ts +6 -0
- package/dist/flavors/csa/grammar.js +239 -0
- package/dist/flavors/csa/index.d.ts +2 -0
- package/dist/flavors/csa/index.js +634 -0
- package/dist/flavors/csa/model.d.ts +33 -0
- package/dist/flavors/csa/model.js +505 -0
- package/dist/flavors/doi/index.d.ts +13 -0
- package/dist/flavors/doi/index.js +65 -0
- package/dist/flavors/easc/index.d.ts +4 -0
- package/dist/flavors/easc/index.js +107 -0
- package/dist/flavors/ecma/index.d.ts +4 -0
- package/dist/flavors/ecma/index.js +117 -0
- package/dist/flavors/etsi/index.d.ts +14 -0
- package/dist/flavors/etsi/index.js +307 -0
- package/dist/flavors/evs/grammar.d.ts +2 -0
- package/dist/flavors/evs/grammar.js +22 -0
- package/dist/flavors/evs/index.d.ts +2 -0
- package/dist/flavors/evs/index.js +24 -0
- package/dist/flavors/evs/model.d.ts +19 -0
- package/dist/flavors/evs/model.js +36 -0
- package/dist/flavors/gb/index.d.ts +31 -0
- package/dist/flavors/gb/index.js +159 -0
- package/dist/flavors/gost/grammar.d.ts +2 -0
- package/dist/flavors/gost/grammar.js +46 -0
- package/dist/flavors/gost/index.d.ts +2 -0
- package/dist/flavors/gost/index.js +165 -0
- package/dist/flavors/gost/model.d.ts +61 -0
- package/dist/flavors/gost/model.js +147 -0
- package/dist/flavors/gost/prefix_routes.d.ts +15 -0
- package/dist/flavors/gost/prefix_routes.js +192 -0
- package/dist/flavors/iala/index.d.ts +32 -0
- package/dist/flavors/iala/index.js +300 -0
- package/dist/flavors/iana/index.d.ts +19 -0
- package/dist/flavors/iana/index.js +71 -0
- package/dist/flavors/idf/grammar.d.ts +2 -0
- package/dist/flavors/idf/grammar.js +71 -0
- package/dist/flavors/idf/index.d.ts +2 -0
- package/dist/flavors/idf/index.js +100 -0
- package/dist/flavors/idf/model.d.ts +54 -0
- package/dist/flavors/idf/model.js +359 -0
- package/dist/flavors/iec/grammar.d.ts +3 -0
- package/dist/flavors/iec/grammar.js +187 -0
- package/dist/flavors/iec/index.d.ts +4 -0
- package/dist/flavors/iec/index.js +507 -0
- package/dist/flavors/iec/model.d.ts +54 -0
- package/dist/flavors/iec/model.js +437 -0
- package/dist/flavors/ieee/grammar.d.ts +2 -0
- package/dist/flavors/ieee/grammar.js +697 -0
- package/dist/flavors/ieee/index.d.ts +3 -0
- package/dist/flavors/ieee/index.js +1258 -0
- package/dist/flavors/ieee/model.d.ts +144 -0
- package/dist/flavors/ieee/model.js +1237 -0
- package/dist/flavors/ieee/preprocessor.d.ts +8 -0
- package/dist/flavors/ieee/preprocessor.js +410 -0
- package/dist/flavors/ieee/update_codes.d.ts +8 -0
- package/dist/flavors/ieee/update_codes.js +197 -0
- package/dist/flavors/ietf/index.d.ts +30 -0
- package/dist/flavors/ietf/index.js +151 -0
- package/dist/flavors/iho/index.d.ts +4 -0
- package/dist/flavors/iho/index.js +126 -0
- package/dist/flavors/index.d.ts +9 -0
- package/dist/flavors/index.js +136 -0
- package/dist/flavors/isbn/index.d.ts +13 -0
- package/dist/flavors/isbn/index.js +97 -0
- package/dist/flavors/iso/grammar.d.ts +2 -0
- package/dist/flavors/iso/grammar.js +207 -0
- package/dist/flavors/iso/index.d.ts +2 -0
- package/dist/flavors/iso/index.js +343 -0
- package/dist/flavors/iso/model.d.ts +159 -0
- package/dist/flavors/iso/model.js +802 -0
- package/dist/flavors/iso/stages.generated.d.ts +13 -0
- package/dist/flavors/iso/stages.generated.js +391 -0
- package/dist/flavors/itu/grammar.d.ts +4 -0
- package/dist/flavors/itu/grammar.js +205 -0
- package/dist/flavors/itu/index.d.ts +2 -0
- package/dist/flavors/itu/index.js +224 -0
- package/dist/flavors/itu/model.d.ts +184 -0
- package/dist/flavors/itu/model.js +599 -0
- package/dist/flavors/jcgm/index.d.ts +7 -0
- package/dist/flavors/jcgm/index.js +300 -0
- package/dist/flavors/jis/index.d.ts +4 -0
- package/dist/flavors/jis/index.js +267 -0
- package/dist/flavors/nist/grammar.d.ts +2 -0
- package/dist/flavors/nist/grammar.js +287 -0
- package/dist/flavors/nist/index.d.ts +2 -0
- package/dist/flavors/nist/index.js +1244 -0
- package/dist/flavors/nist/model.d.ts +155 -0
- package/dist/flavors/nist/model.js +823 -0
- package/dist/flavors/nist/preprocessor.d.ts +11 -0
- package/dist/flavors/nist/preprocessor.js +281 -0
- package/dist/flavors/oasis/index.d.ts +23 -0
- package/dist/flavors/oasis/index.js +110 -0
- package/dist/flavors/ogc/index.d.ts +20 -0
- package/dist/flavors/ogc/index.js +75 -0
- package/dist/flavors/oiml/grammar.d.ts +2 -0
- package/dist/flavors/oiml/grammar.js +206 -0
- package/dist/flavors/oiml/implementation.d.ts +9 -0
- package/dist/flavors/oiml/implementation.js +45 -0
- package/dist/flavors/oiml/model.d.ts +23 -0
- package/dist/flavors/oiml/model.js +592 -0
- package/dist/flavors/omg/index.d.ts +14 -0
- package/dist/flavors/omg/index.js +73 -0
- package/dist/flavors/plateau/index.d.ts +4 -0
- package/dist/flavors/plateau/index.js +97 -0
- package/dist/flavors/tgpp/index.d.ts +4 -0
- package/dist/flavors/tgpp/index.js +122 -0
- package/dist/flavors/un/index.d.ts +13 -0
- package/dist/flavors/un/index.js +90 -0
- package/dist/flavors/w3c/index.d.ts +14 -0
- package/dist/flavors/w3c/index.js +148 -0
- package/dist/flavors/xsf/index.d.ts +18 -0
- package/dist/flavors/xsf/index.js +65 -0
- package/dist/grammar/engine.d.ts +78 -0
- package/dist/grammar/engine.js +351 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/model/attribute.d.ts +54 -0
- package/dist/model/attribute.js +53 -0
- package/dist/model/builder.d.ts +39 -0
- package/dist/model/builder.js +124 -0
- package/dist/model/component.d.ts +70 -0
- package/dist/model/component.js +170 -0
- package/dist/model/identifier.d.ts +84 -0
- package/dist/model/identifier.js +270 -0
- package/dist/model/urn-generator.d.ts +27 -0
- package/dist/model/urn-generator.js +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { ParseFailed, parseGrammar } from "../../grammar/engine.js";
|
|
2
|
+
import { PubidDate } from "../../model/component.js";
|
|
3
|
+
import { ituGrammar, normalizeWhitespaceItu } from "./grammar.js";
|
|
4
|
+
import { ITU_CLASSES, ITU_LANGUAGES, ItuCode, ItuDesignation, } from "./model.js";
|
|
5
|
+
/**
|
|
6
|
+
* Port of lib/pubid/itu/builder.rb — the exact dispatch order:
|
|
7
|
+
* annex_to → annex_number → appendix_number → OB/_op_bull →
|
|
8
|
+
* supplement_type → handbook_marker → study_group → contribution →
|
|
9
|
+
* combined → report/recommendation.
|
|
10
|
+
*/
|
|
11
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12
|
+
const s = (v) => v === undefined || v === null ? undefined : String(v);
|
|
13
|
+
function flatten(data) {
|
|
14
|
+
return Array.isArray(data) ? Object.assign({}, ...data) : data;
|
|
15
|
+
}
|
|
16
|
+
function extractParts(raw) {
|
|
17
|
+
if (Array.isArray(raw)) {
|
|
18
|
+
return raw.map((p) => (isObj(p) ? String(p["part"]) : String(p)));
|
|
19
|
+
}
|
|
20
|
+
if (isObj(raw) && raw["part"] !== undefined)
|
|
21
|
+
return [String(raw["part"])];
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const normLanguage = (v) => {
|
|
25
|
+
const raw = s(v);
|
|
26
|
+
if (raw === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
return ITU_LANGUAGES[raw] ?? raw;
|
|
29
|
+
};
|
|
30
|
+
class ItuBuilder {
|
|
31
|
+
build(data) {
|
|
32
|
+
const tree = flatten(data);
|
|
33
|
+
// The common-text twin ("| ISO/IEC …") is stored as the stripped
|
|
34
|
+
// string (Ruby parses it cross-flavor; no ISO parser exists in the
|
|
35
|
+
// TS mirror yet, and no corpus row carries one).
|
|
36
|
+
const twinRaw = s(tree["common_text_twin"])?.replace(/^\s*\|\s*/, "");
|
|
37
|
+
const twin = twinRaw === "" ? undefined : twinRaw;
|
|
38
|
+
if (tree["annex_to"] !== undefined)
|
|
39
|
+
return this.buildAnnexTo(tree["annex_to"]);
|
|
40
|
+
if (tree["annex_number"] !== undefined) {
|
|
41
|
+
return this.withTwin(this.buildAnnexOfRecommendation(tree), twin);
|
|
42
|
+
}
|
|
43
|
+
if (tree["appendix_number"] !== undefined) {
|
|
44
|
+
return this.withTwin(this.buildAppendixOfRecommendation(tree), twin);
|
|
45
|
+
}
|
|
46
|
+
if ((s(tree["series"]) === "OB" && tree["series_dash"] === undefined) || tree["_op_bull"] !== undefined) {
|
|
47
|
+
return this.withTwin(this.buildSpecialPublication(tree), twin);
|
|
48
|
+
}
|
|
49
|
+
if (tree["supplement_type"] !== undefined) {
|
|
50
|
+
return this.withTwin(this.buildSupplement(tree), twin);
|
|
51
|
+
}
|
|
52
|
+
if (tree["handbook_marker"] !== undefined)
|
|
53
|
+
return this.buildHandbook(tree);
|
|
54
|
+
if (tree["study_group"] !== undefined)
|
|
55
|
+
return this.buildQuestion(tree);
|
|
56
|
+
if (tree["contribution_marker"] !== undefined)
|
|
57
|
+
return this.buildContribution(tree);
|
|
58
|
+
const code = tree["number"] !== undefined ? this.buildCode(tree) : undefined;
|
|
59
|
+
const date = tree["year"] !== undefined ? this.buildDate(tree) : undefined;
|
|
60
|
+
const common = {
|
|
61
|
+
sector: s(tree["sector"]),
|
|
62
|
+
series: s(tree["series"]),
|
|
63
|
+
code,
|
|
64
|
+
date,
|
|
65
|
+
version: s(tree["version"]),
|
|
66
|
+
series_word: tree["series_word"] !== undefined,
|
|
67
|
+
series_dash: tree["series_dash"] !== undefined,
|
|
68
|
+
attachment: tree["attachment"] !== undefined,
|
|
69
|
+
range_end: s(tree["range_end"]),
|
|
70
|
+
language: normLanguage(tree["language"]),
|
|
71
|
+
common_text_twin: twin,
|
|
72
|
+
};
|
|
73
|
+
if (tree["combined"] !== undefined) {
|
|
74
|
+
return new ITU_CLASSES["combined"]({
|
|
75
|
+
...common,
|
|
76
|
+
combined: this.buildDesignations(tree["combined"]),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const klass = tree["report_marker"] !== undefined ? ITU_CLASSES["report"] : ITU_CLASSES["recommendation"];
|
|
80
|
+
return new klass({ ...common });
|
|
81
|
+
}
|
|
82
|
+
withTwin(identifier, twin) {
|
|
83
|
+
if (twin !== undefined) {
|
|
84
|
+
identifier["common_text_twin"] = twin;
|
|
85
|
+
}
|
|
86
|
+
return identifier;
|
|
87
|
+
}
|
|
88
|
+
buildCode(tree) {
|
|
89
|
+
return new ItuCode({
|
|
90
|
+
imp_marker: s(tree["imp_marker"]),
|
|
91
|
+
number: s(tree["number"]),
|
|
92
|
+
series_suffix: s(tree["series_suffix"]),
|
|
93
|
+
series_suffix_spaced: tree["series_suffix_spaced"] !== undefined,
|
|
94
|
+
subseries: s(tree["subseries"]),
|
|
95
|
+
parts: extractParts(tree["parts"]),
|
|
96
|
+
qualifier: s(tree["qualifier"]),
|
|
97
|
+
qualifier_glued: tree["qualifier"] !== undefined && tree["qualifier_spaced"] === undefined,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
buildDate(tree) {
|
|
101
|
+
return new PubidDate({ year: s(tree["year"]), month: s(tree["month"]) });
|
|
102
|
+
}
|
|
103
|
+
/** OB is cross-bureau — the sector of legacy strings is dropped. */
|
|
104
|
+
buildSpecialPublication(tree) {
|
|
105
|
+
return new ITU_CLASSES["special_publication"]({
|
|
106
|
+
series: "OB",
|
|
107
|
+
code: tree["number"] !== undefined ? this.buildCode(tree) : undefined,
|
|
108
|
+
date: tree["year"] !== undefined ? this.buildDate(tree) : undefined,
|
|
109
|
+
language: normLanguage(tree["language"]),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
buildAnnexTo(inner) {
|
|
113
|
+
const data = flatten(inner);
|
|
114
|
+
const base = this.buildSpecialPublication(data);
|
|
115
|
+
return new ITU_CLASSES["annex_to"]({
|
|
116
|
+
base,
|
|
117
|
+
language: normLanguage(data["language"]),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/** sector/series/code are deliberately NOT copied from the base. */
|
|
121
|
+
buildAnnexOfRecommendation(tree) {
|
|
122
|
+
return new ITU_CLASSES["annex_of"]({
|
|
123
|
+
base: this.build(tree["base"]),
|
|
124
|
+
number: s(tree["annex_number"]),
|
|
125
|
+
date: tree["year"] !== undefined ? this.buildDate(tree) : undefined,
|
|
126
|
+
language: normLanguage(tree["language"]),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
buildAppendixOfRecommendation(tree) {
|
|
130
|
+
return new ITU_CLASSES["appendix_of"]({
|
|
131
|
+
base: this.build(tree["base"]),
|
|
132
|
+
number: s(tree["appendix_number"]),
|
|
133
|
+
material: s(tree["appendix_material"]),
|
|
134
|
+
date: tree["year"] !== undefined ? this.buildDate(tree) : undefined,
|
|
135
|
+
language: normLanguage(tree["language"]),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
buildHandbook(tree) {
|
|
139
|
+
return new ITU_CLASSES["handbook"]({
|
|
140
|
+
sector: s(tree["sector"]),
|
|
141
|
+
code: this.buildCode(tree),
|
|
142
|
+
date: tree["year"] !== undefined ? this.buildDate(tree) : undefined,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
buildQuestion(tree) {
|
|
146
|
+
return new ITU_CLASSES["question"]({
|
|
147
|
+
sector: s(tree["sector"]),
|
|
148
|
+
series: s(tree["series"]),
|
|
149
|
+
code: this.buildCode(tree),
|
|
150
|
+
study_group: s(tree["study_group"]),
|
|
151
|
+
has_bl: tree["has_bl"] !== undefined,
|
|
152
|
+
bracketed: tree["bracketed"] !== undefined,
|
|
153
|
+
has_colon: tree["question_colon"] !== undefined,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
buildContribution(tree) {
|
|
157
|
+
return new ITU_CLASSES["contribution"]({
|
|
158
|
+
sector: s(tree["sector"]),
|
|
159
|
+
series: s(tree["series"]),
|
|
160
|
+
code: this.buildCode(tree),
|
|
161
|
+
language: normLanguage(tree["language"]),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
buildDesignations(combined) {
|
|
165
|
+
const list = Array.isArray(combined) ? combined : [combined];
|
|
166
|
+
return list.map((element) => {
|
|
167
|
+
const d = isObj(element) && element["designation"] !== undefined ? flatten(element["designation"]) : isObj(element) ? element : {};
|
|
168
|
+
return new ItuDesignation({
|
|
169
|
+
series: s(d["series"]),
|
|
170
|
+
code: new ItuCode({
|
|
171
|
+
number: s(d["number"]),
|
|
172
|
+
series_suffix: s(d["series_suffix"]),
|
|
173
|
+
series_suffix_spaced: d["series_suffix_spaced"] !== undefined,
|
|
174
|
+
subseries: s(d["subseries"]),
|
|
175
|
+
parts: extractParts(d["parts"]),
|
|
176
|
+
qualifier: s(d["qualifier"]),
|
|
177
|
+
qualifier_glued: d["qualifier"] !== undefined && d["qualifier_spaced"] === undefined,
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
buildSupplement(tree) {
|
|
183
|
+
const base = tree["base"] !== undefined ? this.build(tree["base"]) : undefined;
|
|
184
|
+
const token = (s(tree["supplement_type"]) ?? "").replace(".", "");
|
|
185
|
+
const kind = { Amd: "amendment", Add: "addendum", Cor: "corrigendum", Err: "errata", Suppl: "supplement" }[token];
|
|
186
|
+
if (kind === undefined)
|
|
187
|
+
throw new ParseFailed(`ITU: unknown supplement type ${token}`, 0);
|
|
188
|
+
const date = tree["supplement_year"] !== undefined
|
|
189
|
+
? new PubidDate({ year: s(tree["supplement_year"]), month: s(tree["supplement_month"]) })
|
|
190
|
+
: undefined;
|
|
191
|
+
// An annex base keeps sector/series/code on ITS base — reach
|
|
192
|
+
// through it via root, or a supplement of an annex carries none.
|
|
193
|
+
const baseAsIdu = base;
|
|
194
|
+
const baseIdentity = baseAsIdu !== undefined ? (baseAsIdu.sector !== undefined ? baseAsIdu : baseAsIdu.root()) : undefined;
|
|
195
|
+
const attrs = {
|
|
196
|
+
sector: baseIdentity?.sector ?? s(tree["sector"]),
|
|
197
|
+
series: baseIdentity?.series ?? s(tree["series"]),
|
|
198
|
+
code: baseIdentity?.code,
|
|
199
|
+
base,
|
|
200
|
+
number: s(tree["supplement_number"]),
|
|
201
|
+
// The captured space marks the SPACED ordinal; absence = glued.
|
|
202
|
+
number_glued: tree["supplement_space"] === undefined,
|
|
203
|
+
slash_joined: tree["supplement_slash"] !== undefined,
|
|
204
|
+
date,
|
|
205
|
+
language: normLanguage(tree["language"]),
|
|
206
|
+
series_word: base !== undefined ? baseIdentity?.series_word === true : tree["series_word"] !== undefined,
|
|
207
|
+
};
|
|
208
|
+
if (tree["technical"] !== undefined && kind === "corrigendum")
|
|
209
|
+
attrs["technical"] = true;
|
|
210
|
+
return new ITU_CLASSES[kind](attrs);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export function ituGrammarImplementation() {
|
|
214
|
+
const builder = new ItuBuilder();
|
|
215
|
+
return {
|
|
216
|
+
parse(input) {
|
|
217
|
+
const tree = parseGrammar(ituGrammar, normalizeWhitespaceItu(input));
|
|
218
|
+
if (typeof tree !== "object" || tree === null) {
|
|
219
|
+
throw new ParseFailed("ITU: unexpected parse tree", 0);
|
|
220
|
+
}
|
|
221
|
+
return builder.build(tree);
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { BaseIdentifier } from "../../model/identifier.js";
|
|
2
|
+
import { type FieldMapping } from "../../model/attribute.js";
|
|
3
|
+
import { PubidDate } from "../../model/component.js";
|
|
4
|
+
import { BaseUrnGenerator } from "../../model/urn-generator.js";
|
|
5
|
+
import { Component } from "../../model/component.js";
|
|
6
|
+
/**
|
|
7
|
+
* Port of lib/pubid/itu/identifiers/* + components/{code,designation}.rb.
|
|
8
|
+
* The wire hash is FLAT (StandardSerialization / the Supplement block):
|
|
9
|
+
* sector/series/number/parts/… are bare top-level scalars read through
|
|
10
|
+
* the ItuCode component; publisher ("ITU") is never serialized
|
|
11
|
+
* (reconstructed on render).
|
|
12
|
+
*/
|
|
13
|
+
/** Long-form ↔ single-letter language map (Identifiers::Base::LANGUAGES). */
|
|
14
|
+
export declare const ITU_LANGUAGES: Record<string, string>;
|
|
15
|
+
/** The ITU Code component (Components::Code): [Imp]NUMBER[suffix][.subseries][-parts][qualifier]. */
|
|
16
|
+
export declare class ItuCode extends Component {
|
|
17
|
+
readonly imp_marker?: string | undefined;
|
|
18
|
+
readonly number?: string | undefined;
|
|
19
|
+
readonly series_suffix?: string | undefined;
|
|
20
|
+
readonly series_suffix_spaced: boolean;
|
|
21
|
+
readonly subseries?: string | undefined;
|
|
22
|
+
readonly parts: string[];
|
|
23
|
+
readonly qualifier?: string | undefined;
|
|
24
|
+
readonly qualifier_glued: boolean;
|
|
25
|
+
constructor(attrs: Record<string, unknown>);
|
|
26
|
+
render(): string;
|
|
27
|
+
/** Space-free form for URN/MR — keeps "D.200" and "D.200 R" distinct. */
|
|
28
|
+
compactS(): string;
|
|
29
|
+
toWire(): Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/** One "/SERIES.CODE" joint designation (Components::Designation). */
|
|
32
|
+
export declare class ItuDesignation extends Component {
|
|
33
|
+
readonly series?: string | undefined;
|
|
34
|
+
readonly code: ItuCode;
|
|
35
|
+
constructor(attrs: Record<string, unknown>);
|
|
36
|
+
render(): string;
|
|
37
|
+
toWire(): Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export declare abstract class ItuIdentifier extends BaseIdentifier {
|
|
40
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
41
|
+
readonly sector: string | undefined;
|
|
42
|
+
readonly series: string | undefined;
|
|
43
|
+
readonly code: ItuCode | undefined;
|
|
44
|
+
readonly date: PubidDate | undefined;
|
|
45
|
+
readonly language: string | undefined;
|
|
46
|
+
readonly version: string | undefined;
|
|
47
|
+
readonly series_word: boolean | undefined;
|
|
48
|
+
readonly series_dash: boolean | undefined;
|
|
49
|
+
readonly attachment: boolean | undefined;
|
|
50
|
+
readonly range_end: string | undefined;
|
|
51
|
+
readonly common_text_twin: string | undefined;
|
|
52
|
+
/** Walks `base` to the origin document (Pubid::Identifier#root). */
|
|
53
|
+
root(): ItuIdentifier;
|
|
54
|
+
/** " (M/YYYY)" / " (YYYY)" / "" — shared by every dated ITU type. */
|
|
55
|
+
dateSuffix(): string;
|
|
56
|
+
languageSuffix(): string;
|
|
57
|
+
twinSuffix(): string;
|
|
58
|
+
renderBase(): string;
|
|
59
|
+
render(): string;
|
|
60
|
+
}
|
|
61
|
+
export declare class ItuUrnGenerator extends BaseUrnGenerator<ItuIdentifier> {
|
|
62
|
+
generate(): string;
|
|
63
|
+
generateBaseUrn(id: ItuIdentifier): string;
|
|
64
|
+
generateSupplementUrn(id: ItuSupplement): string;
|
|
65
|
+
}
|
|
66
|
+
export declare class ItuRecommendation extends ItuIdentifier {
|
|
67
|
+
static polymorphicName: string;
|
|
68
|
+
static mappings: FieldMapping[];
|
|
69
|
+
}
|
|
70
|
+
export declare class ItuReport extends ItuIdentifier {
|
|
71
|
+
static polymorphicName: string;
|
|
72
|
+
static mappings: FieldMapping[];
|
|
73
|
+
renderBase(): string;
|
|
74
|
+
}
|
|
75
|
+
export declare class ItuHandbook extends ItuIdentifier {
|
|
76
|
+
static polymorphicName: string;
|
|
77
|
+
static mappings: FieldMapping[];
|
|
78
|
+
renderBase(): string;
|
|
79
|
+
}
|
|
80
|
+
export declare class ItuSpecialPublication extends ItuIdentifier {
|
|
81
|
+
static polymorphicName: string;
|
|
82
|
+
static mappings: FieldMapping[];
|
|
83
|
+
renderBase(): string;
|
|
84
|
+
}
|
|
85
|
+
export declare class ItuContribution extends ItuIdentifier {
|
|
86
|
+
static polymorphicName: string;
|
|
87
|
+
static mappings: FieldMapping[];
|
|
88
|
+
renderBase(): string;
|
|
89
|
+
}
|
|
90
|
+
export declare class ItuQuestion extends ItuIdentifier {
|
|
91
|
+
static polymorphicName: string;
|
|
92
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
93
|
+
static mappings: FieldMapping[];
|
|
94
|
+
readonly study_group: string | undefined;
|
|
95
|
+
readonly has_bl: boolean | undefined;
|
|
96
|
+
readonly bracketed: boolean | undefined;
|
|
97
|
+
readonly has_colon: boolean | undefined;
|
|
98
|
+
renderBase(): string;
|
|
99
|
+
}
|
|
100
|
+
export declare class ItuCombinedIdentifier extends ItuIdentifier {
|
|
101
|
+
static polymorphicName: string;
|
|
102
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
103
|
+
static mappings: FieldMapping[];
|
|
104
|
+
readonly combined: ItuDesignation[];
|
|
105
|
+
renderBase(): string;
|
|
106
|
+
}
|
|
107
|
+
export declare abstract class ItuSupplement extends ItuIdentifier {
|
|
108
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
109
|
+
readonly base: ItuIdentifier | undefined;
|
|
110
|
+
readonly number: string | undefined;
|
|
111
|
+
readonly number_glued: boolean | undefined;
|
|
112
|
+
readonly slash_joined: boolean | undefined;
|
|
113
|
+
renderSupplement(label: string): string;
|
|
114
|
+
}
|
|
115
|
+
export declare class ItuSupplementSuppl extends ItuSupplement {
|
|
116
|
+
static polymorphicName: string;
|
|
117
|
+
static mappings: FieldMapping[];
|
|
118
|
+
render(): string;
|
|
119
|
+
}
|
|
120
|
+
export declare class ItuAmendment extends ItuSupplement {
|
|
121
|
+
static polymorphicName: string;
|
|
122
|
+
static mappings: FieldMapping[];
|
|
123
|
+
render(): string;
|
|
124
|
+
}
|
|
125
|
+
export declare class ItuAddendum extends ItuSupplement {
|
|
126
|
+
static polymorphicName: string;
|
|
127
|
+
static mappings: FieldMapping[];
|
|
128
|
+
render(): string;
|
|
129
|
+
}
|
|
130
|
+
export declare class ItuErrata extends ItuSupplement {
|
|
131
|
+
static polymorphicName: string;
|
|
132
|
+
static mappings: FieldMapping[];
|
|
133
|
+
render(): string;
|
|
134
|
+
}
|
|
135
|
+
export declare class ItuCorrigendum extends ItuSupplement {
|
|
136
|
+
static polymorphicName: string;
|
|
137
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
138
|
+
static mappings: FieldMapping[];
|
|
139
|
+
readonly technical: boolean | undefined;
|
|
140
|
+
render(): string;
|
|
141
|
+
}
|
|
142
|
+
export declare class ItuAnnexOfRecommendation extends ItuIdentifier {
|
|
143
|
+
static polymorphicName: string;
|
|
144
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
145
|
+
static mappings: FieldMapping[];
|
|
146
|
+
readonly base: ItuIdentifier | undefined;
|
|
147
|
+
readonly number: string | undefined;
|
|
148
|
+
renderBase(): string;
|
|
149
|
+
}
|
|
150
|
+
export declare class ItuAppendixOfRecommendation extends ItuIdentifier {
|
|
151
|
+
static polymorphicName: string;
|
|
152
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
153
|
+
static mappings: FieldMapping[];
|
|
154
|
+
readonly base: ItuIdentifier | undefined;
|
|
155
|
+
readonly number: string | undefined;
|
|
156
|
+
readonly material: string | undefined;
|
|
157
|
+
renderBase(): string;
|
|
158
|
+
}
|
|
159
|
+
export declare class ItuAnnex extends ItuIdentifier {
|
|
160
|
+
static polymorphicName: string;
|
|
161
|
+
static attributes: import("../../model/attribute.js").AttributeTable;
|
|
162
|
+
static mappings: FieldMapping[];
|
|
163
|
+
readonly base: ItuIdentifier | undefined;
|
|
164
|
+
renderBase(): string;
|
|
165
|
+
}
|
|
166
|
+
/** The builder's class table (kind token → class). */
|
|
167
|
+
export declare const ITU_CLASSES: {
|
|
168
|
+
readonly recommendation: typeof ItuRecommendation;
|
|
169
|
+
readonly report: typeof ItuReport;
|
|
170
|
+
readonly handbook: typeof ItuHandbook;
|
|
171
|
+
readonly special_publication: typeof ItuSpecialPublication;
|
|
172
|
+
readonly contribution: typeof ItuContribution;
|
|
173
|
+
readonly question: typeof ItuQuestion;
|
|
174
|
+
readonly combined: typeof ItuCombinedIdentifier;
|
|
175
|
+
readonly supplement: typeof ItuSupplementSuppl;
|
|
176
|
+
readonly amendment: typeof ItuAmendment;
|
|
177
|
+
readonly addendum: typeof ItuAddendum;
|
|
178
|
+
readonly errata: typeof ItuErrata;
|
|
179
|
+
readonly corrigendum: typeof ItuCorrigendum;
|
|
180
|
+
readonly annex_of: typeof ItuAnnexOfRecommendation;
|
|
181
|
+
readonly appendix_of: typeof ItuAppendixOfRecommendation;
|
|
182
|
+
readonly annex_to: typeof ItuAnnex;
|
|
183
|
+
};
|
|
184
|
+
export type ItuKind = keyof typeof ITU_CLASSES;
|