@pubid/pubid 0.1.59 → 0.1.61

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 CHANGED
@@ -25,7 +25,7 @@ consumed here at a **pinned ref** and are never edited from this repo.
25
25
 
26
26
  ## Status
27
27
 
28
- **All 42 flavors supported in corpus mode.** The pubid-testsuite corpus is
28
+ **All 46 flavors supported in corpus mode.** The pubid-testsuite corpus is
29
29
  a **closed universe**: every canonical spelling, canonical hash and URN,
30
30
  plus every attested non-normalized alias. pubid-ts resolves and normalizes
31
31
  any identifier IN that universe, and nothing outside it:
@@ -84,12 +84,12 @@ package — though it still uses Node's `fs`/`zlib` to read it, so
84
84
  browser runtimes remain out of scope.
85
85
 
86
86
  The conformance gate enforces corpus mode over the whole testsuite on
87
- every CI run: 42/42 flavors, canonical hash, human form, URN, alias
87
+ every CI run: 46/46 flavors, canonical hash, human form, URN, alias
88
88
  normalization, negative rejection and deserialize idempotency.
89
89
 
90
90
  ## Grammar mode: open-universe runtime parsing
91
91
 
92
- All 42 flavors are grammar-backed and ship the wave plan end to end
92
+ All 46 flavors are grammar-backed and ship the wave plan end to end
93
93
  (core model → parser engine → builder → normalizer → renderer → urn →
94
94
  per-flavor grammars). Grammar implementations parse real-world
95
95
  identifiers far beyond the published corpus — novel spellings, unseen
Binary file
@@ -10,7 +10,9 @@ export * from "./model.js";
10
10
  * Pubid::Eu::Builder: CELEX and ELI fix year/number by position, the
11
11
  * canonical and Official-Journal forms carry two numbers whose ORDER is
12
12
  * not in the grammar (number_first_for), and the renderer's "No"
13
- * disambiguation lives on the model (EuIdentifier#numbers).
13
+ * disambiguation lives on the model (EuIdentifier#numbers). The ELI
14
+ * subtype ("reg_impl") is stripped before the grammar and carried as an
15
+ * equality-ignored facet, as Identifier.bound_without_subtype does.
14
16
  */
15
17
  // --- Builder (lib/pubid/eu/builder.rb) ---------------------------------------
16
18
  const TYPES_BY_WORD = {
@@ -34,6 +36,27 @@ const s = (v) => {
34
36
  const text = String(v);
35
37
  return text.length > 0 ? text : undefined;
36
38
  };
39
+ // The subtypes CELLAR gives each ELI type: implementing and delegated
40
+ // acts of every type, and the financial regulation (Identifier::
41
+ // ELI_SUBTYPES).
42
+ const ELI_SUBTYPES = {
43
+ reg: ["impl", "del", "financ"],
44
+ dir: ["impl", "del"],
45
+ dec: ["impl", "del"],
46
+ };
47
+ // The subtype of an ELI input, removed before the baked grammar (which
48
+ // knows only reg/dir/dec), as BSI and IETF strip their prefixes
49
+ // (Identifier::ELI_SUBTYPE).
50
+ const ELI_SUBTYPE = /^(https?:\/\/data\.europa\.eu\/eli\/(reg|dir|dec))_([a-z]+)\//;
51
+ /** A known subtype of a known ELI type, or undefined. An unknown one
52
+ * stays in the input, so the grammar rejects it. */
53
+ function eliSubtype(identifier) {
54
+ const match = ELI_SUBTYPE.exec(identifier);
55
+ if (match === null)
56
+ return undefined;
57
+ const subtype = match[3];
58
+ return (ELI_SUBTYPES[match[2]] ?? []).includes(subtype) ? subtype : undefined;
59
+ }
37
60
  function positional(data) {
38
61
  const letter = s(data["celex_letter"]);
39
62
  const eli = s(data["eli_type"]);
@@ -77,7 +100,7 @@ function family(data) {
77
100
  }
78
101
  return bracket ?? suffix;
79
102
  }
80
- function buildEu(data) {
103
+ function buildEu(data, subtype) {
81
104
  const act = positional(data) ?? fromPair(data);
82
105
  if (!isPlausibleYear(act.year)) {
83
106
  throw new Error(`EU legal act: ${act.year} is not a year`);
@@ -86,10 +109,12 @@ function buildEu(data) {
86
109
  if (number === "0") {
87
110
  throw new Error("EU legal act: number 0");
88
111
  }
112
+ const fam = family(data);
89
113
  const id = new act.klass({
90
114
  number,
91
115
  date: { year: act.year },
92
- ...(family(data) !== undefined ? { family: family(data) } : {}),
116
+ ...(fam !== undefined ? { family: fam } : {}),
117
+ ...(subtype !== undefined ? { subtype } : {}),
93
118
  });
94
119
  // Keep the order only when it is not what the render rule prints.
95
120
  if (act.numberFirst !== undefined && act.numberFirst !== id.defaultNumberFirst()) {
@@ -103,11 +128,18 @@ export function euGrammarImplementation() {
103
128
  return {
104
129
  parse(input) {
105
130
  cachedRuntime ??= PubidRuntime.load("eu");
106
- const bound = cachedRuntime.parseAndBind(input);
131
+ // An ELI subtype ("reg_impl") is stripped before the grammar, as
132
+ // the reference's bound_without_subtype does; the subtype rides
133
+ // the build as an equality-ignored facet.
134
+ const subtype = eliSubtype(input);
135
+ const stripped = subtype !== undefined
136
+ ? input.replace(ELI_SUBTYPE, "$1/")
137
+ : input;
138
+ const bound = cachedRuntime.parseAndBind(stripped);
107
139
  if (bound === null || typeof bound !== "object") {
108
140
  throw new ParseFailed("eu: the artifact rejected the input", 0);
109
141
  }
110
- return buildEu(bound);
142
+ return buildEu(bound, subtype);
111
143
  },
112
144
  };
113
145
  }
@@ -14,6 +14,13 @@ import type { PubidDate } from "../../model/component.js";
14
14
  * `number_first` is the print ORDER of the two numbers — spelling, not
15
15
  * identity: it serializes but `==` skips it (equality_ignored), so
16
16
  * "EU Decision 1082/2013" equals the CELEX number 32013D1082.
17
+ * `subtype` is the ELI type subtype ("impl" implementing act, "del"
18
+ * delegated act, "financ" financial regulation) from an ELI such as
19
+ * http://data.europa.eu/eli/reg_impl/2016/1356/oj. Such an act shares
20
+ * the numbering of its type (the Official Journal cites it as
21
+ * "Commission Implementing Regulation (EU) 2016/1356"), so the subtype
22
+ * is not identity either: "EU Regulation 2016/1356" is the same act.
23
+ * Only #toEli reads it, to give the ELI back.
17
24
  */
18
25
  /** The act-type metadata each leaf class carries (Ruby self.type). */
19
26
  export interface EuType {
@@ -38,6 +45,7 @@ export declare class EuIdentifier extends BaseIdentifier {
38
45
  readonly date: PubidDate | undefined;
39
46
  readonly family: string | undefined;
40
47
  readonly number_first: boolean | undefined;
48
+ readonly subtype: string | undefined;
41
49
  /** The year, read off the date component (Ruby #year). */
42
50
  get year(): string | undefined;
43
51
  /** A regulation with a year before 2015 prints <number>/<year>;
@@ -65,7 +73,8 @@ export declare class EuIdentifier extends BaseIdentifier {
65
73
  /** The CELEX number: sector 3, year, type letter, number padded to 4.
66
74
  * (The base class carries no type letter — the segments join empty.) */
67
75
  toCelex(): string;
68
- /** The ELI of the act as published in the Official Journal. */
76
+ /** The ELI of the act as published in the Official Journal — the
77
+ * subtype rides the type segment ("reg_impl") when the input had one. */
69
78
  toEli(): string;
70
79
  /** The EU has no registered URN namespace (the ELI is its official
71
80
  * identifier). This pubid-invented form keeps the act type, so a
@@ -12,10 +12,11 @@ export class EuIdentifier extends BaseIdentifier {
12
12
  static attributes = extendAttributes(BaseIdentifier, {
13
13
  family: { type: "string" },
14
14
  number_first: { type: "boolean", equalityIgnored: true },
15
+ subtype: { type: "string", equalityIgnored: true },
15
16
  });
16
- // The gem's key_value whitelist: only the four slots hit the wire; the
17
+ // The gem's key_value whitelist: only the five slots hit the wire; the
17
18
  // base's part/edition/publisher/... slots stay off it.
18
- static mappings = keyValue({ wire: "number", to: "number" }, { wire: "date", to: "date" }, { wire: "family", to: "family" }, { wire: "number_first", to: "number_first" });
19
+ static mappings = keyValue({ wire: "number", to: "number" }, { wire: "date", to: "date" }, { wire: "family", to: "family" }, { wire: "number_first", to: "number_first" }, { wire: "subtype", to: "subtype" });
19
20
  static euType = { key: "identifier", title: "", celex: null, eli: null };
20
21
  /** The year, read off the date component (Ruby #year). */
21
22
  get year() {
@@ -66,9 +67,12 @@ export class EuIdentifier extends BaseIdentifier {
66
67
  toCelex() {
67
68
  return `3${this.year ?? ""}${this.euCelexLetter() ?? ""}${(this.number ?? "").padStart(4, "0")}`;
68
69
  }
69
- /** The ELI of the act as published in the Official Journal. */
70
+ /** The ELI of the act as published in the Official Journal — the
71
+ * subtype rides the type segment ("reg_impl") when the input had one. */
70
72
  toEli() {
71
- return `http://data.europa.eu/eli/${this.euEliSegment() ?? ""}/${this.year ?? ""}/${this.number ?? ""}/oj`;
73
+ const eli = this.euEliSegment() ?? "";
74
+ const typed = this.subtype !== undefined ? `${eli}_${this.subtype}` : eli;
75
+ return `http://data.europa.eu/eli/${typed}/${this.year ?? ""}/${this.number ?? ""}/oj`;
72
76
  }
73
77
  /** The EU has no registered URN namespace (the ELI is its official
74
78
  * identifier). This pubid-invented form keeps the act type, so a
@@ -5,8 +5,8 @@ import { match, str } from "../../grammar/engine.js";
5
5
  * succeeded alternative, so neighbour order in `identifier` is pinned
6
6
  * by the Ruby comments):
7
7
  * annex_to | special_publication | supplement | annex | appendix |
8
- * report | handbook | numeric_question | letter_question | with_series |
9
- * contribution | series_code | without_series
8
+ * report | resolution | handbook | numeric_question | letter_question |
9
+ * with_series | contribution | series_code | without_series
10
10
  * and supplement chains precede supplement_with_base (which would
11
11
  * otherwise strand "/Technical Cor. 1" trailing input).
12
12
  */
@@ -154,6 +154,15 @@ function buildRules() {
154
154
  .then(space, rules["itu_prefix"], rules["sector"], space, rules["report_body"])
155
155
  .or(rules["itu_prefix"].then(rules["sector"], space, rules["report_word"], space, rules["report_body"])));
156
156
  rule("report_identifier", () => rules["base_report"].then(rules["language"].maybe()));
157
+ // ITU-R Resolution ("Resolution ITU-R 1-9 (2023)"): a number and its
158
+ // revision, never a series. Like the Report marker, the word is
159
+ // captured, and both the leading and the infix spelling are accepted.
160
+ rule("resolution_word", () => str("Resolution").or(str("Res.")).as("resolution_marker"));
161
+ rule("resolution_body", () => rules["code"].then(rules["document_date"].maybe()));
162
+ rule("base_resolution", () => rules["resolution_word"]
163
+ .then(space, rules["itu_prefix"], rules["sector"], space, rules["resolution_body"])
164
+ .or(rules["itu_prefix"].then(rules["sector"], space, rules["resolution_word"], space, rules["resolution_body"])));
165
+ rule("resolution_identifier", () => rules["base_resolution"].then(rules["language"].maybe()));
157
166
  rule("base", () => rules["base_report"].or(rules["base_with_series"], rules["base_without_series"], rules["base_series_code"]));
158
167
  // Annex label: one letter, optional number and/or "+" ("F3", "C+").
159
168
  rule("annex_label", () => letter.then(digits.maybe(), str("+").maybe()));
@@ -254,7 +263,7 @@ function buildRules() {
254
263
  rule("radio_regulations", () => rules["itu_prefix"]
255
264
  .then(str("R").as("sector"), space, str("RR").as("radio_regulations"), rules["date_part"].or(dash.then(digit.repeat(4, 4).as("year"))).maybe(), rules["language"].maybe(), match(".").absent()));
256
265
  rule("identifier", () => rules["annex_to_identifier"]
257
- .or(rules["special_publication"], rules["supplement_identifier"], rules["annex_identifier"], rules["appendix_identifier"], rules["report_identifier"], rules["handbook"], rules["numeric_question"], rules["letter_question"], rules["radio_regulations"], rules["with_series"], rules["contribution"], rules["series_code_identifier"], rules["without_series"], rules["publication_id"]));
266
+ .or(rules["special_publication"], rules["supplement_identifier"], rules["annex_identifier"], rules["appendix_identifier"], rules["report_identifier"], rules["resolution_identifier"], rules["handbook"], rules["numeric_question"], rules["letter_question"], rules["radio_regulations"], rules["with_series"], rules["contribution"], rules["series_code_identifier"], rules["without_series"], rules["publication_id"]));
258
267
  rule("root", () => rules["identifier"]
259
268
  .then(rules["common_text_twin"])
260
269
  .or(rules["identifier"]));
@@ -79,7 +79,11 @@ class ItuBuilder {
79
79
  combined: this.buildDesignations(tree["combined"]),
80
80
  });
81
81
  }
82
- const klass = tree["report_marker"] !== undefined ? ITU_CLASSES["report"] : ITU_CLASSES["recommendation"];
82
+ const klass = tree["report_marker"] !== undefined
83
+ ? ITU_CLASSES["report"]
84
+ : tree["resolution_marker"] !== undefined
85
+ ? ITU_CLASSES["resolution"]
86
+ : ITU_CLASSES["recommendation"];
83
87
  return new klass({ ...common });
84
88
  }
85
89
  withTwin(identifier, twin) {
@@ -72,6 +72,11 @@ export declare class ItuReport extends ItuIdentifier {
72
72
  static mappings: FieldMapping[];
73
73
  renderBase(): string;
74
74
  }
75
+ export declare class ItuResolution extends ItuIdentifier {
76
+ static polymorphicName: string;
77
+ static mappings: FieldMapping[];
78
+ renderBase(): string;
79
+ }
75
80
  export declare class ItuHandbook extends ItuIdentifier {
76
81
  static polymorphicName: string;
77
82
  static mappings: FieldMapping[];
@@ -174,6 +179,7 @@ export declare class ItuAnnex extends ItuIdentifier {
174
179
  export declare const ITU_CLASSES: {
175
180
  readonly recommendation: typeof ItuRecommendation;
176
181
  readonly report: typeof ItuReport;
182
+ readonly resolution: typeof ItuResolution;
177
183
  readonly handbook: typeof ItuHandbook;
178
184
  readonly special_publication: typeof ItuSpecialPublication;
179
185
  readonly radio_regulations: typeof ItuRadioRegulations;
@@ -271,6 +271,10 @@ export class ItuUrnGenerator extends BaseUrnGenerator {
271
271
  // reach the URN or the two same-numbered documents collide.
272
272
  if (id instanceof ItuReport)
273
273
  parts.push("report");
274
+ // A Resolution numbers independently too ("1-9" is also a
275
+ // Recommendation number), so it gets its own segment.
276
+ if (id instanceof ItuResolution)
277
+ parts.push("resolution");
274
278
  if (id.series !== undefined) {
275
279
  if (id.code !== undefined) {
276
280
  const join = id.series_dash === true ? "-" : ".";
@@ -347,6 +351,24 @@ export class ItuReport extends ItuIdentifier {
347
351
  }
348
352
  registerType(ItuReport);
349
353
  attachUrn(ItuReport);
354
+ // The ITU-R Resolution, adopted by the Radiocommunication Assembly
355
+ // ("Resolution ITU-R 1-9 (2023)"). A Resolution has a number and a
356
+ // revision (code.parts, as for a Recommendation edition), never a
357
+ // series. Resolutions number independently of Recommendations, so the
358
+ // leading word is part of the identity: it reaches to_s and the URN,
359
+ // and the class-strict == keeps "Resolution ITU-R 1-9" unequal to
360
+ // "ITU-R 1-9" in both directions. The grammar also reads "ITU-R Res.
361
+ // 1-9", "ITU-R Resolution 1-9" and "Res. ITU-R 1-9"; all render ITU's
362
+ // leading form.
363
+ export class ItuResolution extends ItuIdentifier {
364
+ static polymorphicName = "pubid:itu:resolution";
365
+ static mappings = STANDARD_MAPPINGS;
366
+ renderBase() {
367
+ return `Resolution ${super.renderBase()}`;
368
+ }
369
+ }
370
+ registerType(ItuResolution);
371
+ attachUrn(ItuResolution);
350
372
  export class ItuHandbook extends ItuIdentifier {
351
373
  static polymorphicName = "pubid:itu:handbook";
352
374
  static mappings = STANDARD_MAPPINGS;
@@ -629,6 +651,7 @@ attachUrn(ItuAnnex);
629
651
  export const ITU_CLASSES = {
630
652
  recommendation: ItuRecommendation,
631
653
  report: ItuReport,
654
+ resolution: ItuResolution,
632
655
  handbook: ItuHandbook,
633
656
  special_publication: ItuSpecialPublication,
634
657
  radio_regulations: ItuRadioRegulations,
@@ -8,14 +8,27 @@ export * from "./model.js";
8
8
  * parsanol 1.5.1.0), loaded through the artifact runtime. The builder
9
9
  * mirrors Pubid::Wmo::Builder: the grammar carries exactly one
10
10
  * doc_number and edition_value per alternative path, so one flat bound
11
- * map serves all three types and the dispatch keys off `annex_marker`
12
- * and `wmomarker`.
11
+ * map serves all types and the dispatch keys off `annex_marker` and
12
+ * `series_head`.
13
13
  */
14
+ /**
15
+ * The series head the grammar matched -> the model's series key (the
16
+ * widening prefix law: every head names its publisher, and the head
17
+ * face is the grammar's verbatim capture, so the key mapping lives on
18
+ * the one construction site).
19
+ */
20
+ const SERIES_HEADS = {
21
+ "WMO-No.": undefined,
22
+ "WMO/TD-No.": "TD",
23
+ "JCOMM Technical Report No.": "JCOMM",
24
+ "GAW Report No.": "GAW",
25
+ };
26
+ const head = (data, key) => data[key] === undefined ? undefined : String(data[key]);
14
27
  function buildWmo(data) {
15
- const number = data["doc_number"] === undefined ? undefined : String(data["doc_number"]);
16
- const edition = data["edition_value"] === undefined ? undefined : String(data["edition_value"]);
17
- const annexMarker = data["annex_marker"] === undefined ? undefined : String(data["annex_marker"]);
18
- const annexLetter = data["annex_letter"] === undefined ? undefined : String(data["annex_letter"]);
28
+ const number = head(data, "doc_number");
29
+ const edition = head(data, "edition_value");
30
+ const annexMarker = head(data, "annex_marker");
31
+ const annexLetter = head(data, "annex_letter");
19
32
  if (annexMarker !== undefined) {
20
33
  const attrs = {
21
34
  base: new WmoStandard({ number }),
@@ -27,8 +40,20 @@ function buildWmo(data) {
27
40
  attrs["edition"] = edition;
28
41
  return new WmoAnnex(attrs);
29
42
  }
30
- if (data["wmomarker"] !== undefined) {
31
- return new WmoPublication(edition !== undefined ? { number, edition } : { number });
43
+ if (data["series_head"] !== undefined) {
44
+ // The widened publication series: the head key plus the volume,
45
+ // status and updated-in faces of the widening.
46
+ const attrs = {
47
+ series: SERIES_HEADS[data["series_head"]],
48
+ volume: head(data, "volume"),
49
+ edition_status: head(data, "edition_status"),
50
+ updated_in: head(data, "updated_in"),
51
+ };
52
+ if (number !== undefined)
53
+ attrs["number"] = number;
54
+ if (edition !== undefined)
55
+ attrs["edition"] = edition;
56
+ return new WmoPublication(attrs);
32
57
  }
33
58
  return new WmoStandard(edition !== undefined ? { number, edition } : { number });
34
59
  }
@@ -6,11 +6,14 @@ import { BaseIdentifier } from "../../model/identifier.js";
6
6
  * reaching the artifact runtime; the parse entry (./index.js) is the
7
7
  * parg-backed half.
8
8
  *
9
- * Two series share the flavor (pubid#763):
9
+ * The publication series share one type (pubid#763 widened):
10
10
  *
11
11
  * WMO-No. <number>[, <year> edition] the WMO-No. publication
12
12
  * series; editions are calendar
13
13
  * years
14
+ * WMO/TD-No. <number> the Technical Document series
15
+ * JCOMM Technical Report No. <number> the joint WMO/IOC series
16
+ * GAW Report No. <number> the GAW series
14
17
  * S-<number>[ <x.y.z>] the WMO-published S-100 product
15
18
  * specifications; editions are
16
19
  * dotted x.y.z (the IHO lexical
@@ -20,17 +23,37 @@ import { BaseIdentifier } from "../../model/identifier.js";
20
23
  * S-<number> [Annex|ANNEX] [<letter>] [<x.y.z>] annex wrapper
21
24
  *
22
25
  * The edition is ONE string attribute carrying a type-driven face:
23
- * "2025" on a Publication, "1.2.1" on a Standard or Annex. The
24
- * renderer and the MRN URN generator key the face off the type.
26
+ * "2025" on a Publication, "1.2.1" on a Standard or Annex. The compound
27
+ * faces widen it: a year pair ("2021/2018" — the pair IS the identity
28
+ * face) rides the same string, while the status word ("Provisional")
29
+ * and the updated-in year carry their own attributes. The volume face
30
+ * ("I", "I.1", "D") is its own attribute, printed before the edition
31
+ * face. The renderer and the MRN URN generator key the face off the
32
+ * type.
25
33
  */
34
+ /** The series config of a series key: the citation face the grammar
35
+ * matched and the MRN slug prefix (lib/pubid/wmo/identifier.rb). */
36
+ interface WmoSeriesConfig {
37
+ face: string;
38
+ mrn: string;
39
+ }
26
40
  /**
27
41
  * The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
28
42
  * assigning authority of the IANA-registered mrn namespace, following
29
43
  * the IALA pattern (pubid#763 proposed form):
30
44
  *
31
- * urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
45
+ * urn:mrn:wmo:pub:wmo-<number>[:vol-<v>][:status-<s>][:ed<year>]
46
+ * [:updated-<year>] the WMO-No. series
47
+ * urn:mrn:wmo:pub:wmo-td-<number> the TD series
48
+ * urn:mrn:wmo:pub:jcomm-tr-<number> the joint WMO/IOC series
49
+ * urn:mrn:wmo:pub:gaw-<number> the GAW series
32
50
  * urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
33
51
  * urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
52
+ *
53
+ * The segment order mirrors the human face order (volume, status,
54
+ * edition, updated-in); the volume and status values are caseless
55
+ * (downcased, re-cased by the parser). The year pair keeps its slash
56
+ * out of the NSS as a hyphen ("2021/2018" rides as "ed2021-2018").
34
57
  */
35
58
  declare class WmoUrnGenerator {
36
59
  private readonly identifier;
@@ -43,18 +66,45 @@ export declare class WmoIdentifier extends BaseIdentifier {
43
66
  static attributes: import("../../model/attribute.js").AttributeTable;
44
67
  static mappings: import("../../model/attribute.js").FieldMapping[];
45
68
  static urnGenerator: typeof WmoUrnGenerator;
69
+ /** The series config (face + MRN slug prefix) of a series key,
70
+ * defaulting to the WMO-No. row. */
71
+ static seriesConfig(series: string | undefined): WmoSeriesConfig;
72
+ /** The series config of this identifier's own series. */
73
+ seriesConfig(): WmoSeriesConfig;
46
74
  readonly number: string | undefined;
75
+ readonly series: string | undefined;
47
76
  readonly edition: string | undefined;
77
+ readonly volume: string | undefined;
78
+ readonly edition_status: string | undefined;
79
+ readonly updated_in: string | undefined;
48
80
  readonly publisher: string | undefined;
49
- /** The edition is a plain string (the string-edition flavors precede
50
- * this); the base mr_edition reads edition.number of a
51
- * Components::Edition, which would crash on the string. */
81
+ /**
82
+ * The MR-slug identity hooks of the gem (lib/pubid/wmo/
83
+ * identifier.rb) — mirrors with no TS consumer yet (to_mr_string has
84
+ * no TS counterpart), kept faithful to the ruby bodies. The compound
85
+ * faces ride the edition segment so distinct identifiers never
86
+ * collide on the slug: the year pair keeps its slash out of the MR
87
+ * charset as a hyphen ("2021/2018" rides as "ed2021-2018"), the
88
+ * status word and the updated-in year suffix it.
89
+ */
52
90
  mrEdition(): string | undefined;
91
+ /** The series is the type discriminator of the publication series:
92
+ * "WMO/TD-No. 196" and "WMO-No. 196" are two documents. Downcased
93
+ * per the MR charset; undefined (no segment) on the WMO-No. default. */
94
+ mrType(): string | undefined;
95
+ /** The volume is an identity discriminator (the ECMA law): Volume I
96
+ * and Volume II of WMO-No. 8 are two documents sharing one
97
+ * docidentifier. Downcased per the MR charset. */
98
+ mrVolume(): string | undefined;
53
99
  /** "WMO-No." and the S-number are designations, not publisher tokens:
54
100
  * the canonical faces carry no publisher prefix. */
55
101
  render(): string;
56
102
  }
57
- /** Identifiers::Publication — the WMO-No. series. */
103
+ /** Identifiers::Publication — the WMO-No. publication series and its
104
+ * widened siblings (TD, JCOMM, GAW). Editions are calendar years —
105
+ * "2025 edition" — never version ordinals; the face order is the
106
+ * widening ruling's: volume first, then the edition face (the status
107
+ * word inside it), then the updated-in year. */
58
108
  export declare class WmoPublication extends WmoIdentifier {
59
109
  static polymorphicName: string;
60
110
  render(): string;
@@ -1,37 +1,42 @@
1
1
  import { BaseIdentifier, registerType } from "../../model/identifier.js";
2
2
  import { keyValue, extendAttributes } from "../../model/attribute.js";
3
3
  /**
4
- * The wmo identifier model — lib/pubid/wmo/identifier.rb plus its
5
- * Identifiers::* leaves. Registration lives HERE (parg-free) so the
6
- * worker manifest (src/flavors/register-types.ts) can import it without
7
- * reaching the artifact runtime; the parse entry (./index.js) is the
8
- * parg-backed half.
9
- *
10
- * Two series share the flavor (pubid#763):
11
- *
12
- * WMO-No. <number>[, <year> edition] the WMO-No. publication
13
- * series; editions are calendar
14
- * years
15
- * S-<number>[ <x.y.z>] the WMO-published S-100 product
16
- * specifications; editions are
17
- * dotted x.y.z (the IHO lexical
18
- * form, WMO as the assigning
19
- * authority - the S-201-of-IALA
20
- * ruling)
21
- * S-<number> [Annex|ANNEX] [<letter>] [<x.y.z>] annex wrapper
22
- *
23
- * The edition is ONE string attribute carrying a type-driven face:
24
- * "2025" on a Publication, "1.2.1" on a Standard or Annex. The
25
- * renderer and the MRN URN generator key the face off the type.
4
+ * The publication series beyond the WMO-No. default (the widening
5
+ * prefix law: every head token names its publisher, so the model
6
+ * carries the short key and derives the citation face and the MRN
7
+ * slug from this table). The default row stays out of the table:
8
+ * series is undefined for WMO-No., so existing rows serialize without
9
+ * the key.
26
10
  */
11
+ const WMO_SERIES = {
12
+ TD: { face: "WMO/TD-No.", mrn: "wmo-td" },
13
+ JCOMM: { face: "JCOMM Technical Report No.", mrn: "jcomm-tr" },
14
+ GAW: { face: "GAW Report No.", mrn: "gaw" },
15
+ };
16
+ /** The WMO-No. series itself: the face the grammar matches and the MRN
17
+ * slug prefix of the default series (series undefined). */
18
+ const WMO_DEFAULT_SERIES = { face: "WMO-No.", mrn: "wmo" };
19
+ function wmoSeriesConfig(series) {
20
+ const found = series === undefined ? undefined : WMO_SERIES[series];
21
+ return found ?? WMO_DEFAULT_SERIES;
22
+ }
27
23
  /**
28
24
  * The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
29
25
  * assigning authority of the IANA-registered mrn namespace, following
30
26
  * the IALA pattern (pubid#763 proposed form):
31
27
  *
32
- * urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
28
+ * urn:mrn:wmo:pub:wmo-<number>[:vol-<v>][:status-<s>][:ed<year>]
29
+ * [:updated-<year>] the WMO-No. series
30
+ * urn:mrn:wmo:pub:wmo-td-<number> the TD series
31
+ * urn:mrn:wmo:pub:jcomm-tr-<number> the joint WMO/IOC series
32
+ * urn:mrn:wmo:pub:gaw-<number> the GAW series
33
33
  * urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
34
34
  * urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
35
+ *
36
+ * The segment order mirrors the human face order (volume, status,
37
+ * edition, updated-in); the volume and status values are caseless
38
+ * (downcased, re-cased by the parser). The year pair keeps its slash
39
+ * out of the NSS as a hyphen ("2021/2018" rides as "ed2021-2018").
35
40
  */
36
41
  class WmoUrnGenerator {
37
42
  identifier;
@@ -41,22 +46,31 @@ class WmoUrnGenerator {
41
46
  generate() {
42
47
  const id = this.identifier;
43
48
  if (id instanceof WmoAnnex) {
49
+ // The base specification's code, then an "annex" segment (lettered
50
+ // form for the "ANNEX A" style, bare for "Annex" without a
51
+ // letter), then the annex's own edition.
44
52
  const parts = ["urn:mrn:wmo:pub", `s-${id.base?.number ?? ""}`];
45
- // Lettered form for the "ANNEX A" style, bare for "Annex"
46
- // without a letter.
47
53
  parts.push(id.letter !== undefined ? `annex-${id.letter.toLowerCase()}` : "annex");
48
54
  if (id.edition !== undefined)
49
55
  parts.push(`ed${id.edition}`);
50
56
  return parts.join(":");
51
57
  }
52
- // The WMO-No. series codes as "wmo-<number>"; the S-100 specs keep
58
+ // The publication series codes via its SERIES slug ("wmo-1364",
59
+ // "wmo-td-196", "jcomm-tr-14", "gaw-312"); the S-100 specs keep
53
60
  // their lexical form lowercased ("s-411").
54
61
  const code = id instanceof WmoPublication
55
- ? `wmo-${id.number ?? ""}`
62
+ ? `${wmoSeriesConfig(id.series).mrn}-${id.number ?? ""}`
56
63
  : `s-${id.number ?? ""}`;
57
64
  const parts = ["urn:mrn:wmo:pub", code];
65
+ if (id.volume !== undefined)
66
+ parts.push(`vol-${id.volume.toLowerCase()}`);
67
+ if (id.edition_status !== undefined) {
68
+ parts.push(`status-${id.edition_status.toLowerCase()}`);
69
+ }
58
70
  if (id.edition !== undefined)
59
- parts.push(`ed${id.edition}`);
71
+ parts.push(`ed${id.edition.replaceAll("/", "-")}`);
72
+ if (id.updated_in !== undefined)
73
+ parts.push(`updated-${id.updated_in}`);
60
74
  return parts.join(":");
61
75
  }
62
76
  }
@@ -65,19 +79,67 @@ export class WmoIdentifier extends BaseIdentifier {
65
79
  static polymorphicName = "pubid:wmo:identifier";
66
80
  static attributes = extendAttributes(BaseIdentifier, {
67
81
  publisher: { type: "string", default: "WMO" },
68
- number: { type: "string" },
69
- // One edition column, type-driven face.
82
+ number: { type: "string" }, // "1364", "411"
83
+ // The publication series key: undefined (the WMO-No. default),
84
+ // "TD", "JCOMM" or "GAW". The citation face and the MRN slug
85
+ // prefix derive from WMO_SERIES.
86
+ series: { type: "string" },
87
+ // One edition column, type-driven face: "2025" or the year pair
88
+ // "2021/2018" (the WMO-No. series' calendar-year edition) or
89
+ // "1.2.1" (the S-100 dotted edition).
70
90
  edition: { type: "string" },
91
+ // The publication volume face ("I", "I.1", "D"); publication-only.
92
+ volume: { type: "string" },
93
+ // The edition status word ("Provisional"); publication-only.
94
+ edition_status: { type: "string" },
95
+ // The year the edition was updated in ("2025"); publication-only.
96
+ updated_in: { type: "string" },
71
97
  });
72
- // The gem's key_value whitelist: _type, number, edition (the
73
- // defaulted publisher never serializes).
74
- static mappings = keyValue({ wire: "number", to: "number" }, { wire: "edition", to: "edition" });
98
+ // The gem's key_value whitelist: _type, number, series, edition,
99
+ // volume, edition_status, updated_in (the defaulted publisher never
100
+ // serializes).
101
+ static mappings = keyValue({ wire: "number", to: "number" }, { wire: "series", to: "series" }, { wire: "edition", to: "edition" }, { wire: "volume", to: "volume" }, { wire: "edition_status", to: "edition_status" }, { wire: "updated_in", to: "updated_in" });
75
102
  static urnGenerator = WmoUrnGenerator;
76
- /** The edition is a plain string (the string-edition flavors precede
77
- * this); the base mr_edition reads edition.number of a
78
- * Components::Edition, which would crash on the string. */
103
+ /** The series config (face + MRN slug prefix) of a series key,
104
+ * defaulting to the WMO-No. row. */
105
+ static seriesConfig(series) {
106
+ return wmoSeriesConfig(series);
107
+ }
108
+ /** The series config of this identifier's own series. */
109
+ seriesConfig() {
110
+ return wmoSeriesConfig(this.series);
111
+ }
112
+ /**
113
+ * The MR-slug identity hooks of the gem (lib/pubid/wmo/
114
+ * identifier.rb) — mirrors with no TS consumer yet (to_mr_string has
115
+ * no TS counterpart), kept faithful to the ruby bodies. The compound
116
+ * faces ride the edition segment so distinct identifiers never
117
+ * collide on the slug: the year pair keeps its slash out of the MR
118
+ * charset as a hyphen ("2021/2018" rides as "ed2021-2018"), the
119
+ * status word and the updated-in year suffix it.
120
+ */
79
121
  mrEdition() {
80
- return this.edition === undefined ? undefined : `ed${this.edition}`;
122
+ if (this.edition === undefined)
123
+ return undefined;
124
+ let segment = `ed${this.edition.replaceAll("/", "-")}`;
125
+ if (this.edition_status !== undefined) {
126
+ segment += `-${this.edition_status.toLowerCase()}`;
127
+ }
128
+ if (this.updated_in !== undefined)
129
+ segment += `-updated${this.updated_in}`;
130
+ return segment;
131
+ }
132
+ /** The series is the type discriminator of the publication series:
133
+ * "WMO/TD-No. 196" and "WMO-No. 196" are two documents. Downcased
134
+ * per the MR charset; undefined (no segment) on the WMO-No. default. */
135
+ mrType() {
136
+ return this.series === undefined ? undefined : this.series.toLowerCase();
137
+ }
138
+ /** The volume is an identity discriminator (the ECMA law): Volume I
139
+ * and Volume II of WMO-No. 8 are two documents sharing one
140
+ * docidentifier. Downcased per the MR charset. */
141
+ mrVolume() {
142
+ return this.volume === undefined ? undefined : `vol-${this.volume.toLowerCase()}`;
81
143
  }
82
144
  /** "WMO-No." and the S-number are designations, not publisher tokens:
83
145
  * the canonical faces carry no publisher prefix. */
@@ -86,13 +148,24 @@ export class WmoIdentifier extends BaseIdentifier {
86
148
  (this.edition !== undefined ? ` ${this.edition}` : "");
87
149
  }
88
150
  }
89
- /** Identifiers::Publication — the WMO-No. series. */
151
+ /** Identifiers::Publication — the WMO-No. publication series and its
152
+ * widened siblings (TD, JCOMM, GAW). Editions are calendar years —
153
+ * "2025 edition" — never version ordinals; the face order is the
154
+ * widening ruling's: volume first, then the edition face (the status
155
+ * word inside it), then the updated-in year. */
90
156
  export class WmoPublication extends WmoIdentifier {
91
157
  static polymorphicName = "pubid:wmo:publication";
92
158
  render() {
93
- let rendered = `WMO-No. ${this.number ?? ""}`;
94
- if (this.edition !== undefined)
95
- rendered += `, ${this.edition} edition`;
159
+ let rendered = `${this.seriesConfig().face} ${this.number ?? ""}`;
160
+ if (this.volume !== undefined)
161
+ rendered += `, Volume ${this.volume}`;
162
+ if (this.edition !== undefined) {
163
+ rendered += this.edition_status !== undefined
164
+ ? `, ${this.edition_status} ${this.edition} edition`
165
+ : `, ${this.edition} edition`;
166
+ if (this.updated_in !== undefined)
167
+ rendered += `, updated in ${this.updated_in}`;
168
+ }
96
169
  return rendered;
97
170
  }
98
171
  }
@@ -9,6 +9,7 @@ import { define } from "../index.js";
9
9
  export const euSchema = define("eu", (s) => {
10
10
  s.atom("family", "family");
11
11
  s.facet("number_first", "numberfirst", "bool");
12
+ s.facet("subtype", "subtype");
12
13
  s.type("pubid:eu:regulation", "reg", { core: ["year", "number"] });
13
14
  s.type("pubid:eu:directive", "dir", { core: ["year", "number"] });
14
15
  s.type("pubid:eu:decision", "dec", { core: ["year", "number"] });
@@ -43,6 +43,7 @@ export const ituSchema = define("itu", (s) => {
43
43
  s.facet("slash_joined", "slashjoined", "bool");
44
44
  s.type("pubid:itu:recommendation", "rec");
45
45
  s.type("pubid:itu:report", "rpt");
46
+ s.type("pubid:itu:resolution", "res");
46
47
  s.type("pubid:itu:combined-identifier", "comb");
47
48
  s.type("pubid:itu:question", "q");
48
49
  s.type("pubid:itu:handbook", "hb");
@@ -7,7 +7,11 @@
7
7
  */
8
8
  import { define } from "../index.js";
9
9
  export const wmoSchema = define("wmo", (s) => {
10
+ s.atom("series", "series");
11
+ s.atom("volume", "vol");
10
12
  s.atom("edition", "ed");
13
+ s.atom("edition_status", "status");
14
+ s.atom("updated_in", "updated");
11
15
  s.atom("annex_form", "annexform");
12
16
  s.atom("letter", "letter");
13
17
  s.type("pubid:wmo:publication", "pub");
@@ -732,13 +732,18 @@ export const URN_PARSERS = {
732
732
  return parse(text);
733
733
  },
734
734
  },
735
- // lib/pubid/wmo/urn_parser.rb — the MRN segments: a "wmo-<digits>" code
736
- // rebuilds the compact year edition (the text parser normalizes to the
737
- // comma face); an "s-<digits>" code takes a caseless annex segment (at
738
- // most one, rebuilt as the attested "Annex" face) then the dotted
739
- // edition. Every non-annex segment must be "ed" + the shape the code
740
- // declares (a year for a publication, dotted for a standard) — per the
741
- // ISO urn_parser strictness.
735
+ // lib/pubid/wmo/urn_parser.rb — the MRN segments of the widening: the
736
+ // code resolves the series slug ("wmo-td-"/"wmo-"/"jcomm-tr-"/"gaw-"
737
+ // publications, longest slug first; "s-" the S-100 specs). A
738
+ // publication takes the caseless volume ("vol-i.1"), status
739
+ // ("status-provisional"), updated-in ("updated-2025") and one
740
+ // "ed<year>" (the year pair hyphenated, "ed2021-2018") segments; an
741
+ // "s-" code takes a caseless annex segment (at most one, rebuilt as
742
+ // the attested "Annex" face) then the dotted edition. Every other
743
+ // segment must be "ed" + the shape the code declares (a year for a
744
+ // publication, dotted for a standard) — per the ISO urn_parser
745
+ // strictness. The rebuild walks the comma-optional faces and the text
746
+ // parser normalizes (one construction path).
742
747
  wmo: {
743
748
  prefix: "urn:mrn:wmo:pub:",
744
749
  reconstruct(body, parse) {
@@ -758,18 +763,69 @@ export const URN_PARSERS = {
758
763
  }
759
764
  return edition;
760
765
  };
761
- const publication = /^wmo-(\d+)$/i.exec(code);
762
- if (publication !== null) {
766
+ // Longest slug first: "wmo-td-" also starts with "wmo-". The face
767
+ // is the series key's citation face (the gem reads
768
+ // Identifier.series_config(series)[:face]).
769
+ const SERIES_CODES = [
770
+ ["wmo-td-", "TD", "WMO/TD-No."],
771
+ ["wmo-", undefined, "WMO-No."],
772
+ ["jcomm-tr-", "JCOMM", "JCOMM Technical Report No."],
773
+ ["gaw-", "GAW", "GAW Report No."],
774
+ ];
775
+ const publicationCode = SERIES_CODES
776
+ .map(([slug, series, face]) => ({
777
+ series,
778
+ face,
779
+ match: new RegExp(`^${slug}(\\d+)$`, "i").exec(code),
780
+ }))
781
+ .find(({ match }) => match !== null);
782
+ if (publicationCode !== undefined) {
783
+ let volume;
784
+ let status;
763
785
  let edition;
786
+ let updatedIn;
764
787
  for (const seg of segments) {
788
+ const vol = /^vol-([a-z]+(?:\.\d+)*)$/i.exec(seg);
789
+ if (vol !== null) {
790
+ if (volume !== undefined) {
791
+ throw new Error(`Invalid WMO URN segment (duplicate volume): ${JSON.stringify(seg)}`);
792
+ }
793
+ volume = vol[1].toUpperCase();
794
+ continue;
795
+ }
796
+ const stat = /^status-([a-z]+)$/i.exec(seg);
797
+ if (stat !== null) {
798
+ if (status !== undefined) {
799
+ throw new Error(`Invalid WMO URN segment (duplicate status): ${JSON.stringify(seg)}`);
800
+ }
801
+ status = stat[1].charAt(0).toUpperCase() + stat[1].slice(1);
802
+ continue;
803
+ }
804
+ const updated = /^updated-(\d{4})$/i.exec(seg);
805
+ if (updated !== null) {
806
+ if (updatedIn !== undefined) {
807
+ throw new Error(`Invalid WMO URN segment (duplicate updated): ${JSON.stringify(seg)}`);
808
+ }
809
+ updatedIn = updated[1];
810
+ continue;
811
+ }
765
812
  if (edition !== undefined) {
766
813
  throw new Error(`Invalid WMO URN segment (duplicate edition): ${JSON.stringify(seg)}`);
767
814
  }
768
- edition = editionValue(seg, /^\d{4}$/);
815
+ // The year pair keeps its slash out of the NSS as a hyphen;
816
+ // the rebuild restores it ("ed2021-2018" -> "2021/2018").
817
+ edition = editionValue(seg, /^\d{4}(?:-\d{4})?$/).replaceAll("-", "/");
769
818
  }
770
- let text = `WMO-No. ${publication[1]}`;
771
- if (edition !== undefined)
772
- text += `:ed${edition}`;
819
+ let text = `${publicationCode.face} ${publicationCode.match[1]}`;
820
+ if (volume !== undefined)
821
+ text += ` Volume ${volume}`;
822
+ if (edition !== undefined) {
823
+ text += status !== undefined
824
+ ? `, ${status} ${edition} edition`
825
+ : `, ${edition} edition`;
826
+ }
827
+ if (updatedIn !== undefined)
828
+ text += `, updated in ${updatedIn}`;
773
829
  return parse(text);
774
830
  }
775
831
  const standard = /^s-(\d+)$/i.exec(code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubid/pubid",
3
- "version": "0.1.59",
3
+ "version": "0.1.61",
4
4
  "description": "TypeScript PubID identifiers: resolution, normalization and canonical hashes for every identifier in the pubid-testsuite corpus (41 standards bodies), with a conformance runner mirroring the Ruby reference",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +1 @@
1
- {"bindings":null,"version":"0.1.0","grammar":"PubidWmo","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":47}},{"Entity":{"atom":7}},{"Str":{"pattern":"S-"}},{"Entity":{"atom":4}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":3,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number","atom":5}},{"Sequence":{"atoms":[2,6]}},{"Entity":{"atom":9}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Annex"}},{"Str":{"pattern":"ANNEX"}},{"Alternative":{"atoms":[10,11]}},{"Named":{"name":"annex_marker","atom":12}},{"Entity":{"atom":9}},{"Entity":{"atom":16}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Named":{"name":"annex_letter","atom":15}},{"Entity":{"atom":19}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Lookahead":{"atom":18,"positive":false}},{"Sequence":{"atoms":[14,17,20]}},{"Repetition":{"atom":21,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":37}},{"Entity":{"atom":9}},{"Entity":{"atom":35}},{"Entity":{"atom":4}},{"Repetition":{"atom":26,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":29}},{"Str":{"pattern":"."}},{"Entity":{"atom":4}},{"Repetition":{"atom":30,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[28,31]}},{"Repetition":{"atom":32,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[27,33]}},{"Named":{"name":"edition_value","atom":34}},{"Sequence":{"atoms":[24,25]}},{"Named":{"name":"edition","atom":36}},{"Entity":{"atom":44}},{"Entity":{"atom":40}},{"Str":{"pattern":":"}},{"Str":{"pattern":"ed"}},{"Entity":{"atom":35}},{"Sequence":{"atoms":[39,41,42]}},{"Named":{"name":"edition","atom":43}},{"Alternative":{"atoms":[23,38]}},{"Repetition":{"atom":45,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,8,13,22,46]}},{"Entity":{"atom":77}},{"Entity":{"atom":51}},{"Str":{"pattern":"WMO-No."}},{"Named":{"name":"wmomarker","atom":50}},{"Entity":{"atom":9}},{"Entity":{"atom":56}},{"Entity":{"atom":4}},{"Repetition":{"atom":54,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number","atom":55}},{"Entity":{"atom":68}},{"Entity":{"atom":59}},{"Str":{"pattern":","}},{"Repetition":{"atom":58,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":9}},{"Entity":{"atom":65}},{"Entity":{"atom":4}},{"Repetition":{"atom":63,"min":4,"max":4,"tag":"Repetition"}},{"Named":{"name":"edition_value","atom":64}},{"Str":{"pattern":" edition"}},{"Sequence":{"atoms":[60,61,62,66]}},{"Named":{"name":"edition","atom":67}},{"Entity":{"atom":74}},{"Entity":{"atom":40}},{"Str":{"pattern":"ed"}},{"Entity":{"atom":65}},{"Sequence":{"atoms":[70,71,72]}},{"Named":{"name":"edition","atom":73}},{"Alternative":{"atoms":[57,69]}},{"Repetition":{"atom":75,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[49,52,53,76]}},{"Entity":{"atom":84}},{"Entity":{"atom":7}},{"Entity":{"atom":37}},{"Entity":{"atom":44}},{"Alternative":{"atoms":[80,81]}},{"Repetition":{"atom":82,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[79,83]}},{"Alternative":{"atoms":[0,48,78]}}],"root":85},"bindings":[{"capture":"wmomarker","path":"wmomarker","type":"string","card":null,"preprocess":null},{"capture":"doc_number","path":"doc_number","type":"string","card":null,"preprocess":null},{"capture":"edition_value","path":"edition_value","type":"string","card":null,"preprocess":null},{"capture":"annex_marker","path":"annex_marker","type":"string","card":null,"preprocess":null},{"capture":"annex_letter","path":"annex_letter","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule identifier: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"WMO-No. 1364","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364, 2025 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364 2025 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364:ed2025","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 1.2.1","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411:ed1.2.1","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 Annex A","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 ANNEX A","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 Annex A 1.2.0","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}},{"entry":"identifier","kind":"reject","input":"WMO-No. edition","expect":{}},{"entry":"identifier","kind":"reject","input":"S-411 1234","expect":{}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364","expect":{"wmomarker":"WMO-No.","doc_number":"1364"}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364, 2025 edition","expect":{"wmomarker":"WMO-No.","doc_number":"1364","edition_value":"2025"}},{"entry":"identifier","kind":"example","input":"S-411 1.2.1","expect":{"doc_number":"411","edition_value":"1.2.1"}},{"entry":"identifier","kind":"example","input":"S-411 Annex A 1.2.0","expect":{"doc_number":"411","annex_marker":"Annex","annex_letter":"A","edition_value":"1.2.0"}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364:ed2025","expect":{"wmomarker":"WMO-No.","doc_number":"1364","edition_value":"2025"}}],"docs":{},"source":"# WMO document identifiers (pubid#763): the WMO-No. publication series\n# and the WMO-published S-100 product specifications.\n#\n# WMO-No. 1364 publication, bare\n# WMO-No. 1364, 2025 edition publication, year edition (citation comma)\n# WMO-No. 1364 2025 edition publication, year edition (cover stack)\n# WMO-No. 1364:ed2025 publication, compact year edition (alias)\n# S-411 S-100 product specification, bare\n# S-411 1.2.1 dotted edition (the S-411 repo form)\n# S-411:ed1.2.1 compact dotted edition (alias)\n# S-411 Annex A annex wrapper (the DCEG docidentifier)\n# S-411 Annex A 1.2.0 annex wrapper carrying its edition\n#\n# Editions are a type-driven face: the WMO-No. series carries calendar-year\n# editions (\"2025 edition\", MRN `ed2025`); the S-100 shapes carry the IHO\n# dotted x.y.z (MRN `ed1.2.1`). Both bind the one `edition_value` capture;\n# the builder keys the face off the resolved type.\n#\n# Type assignment (the #763 ruling): the S-lexical form is a WMO type,\n# publisher-parameterised per IALA's S-201 — the lexical shape is the IHO\n# S-100 form, but the flavor owns the WMO-published documents\n# (metanorma/S-411-Product-Specification, mn-document-class wmo).\n#\n# Edition-2 conversion with typed model bindings, mirroring the iala\n# grammar: each alternative path carries exactly one occurrence of every\n# capture name, so the harvest delivers one flat bound map; the annex base\n# composite stays unbound (its `doc_number` hoists to the top level) and\n# the builder dispatches on `wmomarker` / `annex_marker`. The annex letter\n# guard (!lower) keeps a following edition segment from mis-capturing.\n\ngrammar PubidWmo version \"0.1.0\" edition 2 {\n wmomarker = \"WMO-No.\" as wmomarker\n doc_number = (1*digit) as doc_number\n s_code = \"S-\" (1*digit) as doc_number\n year_value = (4digit) as edition_value\n dotted_value = (1*digit 1*(dot 1*digit)) as edition_value\n edition_year_human = ([comma] space year_value \" edition\") as edition\n edition_year_compact = (colon \"ed\" year_value) as edition\n edition_dotted_human = (space dotted_value) as edition\n edition_dotted_compact = (colon \"ed\" dotted_value) as edition\n annex_identifier = {\n s_code\n space\n (\"Annex\" / \"ANNEX\") as annex_marker\n [ (space upper as annex_letter !lower) ]\n [edition_dotted_human / edition_dotted_compact]\n }\n publication_identifier = {\n wmomarker space doc_number\n [edition_year_human / edition_year_compact]\n }\n standard_identifier = {\n s_code\n [edition_dotted_human / edition_dotted_compact]\n }\n identifier = annex_identifier / publication_identifier / standard_identifier\n entry identifier: identifier\n\n upper = %x41-5A\n lower = %x61-7A\n digit = %x30-39\n comma = \",\"\n colon = \":\"\n dot = \".\"\n space = \" \"\n\n bindings identifier {\n wmomarker -> wmomarker (string)\n doc_number -> doc_number (string)\n edition_value -> edition_value (string)\n annex_marker -> annex_marker (string)\n annex_letter -> annex_letter (string)\n }\n\n test {\n accept \"WMO-No. 1364\"\n accept \"WMO-No. 1364, 2025 edition\"\n accept \"WMO-No. 1364 2025 edition\"\n accept \"WMO-No. 1364:ed2025\"\n accept \"S-411\"\n accept \"S-411 1.2.1\"\n accept \"S-411:ed1.2.1\"\n accept \"S-411 Annex A\"\n accept \"S-411 ANNEX A\"\n accept \"S-411 Annex A 1.2.0\"\n reject \"nonsense\"\n reject \"WMO-No. edition\"\n reject \"S-411 1234\"\n example \"WMO-No. 1364\" { wmomarker: \"WMO-No.\", doc_number: \"1364\" }\n example \"WMO-No. 1364, 2025 edition\" {\n wmomarker: \"WMO-No.\",\n doc_number: \"1364\",\n edition_value: \"2025\",\n }\n example \"S-411 1.2.1\" { doc_number: \"411\", edition_value: \"1.2.1\" }\n example \"S-411 Annex A 1.2.0\" {\n doc_number: \"411\",\n annex_marker: \"Annex\",\n annex_letter: \"A\",\n edition_value: \"1.2.0\",\n }\n example \"WMO-No. 1364:ed2025\" {\n wmomarker: \"WMO-No.\",\n doc_number: \"1364\",\n edition_value: \"2025\",\n }\n }\n}\n","source_hash":"c1154f8f4d15e8e1bb6cf9e72f81ff364f38a4fcdb6a51306ad9168b309e593f","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:b48a1a5ec6cdc049a19e4a5c0384c10c9bf00160cc30924a21606ac45f558819","checksum":"sha256:671bca49cef897f9c5554c6073cf7b9a2319240ecc2a82a36d559af0d44e5d09","validated":{"lint_errors":0,"lint_warnings":1,"tests_total":18,"tests_failures":0,"self_test":true}}
1
+ {"bindings":null,"version":"0.2.0","grammar":"PubidWmo","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":47}},{"Entity":{"atom":7}},{"Str":{"pattern":"S-"}},{"Entity":{"atom":4}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":3,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number","atom":5}},{"Sequence":{"atoms":[2,6]}},{"Entity":{"atom":9}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Annex"}},{"Str":{"pattern":"ANNEX"}},{"Alternative":{"atoms":[10,11]}},{"Named":{"name":"annex_marker","atom":12}},{"Entity":{"atom":9}},{"Entity":{"atom":16}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Named":{"name":"annex_letter","atom":15}},{"Entity":{"atom":19}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Lookahead":{"atom":18,"positive":false}},{"Sequence":{"atoms":[14,17,20]}},{"Repetition":{"atom":21,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":37}},{"Entity":{"atom":9}},{"Entity":{"atom":35}},{"Entity":{"atom":4}},{"Repetition":{"atom":26,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":29}},{"Str":{"pattern":"."}},{"Entity":{"atom":4}},{"Repetition":{"atom":30,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[28,31]}},{"Repetition":{"atom":32,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[27,33]}},{"Named":{"name":"edition_value","atom":34}},{"Sequence":{"atoms":[24,25]}},{"Named":{"name":"edition","atom":36}},{"Entity":{"atom":44}},{"Entity":{"atom":40}},{"Str":{"pattern":":"}},{"Str":{"pattern":"ed"}},{"Entity":{"atom":35}},{"Sequence":{"atoms":[39,41,42]}},{"Named":{"name":"edition","atom":43}},{"Alternative":{"atoms":[23,38]}},{"Repetition":{"atom":45,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,8,13,22,46]}},{"Entity":{"atom":141}},{"Entity":{"atom":58}},{"Str":{"pattern":"WMO-No."}},{"Named":{"name":"series_head","atom":50}},{"Str":{"pattern":"WMO/TD-No."}},{"Named":{"name":"series_head","atom":52}},{"Str":{"pattern":"JCOMM Technical Report No."}},{"Named":{"name":"series_head","atom":54}},{"Str":{"pattern":"GAW Report No."}},{"Named":{"name":"series_head","atom":56}},{"Alternative":{"atoms":[51,53,55,57]}},{"Entity":{"atom":9}},{"Entity":{"atom":63}},{"Entity":{"atom":4}},{"Repetition":{"atom":61,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"doc_number","atom":62}},{"Entity":{"atom":92}},{"Str":{"pattern":","}},{"Repetition":{"atom":65,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":9}},{"Str":{"pattern":"Volume"}},{"Entity":{"atom":9}},{"Entity":{"atom":91}},{"Entity":{"atom":82}},{"Str":{"pattern":"VIII"}},{"Str":{"pattern":"VII"}},{"Str":{"pattern":"VI"}},{"Str":{"pattern":"III"}},{"Str":{"pattern":"II"}},{"Str":{"pattern":"IX"}},{"Str":{"pattern":"IV"}},{"Str":{"pattern":"X"}},{"Str":{"pattern":"V"}},{"Str":{"pattern":"I"}},{"Alternative":{"atoms":[72,73,74,75,76,77,78,79,80,81]}},{"Entity":{"atom":16}},{"Alternative":{"atoms":[71,83]}},{"Entity":{"atom":29}},{"Entity":{"atom":4}},{"Repetition":{"atom":86,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[85,87]}},{"Repetition":{"atom":88,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[84,89]}},{"Named":{"name":"volume","atom":90}},{"Sequence":{"atoms":[66,67,68,69,70]}},{"Repetition":{"atom":64,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":122}},{"Str":{"pattern":","}},{"Repetition":{"atom":95,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":9}},{"Entity":{"atom":108}},{"Entity":{"atom":4}},{"Repetition":{"atom":99,"min":4,"max":4,"tag":"Repetition"}},{"Entity":{"atom":102}},{"Str":{"pattern":"/"}},{"Entity":{"atom":4}},{"Repetition":{"atom":103,"min":4,"max":4,"tag":"Repetition"}},{"Sequence":{"atoms":[101,104]}},{"Repetition":{"atom":105,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[100,106]}},{"Named":{"name":"edition_value","atom":107}},{"Str":{"pattern":" edition"}},{"Entity":{"atom":120}},{"Str":{"pattern":","}},{"Entity":{"atom":9}},{"Str":{"pattern":"updated"}},{"Entity":{"atom":9}},{"Str":{"pattern":"in"}},{"Entity":{"atom":9}},{"Entity":{"atom":4}},{"Repetition":{"atom":117,"min":4,"max":4,"tag":"Repetition"}},{"Named":{"name":"updated_in","atom":118}},{"Sequence":{"atoms":[111,112,113,114,115,116,119]}},{"Repetition":{"atom":110,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[96,97,98,109,121]}},{"Entity":{"atom":132}},{"Str":{"pattern":","}},{"Repetition":{"atom":124,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":9}},{"Str":{"pattern":"Provisional"}},{"Named":{"name":"edition_status","atom":127}},{"Entity":{"atom":9}},{"Entity":{"atom":108}},{"Str":{"pattern":" edition"}},{"Sequence":{"atoms":[125,126,128,129,130,131]}},{"Entity":{"atom":138}},{"Entity":{"atom":40}},{"Str":{"pattern":"ed"}},{"Entity":{"atom":108}},{"Sequence":{"atoms":[134,135,136]}},{"Named":{"name":"edition","atom":137}},{"Alternative":{"atoms":[94,123,133]}},{"Repetition":{"atom":139,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[49,59,60,93,140]}},{"Entity":{"atom":148}},{"Entity":{"atom":7}},{"Entity":{"atom":37}},{"Entity":{"atom":44}},{"Alternative":{"atoms":[144,145]}},{"Repetition":{"atom":146,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[143,147]}},{"Alternative":{"atoms":[0,48,142]}}],"root":149},"bindings":[{"capture":"series_head","path":"series_head","type":"string","card":null,"preprocess":null},{"capture":"doc_number","path":"doc_number","type":"string","card":null,"preprocess":null},{"capture":"edition_value","path":"edition_value","type":"string","card":null,"preprocess":null},{"capture":"volume","path":"volume","type":"string","card":null,"preprocess":null},{"capture":"edition_status","path":"edition_status","type":"string","card":null,"preprocess":null},{"capture":"updated_in","path":"updated_in","type":"string","card":null,"preprocess":null},{"capture":"annex_marker","path":"annex_marker","type":"string","card":null,"preprocess":null},{"capture":"annex_letter","path":"annex_letter","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule series_head: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 1 and 9 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 2 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 2 and 9 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 3 and 9 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 4 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 4 and 6 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 4 and 7 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 4 and 10 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 5 and 6 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 5 and 7 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 5 and 10 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 6 and 7 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 6 and 10 are order-dependent (shared first bytes; ordered choice is decisive)","rule volume_roman: branches 7 and 10 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"WMO-No. 1364","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364, 2025 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364 2025 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364:ed2025","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 1.2.1","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411:ed1.2.1","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 Annex A","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 ANNEX A","expect":{}},{"entry":"identifier","kind":"accept","input":"S-411 Annex A 1.2.0","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 306","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 8, Volume I","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 8, Volume V","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 306, Volume I.1","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 9, Volume D","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 306, Volume I.1, 2020 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 8, 2021/2018 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 1364, 2023 edition, updated in 2025","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO-No. 8, Provisional 2026 edition","expect":{}},{"entry":"identifier","kind":"accept","input":"WMO/TD-No. 196","expect":{}},{"entry":"identifier","kind":"accept","input":"JCOMM Technical Report No. 14","expect":{}},{"entry":"identifier","kind":"accept","input":"GAW Report No. 312","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}},{"entry":"identifier","kind":"reject","input":"WMO-No. edition","expect":{}},{"entry":"identifier","kind":"reject","input":"S-411 1234","expect":{}},{"entry":"identifier","kind":"reject","input":"TD-No. 1265","expect":{}},{"entry":"identifier","kind":"reject","input":"TD No. 196","expect":{}},{"entry":"identifier","kind":"reject","input":"IMO/TD-No. 259","expect":{}},{"entry":"identifier","kind":"reject","input":"WMO/GAW Report No. 285","expect":{}},{"entry":"identifier","kind":"reject","input":"WMO/TD - No. 1469","expect":{}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364","expect":{"series_head":"WMO-No.","doc_number":"1364"}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364, 2025 edition","expect":{"series_head":"WMO-No.","doc_number":"1364","edition_value":"2025"}},{"entry":"identifier","kind":"example","input":"S-411 1.2.1","expect":{"doc_number":"411","edition_value":"1.2.1"}},{"entry":"identifier","kind":"example","input":"S-411 Annex A 1.2.0","expect":{"doc_number":"411","annex_marker":"Annex","annex_letter":"A","edition_value":"1.2.0"}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364:ed2025","expect":{"series_head":"WMO-No.","doc_number":"1364","edition_value":"2025"}},{"entry":"identifier","kind":"example","input":"WMO-No. 306, Volume I.1","expect":{"series_head":"WMO-No.","doc_number":"306","volume":"I.1"}},{"entry":"identifier","kind":"example","input":"WMO-No. 306, Volume I.1, 2020 edition","expect":{"series_head":"WMO-No.","doc_number":"306","volume":"I.1","edition_value":"2020"}},{"entry":"identifier","kind":"example","input":"WMO-No. 8, 2021/2018 edition","expect":{"series_head":"WMO-No.","doc_number":"8","edition_value":"2021/2018"}},{"entry":"identifier","kind":"example","input":"WMO-No. 1364, 2023 edition, updated in 2025","expect":{"series_head":"WMO-No.","doc_number":"1364","edition_value":"2023","updated_in":"2025"}},{"entry":"identifier","kind":"example","input":"WMO-No. 8, Provisional 2026 edition","expect":{"series_head":"WMO-No.","doc_number":"8","edition_status":"Provisional","edition_value":"2026"}},{"entry":"identifier","kind":"example","input":"WMO/TD-No. 196","expect":{"series_head":"WMO/TD-No.","doc_number":"196"}},{"entry":"identifier","kind":"example","input":"JCOMM Technical Report No. 14","expect":{"series_head":"JCOMM Technical Report No.","doc_number":"14"}},{"entry":"identifier","kind":"example","input":"GAW Report No. 312","expect":{"series_head":"GAW Report No.","doc_number":"312"}}],"docs":{},"source":"# WMO document identifiers (pubid#763, widened): the WMO-No. publication\n# series, the WMO-published S-100 product specifications, and the WMO\n# technical-document series (WMO/TD, JCOMM Technical Report, GAW Report).\n#\n# WMO-No. 1364 publication, bare\n# WMO-No. 1364, 2025 edition publication, year edition (citation comma)\n# WMO-No. 1364 2025 edition publication, year edition (cover stack)\n# WMO-No. 1364:ed2025 publication, compact year edition (alias)\n# WMO-No. 8, 2021/2018 edition publication, compound year-pair edition\n# (primary year first, the IMOP wording)\n# WMO-No. 1364, 2023 edition,\n# updated in 2025 publication, edition + updated-in year\n# (library record 69478)\n# WMO-No. 8, Provisional 2026\n# edition publication, status-qualified edition\n# (IMOP Knowledge-Hub)\n# WMO-No. 8, Volume I … V volume face, roman (IMOP Guide page)\n# WMO-No. 306, Volume I.1 dotted-roman sub-volume (record 35713)\n# WMO-No. 9, Volume D letter volume (Resolution 10 (SERCOM-1))\n# WMO/TD-No. 196 the Technical Document series (the\n# library serial \"WMO/TD-No.\"; the PREFIX\n# law of the widening ruling: the bare\n# \"TD-No.\" head names no publisher, so it\n# never parses)\n# JCOMM Technical Report No. 14 the joint WMO/IOC series (self-\n# identifying head)\n# GAW Report No. 312 the GAW series, bare head (WMO's own\n# library records; the prefixed\n# \"WMO/GAW Report No.\" spelling is\n# third-party citation only)\n# S-411 S-100 product specification, bare\n# S-411 1.2.1 dotted edition (the S-411 repo form)\n# S-411:ed1.2.1 compact dotted edition (alias)\n# S-411 Annex A annex wrapper (the DCEG docidentifier)\n# S-411 Annex A 1.2.0 annex wrapper carrying its edition\n#\n# Editions are a type-driven face: the publication series carry calendar-\n# year editions (\"2025 edition\", MRN `ed2025`); the S-100 shapes carry the\n# IHO dotted x.y.z (MRN `ed1.2.1`). Both bind the one `edition_value`\n# capture; the builder keys the face off the resolved type. The compound\n# faces widen the same capture: the year pair (\"2021/2018\") is one\n# edition value — the pair IS the identity face, the dotted-x.y.z rule of\n# the S-100 side applied to years — and the status word (\"Provisional\")\n# and the updated-in year ride their own captures beside it.\n#\n# The volume face precedes the edition face when both appear (the face\n# order of the widening ruling; both faces individually attested on\n# WMO-No. 306 Volume I.1 and the 2020-edition rows).\n#\n# Type assignment (the #763 ruling): the S-lexical form is a WMO type,\n# publisher-parameterised per IALA's S-201 — the lexical shape is the IHO\n# S-100 form, but the flavor owns the WMO-published documents\n# (metanorma/S-411-Product-Specification, mn-document-class wmo).\n#\n# Edition-2 conversion with typed model bindings, mirroring the iala\n# grammar: each alternative path carries at most one occurrence of every\n# capture name, so the harvest delivers one flat bound map; the annex base\n# composite stays unbound (its `doc_number` hoists to the top level) and\n# the builder dispatches on `series_head` / `annex_marker`. The annex\n# letter guard (!lower) keeps a following edition segment from\n# mis-capturing.\n\ngrammar PubidWmo version \"0.2.0\" edition 2 {\n series_head = {\n \"WMO-No.\" as series_head\n / \"WMO/TD-No.\" as series_head\n / \"JCOMM Technical Report No.\" as series_head\n / \"GAW Report No.\" as series_head\n }\n doc_number = (1*digit) as doc_number\n s_code = \"S-\" (1*digit) as doc_number\n year_value = ((4digit) [slash (4digit)]) as edition_value\n dotted_value = (1*digit 1*(dot 1*digit)) as edition_value\n updated_tail = {\n \",\" space \"updated\" space \"in\" space ((4digit) as updated_in)\n }\n edition_year_human = {\n [\",\"] space year_value \" edition\"\n [updated_tail]\n }\n edition_year_compact = (colon \"ed\" year_value) as edition\n edition_status_human = {\n [\",\"] space (\"Provisional\" as edition_status) space year_value \" edition\"\n }\n edition_dotted_human = (space dotted_value) as edition\n edition_dotted_compact = (colon \"ed\" dotted_value) as edition\n volume_roman = {\n \"VIII\" / \"VII\" / \"VI\" / \"III\" / \"II\"\n / \"IX\" / \"IV\" / \"X\" / \"V\" / \"I\"\n }\n volume_value = ((volume_roman / upper) *(dot 1*digit)) as volume\n volume_face = { [\",\"] space \"Volume\" space volume_value }\n annex_identifier = {\n s_code\n space\n (\"Annex\" / \"ANNEX\") as annex_marker\n [ (space upper as annex_letter !lower) ]\n [edition_dotted_human / edition_dotted_compact]\n }\n publication_identifier = {\n series_head space doc_number\n [volume_face]\n [edition_year_human / edition_status_human / edition_year_compact]\n }\n standard_identifier = {\n s_code\n [edition_dotted_human / edition_dotted_compact]\n }\n identifier = annex_identifier / publication_identifier / standard_identifier\n entry identifier: identifier\n\n upper = %x41-5A\n lower = %x61-7A\n digit = %x30-39\n colon = \":\"\n dot = \".\"\n slash = \"/\"\n space = \" \"\n\n bindings identifier {\n series_head -> series_head (string)\n doc_number -> doc_number (string)\n edition_value -> edition_value (string)\n volume -> volume (string)\n edition_status -> edition_status (string)\n updated_in -> updated_in (string)\n annex_marker -> annex_marker (string)\n annex_letter -> annex_letter (string)\n }\n\n test {\n accept \"WMO-No. 1364\"\n accept \"WMO-No. 1364, 2025 edition\"\n accept \"WMO-No. 1364 2025 edition\"\n accept \"WMO-No. 1364:ed2025\"\n accept \"S-411\"\n accept \"S-411 1.2.1\"\n accept \"S-411:ed1.2.1\"\n accept \"S-411 Annex A\"\n accept \"S-411 ANNEX A\"\n accept \"S-411 Annex A 1.2.0\"\n # the widened publication faces\n accept \"WMO-No. 306\"\n accept \"WMO-No. 8, Volume I\"\n accept \"WMO-No. 8, Volume V\"\n accept \"WMO-No. 306, Volume I.1\"\n accept \"WMO-No. 9, Volume D\"\n accept \"WMO-No. 306, Volume I.1, 2020 edition\"\n accept \"WMO-No. 8, 2021/2018 edition\"\n accept \"WMO-No. 1364, 2023 edition, updated in 2025\"\n accept \"WMO-No. 8, Provisional 2026 edition\"\n # the new series heads (the prefix law: every head names its publisher)\n accept \"WMO/TD-No. 196\"\n accept \"JCOMM Technical Report No. 14\"\n accept \"GAW Report No. 312\"\n reject \"nonsense\"\n reject \"WMO-No. edition\"\n reject \"S-411 1234\"\n # the prefix law rejects: a series head that names no publisher (the\n # bare TD-No. spellings), a misattributed publisher (no IMO TD series\n # exists — the wild string is an OCR misread), and the third-party\n # GAW citation form\n reject \"TD-No. 1265\"\n reject \"TD No. 196\"\n reject \"IMO/TD-No. 259\"\n reject \"WMO/GAW Report No. 285\"\n # the spaced cover variant of the TD head (\"WMO/TD - No. 1469\",\n # GAW-183 cover): deliberately outside the grammar — only the glued\n # library-serial head \"WMO/TD-No.\" is defined\n reject \"WMO/TD - No. 1469\"\n example \"WMO-No. 1364\" { series_head: \"WMO-No.\", doc_number: \"1364\" }\n example \"WMO-No. 1364, 2025 edition\" {\n series_head: \"WMO-No.\",\n doc_number: \"1364\",\n edition_value: \"2025\",\n }\n example \"S-411 1.2.1\" { doc_number: \"411\", edition_value: \"1.2.1\" }\n example \"S-411 Annex A 1.2.0\" {\n doc_number: \"411\",\n annex_marker: \"Annex\",\n annex_letter: \"A\",\n edition_value: \"1.2.0\",\n }\n example \"WMO-No. 1364:ed2025\" {\n series_head: \"WMO-No.\",\n doc_number: \"1364\",\n edition_value: \"2025\",\n }\n example \"WMO-No. 306, Volume I.1\" {\n series_head: \"WMO-No.\",\n doc_number: \"306\",\n volume: \"I.1\",\n }\n example \"WMO-No. 306, Volume I.1, 2020 edition\" {\n series_head: \"WMO-No.\",\n doc_number: \"306\",\n volume: \"I.1\",\n edition_value: \"2020\",\n }\n example \"WMO-No. 8, 2021/2018 edition\" {\n series_head: \"WMO-No.\",\n doc_number: \"8\",\n edition_value: \"2021/2018\",\n }\n example \"WMO-No. 1364, 2023 edition, updated in 2025\" {\n series_head: \"WMO-No.\",\n doc_number: \"1364\",\n edition_value: \"2023\",\n updated_in: \"2025\",\n }\n example \"WMO-No. 8, Provisional 2026 edition\" {\n series_head: \"WMO-No.\",\n doc_number: \"8\",\n edition_status: \"Provisional\",\n edition_value: \"2026\",\n }\n example \"WMO/TD-No. 196\" { series_head: \"WMO/TD-No.\", doc_number: \"196\" }\n example \"JCOMM Technical Report No. 14\" {\n series_head: \"JCOMM Technical Report No.\",\n doc_number: \"14\",\n }\n example \"GAW Report No. 312\" {\n series_head: \"GAW Report No.\",\n doc_number: \"312\",\n }\n }\n}\n","source_hash":"19e2416ed1c54b42eda1377b7624c1fe76f7d3093665060dec831c591b04c10d","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:797692d6e72bb5823c9c17c5de2d76b2082df2b241726cc82d73e5442df28972","checksum":"sha256:f45e21fd4eb6b2bed6d5752c1f1e1ebc5036e67d58d7f8fcf1b6b2171a266fef","validated":{"lint_errors":0,"lint_warnings":18,"tests_total":43,"tests_failures":0,"self_test":true}}