@pubid/pubid 0.1.57 → 0.1.59

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.
Files changed (44) hide show
  1. package/dist/flavors/ansi/index.d.ts +1 -22
  2. package/dist/flavors/ansi/index.js +106 -132
  3. package/dist/flavors/ansi/model.d.ts +60 -0
  4. package/dist/flavors/ansi/model.js +107 -0
  5. package/dist/flavors/arxiv/index.d.ts +3 -0
  6. package/dist/flavors/arxiv/index.js +105 -0
  7. package/dist/flavors/arxiv/model.d.ts +51 -0
  8. package/dist/flavors/arxiv/model.js +79 -0
  9. package/dist/flavors/eu/index.d.ts +3 -0
  10. package/dist/flavors/eu/index.js +113 -0
  11. package/dist/flavors/eu/model.d.ts +108 -0
  12. package/dist/flavors/eu/model.js +155 -0
  13. package/dist/flavors/gost/index.js +2 -2
  14. package/dist/flavors/index.js +9 -0
  15. package/dist/flavors/jis/index.js +9 -0
  16. package/dist/flavors/register-types.d.ts +4 -1
  17. package/dist/flavors/register-types.js +4 -1
  18. package/dist/flavors/wmo/index.d.ts +3 -0
  19. package/dist/flavors/wmo/index.js +47 -0
  20. package/dist/flavors/wmo/model.d.ts +82 -0
  21. package/dist/flavors/wmo/model.js +135 -0
  22. package/dist/model/subset-match.d.ts +10 -1
  23. package/dist/model/subset-match.js +35 -1
  24. package/dist/pubid-urn/schemas/ansi.js +3 -0
  25. package/dist/pubid-urn/schemas/arxiv.d.ts +8 -0
  26. package/dist/pubid-urn/schemas/arxiv.js +15 -0
  27. package/dist/pubid-urn/schemas/eu.d.ts +8 -0
  28. package/dist/pubid-urn/schemas/eu.js +15 -0
  29. package/dist/pubid-urn/schemas/index.js +6 -0
  30. package/dist/pubid-urn/schemas/wmo.d.ts +8 -0
  31. package/dist/pubid-urn/schemas/wmo.js +16 -0
  32. package/dist/urn/parsers.js +76 -0
  33. package/package.json +1 -1
  34. package/vendor/parg/ansi.json +1 -1
  35. package/vendor/parg/arxiv.json +1 -0
  36. package/vendor/parg/bsi_pfs.json +1 -1
  37. package/vendor/parg/csv.json +1 -1
  38. package/vendor/parg/eu.json +1 -0
  39. package/vendor/parg/ini.json +1 -1
  40. package/vendor/parg/itu.json +1 -1
  41. package/vendor/parg/json.json +1 -1
  42. package/vendor/parg/lua.json +1 -0
  43. package/vendor/parg/toml.json +1 -0
  44. package/vendor/parg/wmo.json +1 -0
@@ -0,0 +1,82 @@
1
+ import { BaseIdentifier } from "../../model/identifier.js";
2
+ /**
3
+ * The wmo identifier model — lib/pubid/wmo/identifier.rb plus its
4
+ * Identifiers::* leaves. Registration lives HERE (parg-free) so the
5
+ * worker manifest (src/flavors/register-types.ts) can import it without
6
+ * reaching the artifact runtime; the parse entry (./index.js) is the
7
+ * parg-backed half.
8
+ *
9
+ * Two series share the flavor (pubid#763):
10
+ *
11
+ * WMO-No. <number>[, <year> edition] the WMO-No. publication
12
+ * series; editions are calendar
13
+ * years
14
+ * S-<number>[ <x.y.z>] the WMO-published S-100 product
15
+ * specifications; editions are
16
+ * dotted x.y.z (the IHO lexical
17
+ * form, WMO as the assigning
18
+ * authority - the S-201-of-IALA
19
+ * ruling)
20
+ * S-<number> [Annex|ANNEX] [<letter>] [<x.y.z>] annex wrapper
21
+ *
22
+ * 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.
25
+ */
26
+ /**
27
+ * The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
28
+ * assigning authority of the IANA-registered mrn namespace, following
29
+ * the IALA pattern (pubid#763 proposed form):
30
+ *
31
+ * urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
32
+ * urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
33
+ * urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
34
+ */
35
+ declare class WmoUrnGenerator {
36
+ private readonly identifier;
37
+ constructor(identifier: WmoIdentifier);
38
+ generate(): string;
39
+ }
40
+ /** The base WMO identifier (Pubid::Wmo::Identifier). */
41
+ export declare class WmoIdentifier extends BaseIdentifier {
42
+ static polymorphicName: string;
43
+ static attributes: import("../../model/attribute.js").AttributeTable;
44
+ static mappings: import("../../model/attribute.js").FieldMapping[];
45
+ static urnGenerator: typeof WmoUrnGenerator;
46
+ readonly number: string | undefined;
47
+ readonly edition: string | undefined;
48
+ 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. */
52
+ mrEdition(): string | undefined;
53
+ /** "WMO-No." and the S-number are designations, not publisher tokens:
54
+ * the canonical faces carry no publisher prefix. */
55
+ render(): string;
56
+ }
57
+ /** Identifiers::Publication — the WMO-No. series. */
58
+ export declare class WmoPublication extends WmoIdentifier {
59
+ static polymorphicName: string;
60
+ render(): string;
61
+ }
62
+ /** Identifiers::Standard — the WMO-published S-100 specifications. */
63
+ export declare class WmoStandard extends WmoIdentifier {
64
+ static polymorphicName: string;
65
+ }
66
+ /**
67
+ * Identifiers::Annex — an annex to a WMO-published S-100 product
68
+ * specification: "S-411 Annex A" (the DCEG docidentifier). The marker
69
+ * case is preserved (Annex vs ANNEX) for round-trip fidelity; the
70
+ * optional edition applies to the annex itself, not the base.
71
+ */
72
+ export declare class WmoAnnex extends WmoIdentifier {
73
+ static polymorphicName: string;
74
+ static attributes: import("../../model/attribute.js").AttributeTable;
75
+ static mappings: import("../../model/attribute.js").FieldMapping[];
76
+ readonly base: WmoIdentifier | undefined;
77
+ readonly annex_form: string | undefined;
78
+ readonly letter: string | undefined;
79
+ readonly edition: string | undefined;
80
+ render(): string;
81
+ }
82
+ export {};
@@ -0,0 +1,135 @@
1
+ import { BaseIdentifier, registerType } from "../../model/identifier.js";
2
+ import { keyValue, extendAttributes } from "../../model/attribute.js";
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.
26
+ */
27
+ /**
28
+ * The MRN URN generator (lib/pubid/wmo/urn_generator.rb) — the WMO
29
+ * assigning authority of the IANA-registered mrn namespace, following
30
+ * the IALA pattern (pubid#763 proposed form):
31
+ *
32
+ * urn:mrn:wmo:pub:wmo-<number>[:ed<year>] the WMO-No. series
33
+ * urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
34
+ * urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
35
+ */
36
+ class WmoUrnGenerator {
37
+ identifier;
38
+ constructor(identifier) {
39
+ this.identifier = identifier;
40
+ }
41
+ generate() {
42
+ const id = this.identifier;
43
+ if (id instanceof WmoAnnex) {
44
+ 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
+ parts.push(id.letter !== undefined ? `annex-${id.letter.toLowerCase()}` : "annex");
48
+ if (id.edition !== undefined)
49
+ parts.push(`ed${id.edition}`);
50
+ return parts.join(":");
51
+ }
52
+ // The WMO-No. series codes as "wmo-<number>"; the S-100 specs keep
53
+ // their lexical form lowercased ("s-411").
54
+ const code = id instanceof WmoPublication
55
+ ? `wmo-${id.number ?? ""}`
56
+ : `s-${id.number ?? ""}`;
57
+ const parts = ["urn:mrn:wmo:pub", code];
58
+ if (id.edition !== undefined)
59
+ parts.push(`ed${id.edition}`);
60
+ return parts.join(":");
61
+ }
62
+ }
63
+ /** The base WMO identifier (Pubid::Wmo::Identifier). */
64
+ export class WmoIdentifier extends BaseIdentifier {
65
+ static polymorphicName = "pubid:wmo:identifier";
66
+ static attributes = extendAttributes(BaseIdentifier, {
67
+ publisher: { type: "string", default: "WMO" },
68
+ number: { type: "string" },
69
+ // One edition column, type-driven face.
70
+ edition: { type: "string" },
71
+ });
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" });
75
+ 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. */
79
+ mrEdition() {
80
+ return this.edition === undefined ? undefined : `ed${this.edition}`;
81
+ }
82
+ /** "WMO-No." and the S-number are designations, not publisher tokens:
83
+ * the canonical faces carry no publisher prefix. */
84
+ render() {
85
+ return `S-${this.number ?? ""}` +
86
+ (this.edition !== undefined ? ` ${this.edition}` : "");
87
+ }
88
+ }
89
+ /** Identifiers::Publication — the WMO-No. series. */
90
+ export class WmoPublication extends WmoIdentifier {
91
+ static polymorphicName = "pubid:wmo:publication";
92
+ render() {
93
+ let rendered = `WMO-No. ${this.number ?? ""}`;
94
+ if (this.edition !== undefined)
95
+ rendered += `, ${this.edition} edition`;
96
+ return rendered;
97
+ }
98
+ }
99
+ /** Identifiers::Standard — the WMO-published S-100 specifications. */
100
+ export class WmoStandard extends WmoIdentifier {
101
+ static polymorphicName = "pubid:wmo:standard";
102
+ }
103
+ /**
104
+ * Identifiers::Annex — an annex to a WMO-published S-100 product
105
+ * specification: "S-411 Annex A" (the DCEG docidentifier). The marker
106
+ * case is preserved (Annex vs ANNEX) for round-trip fidelity; the
107
+ * optional edition applies to the annex itself, not the base.
108
+ */
109
+ export class WmoAnnex extends WmoIdentifier {
110
+ static polymorphicName = "pubid:wmo:annex";
111
+ static attributes = extendAttributes(WmoIdentifier, {
112
+ // The specification this annex supplements. Always present;
113
+ // carries the S-number (e.g. S-411).
114
+ base: { type: WmoIdentifier },
115
+ // "Annex" or "ANNEX" — preserved verbatim for exact round-trip.
116
+ annex_form: { type: "string" },
117
+ // "A", "B", … or undefined for the bare form.
118
+ letter: { type: "string" },
119
+ });
120
+ static mappings = keyValue(...WmoIdentifier.mappings, { wire: "base", to: "base" }, { wire: "annex_form", to: "annex_form" }, { wire: "letter", to: "letter" });
121
+ render() {
122
+ let rendered = `S-${this.base?.number ?? ""} ${this.annex_form ?? ""}`;
123
+ if (this.letter !== undefined)
124
+ rendered += ` ${this.letter}`;
125
+ if (this.edition !== undefined)
126
+ rendered += ` ${this.edition}`;
127
+ return rendered;
128
+ }
129
+ }
130
+ // The WMO_TYPE_MAP role: the base plus the three concrete leaves (the
131
+ // schema's pubid:wmo:{identifier,publication,standard,annex}).
132
+ registerType(WmoIdentifier);
133
+ registerType(WmoPublication);
134
+ registerType(WmoStandard);
135
+ registerType(WmoAnnex);
@@ -18,7 +18,16 @@
18
18
  * - A STRICT attribute (class `subsetStrict` declaration) is exempt from the
19
19
  * wildcards: the reference always states it, a stated collection must match
20
20
  * in full, and nested matches run in BOTH directions with the class's own
21
- * rule.
21
+ * rule. A blank strict attribute still matches a blank candidate (nil≈empty,
22
+ * the from_hash-dropped-empty tolerance).
23
+ * - An EXACT-BLANK attribute (class `subsetExactBlanks` declaration) goes
24
+ * further: it compares by ABSOLUTE equality, so even blank-vs-blank must
25
+ * hold the same value. The bare SYMBOL face (`symbol: ""`, rendered
26
+ * "…SYMBOL") and the no-symbol face (`symbol` undefined) do not match
27
+ * either way. This is the mirror of the Ruby per-flavor
28
+ * `subset_attribute_match?` overrides (lib/pubid/jis/identifier.rb, pubid
29
+ * main ef8f041c); strict attributes of flavors that do not opt in keep the
30
+ * blank-blank shortcut.
22
31
  * - A reference with `allParts` set skips part/parts/subpart/allParts.
23
32
  * - Nested identifiers and components recurse with their own match; every
24
33
  * other value compares with deep scalar equality.
@@ -18,7 +18,16 @@
18
18
  * - A STRICT attribute (class `subsetStrict` declaration) is exempt from the
19
19
  * wildcards: the reference always states it, a stated collection must match
20
20
  * in full, and nested matches run in BOTH directions with the class's own
21
- * rule.
21
+ * rule. A blank strict attribute still matches a blank candidate (nil≈empty,
22
+ * the from_hash-dropped-empty tolerance).
23
+ * - An EXACT-BLANK attribute (class `subsetExactBlanks` declaration) goes
24
+ * further: it compares by ABSOLUTE equality, so even blank-vs-blank must
25
+ * hold the same value. The bare SYMBOL face (`symbol: ""`, rendered
26
+ * "…SYMBOL") and the no-symbol face (`symbol` undefined) do not match
27
+ * either way. This is the mirror of the Ruby per-flavor
28
+ * `subset_attribute_match?` overrides (lib/pubid/jis/identifier.rb, pubid
29
+ * main ef8f041c); strict attributes of flavors that do not opt in keep the
30
+ * blank-blank shortcut.
22
31
  * - A reference with `allParts` set skips part/parts/subpart/allParts.
23
32
  * - Nested identifiers and components recurse with their own match; every
24
33
  * other value compares with deep scalar equality.
@@ -96,6 +105,18 @@ export function exactMatch(mine, theirs) {
96
105
  }
97
106
  return scalarEqual(mine, theirs);
98
107
  }
108
+ /**
109
+ * An EXACT-BLANK attribute is stated even when blank: the two faces are
110
+ * compared by absolute equality, blank-vs-blank included. This is the
111
+ * per-class mirror of the Ruby flavor's `subset_attribute_match?` override
112
+ * (the JIS symbol law: the bare SYMBOL face and no symbol are distinct
113
+ * states of a two-valued attribute — pubid main ef8f041c). `exactMatch`
114
+ * keeps its blank-blank shortcut for the strict attributes that rely on
115
+ * the from_hash-dropped-empty tolerance.
116
+ */
117
+ function exactBlankMatch(mine, theirs) {
118
+ return scalarEqual(mine, theirs);
119
+ }
99
120
  /**
100
121
  * True when `candidate` holds every part that `reference` states. Both must
101
122
  * be identifiers or components of the same concrete class.
@@ -115,8 +136,17 @@ export function subsetMatch(reference, candidate) {
115
136
  return JSON.stringify(a) === JSON.stringify(b);
116
137
  }
117
138
  const strict = new Set(ctor.subsetStrict ?? []);
139
+ const exactBlanks = new Set(ctor.subsetExactBlanks ?? []);
118
140
  const ignored = new Set([
119
141
  ...(ctor.subsetIgnoredAttributes ?? []),
142
+ // Ruby SubsetMatch#subset_skipped_attributes also skips every
143
+ // `equality_ignored` attribute ("skipped, as == and hash skip it") —
144
+ // jis's language_before_year, eu's number_first (the print ORDER of
145
+ // the two numbers is spelling, so "EU Decision 1082/2013" ===
146
+ // 32013D1082).
147
+ ...Object.entries(ctor.attributes)
148
+ .filter(([, spec]) => spec?.equalityIgnored === true)
149
+ .map(([name]) => name),
120
150
  ...(reference.subsetAllPartsWildcard?.()
121
151
  ? ALL_PARTS_ATTRIBUTES
122
152
  : []),
@@ -127,6 +157,10 @@ export function subsetMatch(reference, candidate) {
127
157
  return true;
128
158
  const mine = reference[name];
129
159
  const theirs = candidate[name];
160
+ // Exact-blank names route before the strict rule: their blanks are
161
+ // distinct values, not the nil≈empty tolerance.
162
+ if (exactBlanks.has(name))
163
+ return exactBlankMatch(mine, theirs);
130
164
  if (strict.has(name))
131
165
  return exactMatch(mine, theirs);
132
166
  return valueMatch(mine, theirs);
@@ -12,6 +12,7 @@ export const ansiSchema = define("ansi", (s) => {
12
12
  s.atom("type.abbr", "type");
13
13
  s.atom("part", "part");
14
14
  s.atom("subpart", "subpart");
15
+ s.atom("revision", "rev");
15
16
  s.atom("year", "year");
16
17
  s.atom("date.year", "dateyear");
17
18
  s.atom("date.month", "datemonth");
@@ -24,6 +25,8 @@ export const ansiSchema = define("ansi", (s) => {
24
25
  s.atom("locality.value", "loc");
25
26
  s.facet("languages.*.original_code", "langsrc");
26
27
  s.facet("edition.original_text", "edsrc");
28
+ s.facet("date_separator", "datesep");
29
+ s.facet("number_separator", "numsep");
27
30
  s.type("pubid:ansi:standard", "std");
28
31
  s.type("pubid:ansi:american-national-standard", "ans");
29
32
  s.type("pubid:ansi:identifier", "id");
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The pubid-scheme URN schema of ARXIV — the transcription
3
+ * of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
4
+ * #670; design in docs/URN-SCHEMES.adoc). GENERATED by
5
+ * scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
6
+ * schema and regenerate, never this table by hand.
7
+ */
8
+ export declare const arxivSchema: import("../schema.js").FlavorSchema;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The pubid-scheme URN schema of ARXIV — the transcription
3
+ * of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
4
+ * #670; design in docs/URN-SCHEMES.adoc). GENERATED by
5
+ * scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
6
+ * schema and regenerate, never this table by hand.
7
+ */
8
+ import { define } from "../index.js";
9
+ export const arxivSchema = define("arxiv", (s) => {
10
+ s.atom("archive", "archive");
11
+ s.atom("subject_class", "sc");
12
+ s.atom("version", "v", "int");
13
+ s.type("pubid:arxiv:eprint", "eprint", { core: [["year", "int"], ["month", "int"], "number"] });
14
+ s.type("pubid:arxiv:identifier", "id", { core: [["year", "int"], ["month", "int"], "number"] });
15
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The pubid-scheme URN schema of EU — the transcription
3
+ * of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
4
+ * #670; design in docs/URN-SCHEMES.adoc). GENERATED by
5
+ * scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
6
+ * schema and regenerate, never this table by hand.
7
+ */
8
+ export declare const euSchema: import("../schema.js").FlavorSchema;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The pubid-scheme URN schema of EU — the transcription
3
+ * of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
4
+ * #670; design in docs/URN-SCHEMES.adoc). GENERATED by
5
+ * scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
6
+ * schema and regenerate, never this table by hand.
7
+ */
8
+ import { define } from "../index.js";
9
+ export const euSchema = define("eu", (s) => {
10
+ s.atom("family", "family");
11
+ s.facet("number_first", "numberfirst", "bool");
12
+ s.type("pubid:eu:regulation", "reg", { core: ["year", "number"] });
13
+ s.type("pubid:eu:directive", "dir", { core: ["year", "number"] });
14
+ s.type("pubid:eu:decision", "dec", { core: ["year", "number"] });
15
+ });
@@ -5,6 +5,7 @@
5
5
  * pubid-urn module builds its flavor lookup lazily from this array.
6
6
  */
7
7
  import { adobeSchema } from "./adobe.js";
8
+ import { arxivSchema } from "./arxiv.js";
8
9
  import { amcaSchema } from "./amca.js";
9
10
  import { ansiSchema } from "./ansi.js";
10
11
  import { apiSchema } from "./api.js";
@@ -26,6 +27,7 @@ import { eascSchema } from "./easc.js";
26
27
  import { ecmaSchema } from "./ecma.js";
27
28
  import { etsiSchema } from "./etsi.js";
28
29
  import { etsiPfsSchema } from "./etsi_pfs.js";
30
+ import { euSchema } from "./eu.js";
29
31
  import { evsSchema } from "./evs.js";
30
32
  import { gbSchema } from "./gb.js";
31
33
  import { gostSchema } from "./gost.js";
@@ -51,10 +53,12 @@ import { saeSchema } from "./sae.js";
51
53
  import { tgppSchema } from "./tgpp.js";
52
54
  import { unSchema } from "./un.js";
53
55
  import { w3cSchema } from "./w3c.js";
56
+ import { wmoSchema } from "./wmo.js";
54
57
  import { xsfSchema } from "./xsf.js";
55
58
  /** All flavor schemas, in the ruby registry order (alphabetical by module). */
56
59
  export const PUBID_URN_SCHEMAS = [
57
60
  adobeSchema,
61
+ arxivSchema,
58
62
  amcaSchema,
59
63
  ansiSchema,
60
64
  apiSchema,
@@ -76,6 +80,7 @@ export const PUBID_URN_SCHEMAS = [
76
80
  ecmaSchema,
77
81
  etsiSchema,
78
82
  etsiPfsSchema,
83
+ euSchema,
79
84
  evsSchema,
80
85
  gbSchema,
81
86
  gostSchema,
@@ -101,5 +106,6 @@ export const PUBID_URN_SCHEMAS = [
101
106
  tgppSchema,
102
107
  unSchema,
103
108
  w3cSchema,
109
+ wmoSchema,
104
110
  xsfSchema,
105
111
  ];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The pubid-scheme URN schema of WMO — the transcription
3
+ * of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
4
+ * #670; design in docs/URN-SCHEMES.adoc). GENERATED by
5
+ * scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
6
+ * schema and regenerate, never this table by hand.
7
+ */
8
+ export declare const wmoSchema: import("../schema.js").FlavorSchema;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The pubid-scheme URN schema of WMO — the transcription
3
+ * of lib/pubid/<flavor>/pubid_urn_schema.rb (pubid#656, completed by
4
+ * #670; design in docs/URN-SCHEMES.adoc). GENERATED by
5
+ * scripts/port-urn-schemas.rb from the ruby declaration: edit the ruby
6
+ * schema and regenerate, never this table by hand.
7
+ */
8
+ import { define } from "../index.js";
9
+ export const wmoSchema = define("wmo", (s) => {
10
+ s.atom("edition", "ed");
11
+ s.atom("annex_form", "annexform");
12
+ s.atom("letter", "letter");
13
+ s.type("pubid:wmo:publication", "pub");
14
+ s.type("pubid:wmo:standard", "std");
15
+ s.type("pubid:wmo:annex", "annex");
16
+ });
@@ -732,6 +732,82 @@ 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.
742
+ wmo: {
743
+ prefix: "urn:mrn:wmo:pub:",
744
+ reconstruct(body, parse) {
745
+ const parts = splitParts(body);
746
+ const code = parts[0];
747
+ if (code === undefined) {
748
+ throw new Error(`Invalid WMO URN code segment: ${JSON.stringify(code)}`);
749
+ }
750
+ const segments = parts.slice(1);
751
+ const editionValue = (seg, shape) => {
752
+ if (!/^ed/i.test(seg)) {
753
+ throw new Error(`Invalid WMO URN segment: ${JSON.stringify(seg)}`);
754
+ }
755
+ const edition = seg.replace(/^ed/i, "");
756
+ if (!shape.test(edition)) {
757
+ throw new Error(`Invalid WMO URN segment: ${JSON.stringify(seg)}`);
758
+ }
759
+ return edition;
760
+ };
761
+ const publication = /^wmo-(\d+)$/i.exec(code);
762
+ if (publication !== null) {
763
+ let edition;
764
+ for (const seg of segments) {
765
+ if (edition !== undefined) {
766
+ throw new Error(`Invalid WMO URN segment (duplicate edition): ${JSON.stringify(seg)}`);
767
+ }
768
+ edition = editionValue(seg, /^\d{4}$/);
769
+ }
770
+ let text = `WMO-No. ${publication[1]}`;
771
+ if (edition !== undefined)
772
+ text += `:ed${edition}`;
773
+ return parse(text);
774
+ }
775
+ const standard = /^s-(\d+)$/i.exec(code);
776
+ if (standard !== null) {
777
+ let annexLetter;
778
+ let edition;
779
+ let hasAnnex = false;
780
+ for (const seg of segments) {
781
+ const annex = /^annex(-([a-z]))?$/i.exec(seg);
782
+ if (annex !== null) {
783
+ if (hasAnnex) {
784
+ throw new Error(`Invalid WMO URN segment (duplicate annex): ${JSON.stringify(seg)}`);
785
+ }
786
+ hasAnnex = true;
787
+ annexLetter = annex[2]?.toUpperCase();
788
+ }
789
+ else {
790
+ if (edition !== undefined) {
791
+ throw new Error(`Invalid WMO URN segment: ${JSON.stringify(seg)}`);
792
+ }
793
+ edition = editionValue(seg, /^\d+(\.\d+)+$/);
794
+ }
795
+ }
796
+ // The annex segment is caseless in the MRN, so the rebuild picks
797
+ // the attested WMO face "Annex" (the DCEG docidentifier); the
798
+ // uppercase "ANNEX" form stays a parse-only human alias.
799
+ let text = `S-${standard[1]}`;
800
+ if (hasAnnex)
801
+ text += " Annex";
802
+ if (annexLetter !== undefined)
803
+ text += ` ${annexLetter}`;
804
+ if (edition !== undefined)
805
+ text += ` ${edition}`;
806
+ return parse(text);
807
+ }
808
+ throw new Error(`Invalid WMO URN code segment: ${JSON.stringify(code)}`);
809
+ },
810
+ },
735
811
  };
736
812
  export function lookupUrnParser(flavor) {
737
813
  return URN_PARSERS[flavor];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubid/pubid",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
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":"PubidAnsi","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":85}},{"Str":{"pattern":"ANSI"}},{"Named":{"name":"publisher","atom":1}},{"Entity":{"atom":18}},{"Entity":{"atom":16}},{"Str":{"pattern":"/"}},{"Str":{"pattern":" "}},{"Repetition":{"atom":6,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"ISO"}},{"Str":{"pattern":"IEC"}},{"Str":{"pattern":"IEEE"}},{"Str":{"pattern":"SAE"}},{"Str":{"pattern":"ASME"}},{"Str":{"pattern":"ASTM"}},{"Alternative":{"atoms":[8,9,10,11,12,13]}},{"Named":{"name":"copublisher","atom":14}},{"Sequence":{"atoms":[5,7,15]}},{"Repetition":{"atom":4,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"copublishers","atom":17}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Std "}},{"Repetition":{"atom":20,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":58}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":23,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":25,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":28,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[27,29]}},{"Repetition":{"atom":30,"min":0,"max":3,"tag":"Repetition"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":32,"min":0,"max":1,"tag":"Repetition"}},{"Repetition":{"atom":33,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":36,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[35,37]}},{"Repetition":{"atom":38,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[24,26,31,34,39]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":41,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":44,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":46,"min":0,"max":1,"tag":"Repetition"}},{"Repetition":{"atom":47,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[43,45,48]}},{"Repetition":{"atom":49,"min":0,"max":2,"tag":"Repetition"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":52,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[51,53]}},{"Repetition":{"atom":54,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[42,50,55]}},{"Alternative":{"atoms":[40,56]}},{"Named":{"name":"number_with_part","atom":57}},{"Entity":{"atom":70}},{"Str":{"pattern":":"}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"20"}},{"Alternative":{"atoms":[61,62]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":64,"min":2,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Lookahead":{"atom":66,"positive":false}},{"Sequence":{"atoms":[63,65,67]}},{"Named":{"name":"date","atom":68}},{"Sequence":{"atoms":[60,69]}},{"Repetition":{"atom":59,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":83}},{"Str":{"pattern":"("}},{"Entity":{"atom":81}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":75,"min":2,"max":null,"tag":"Repetition"}},{"Str":{"pattern":","}},{"Repetition":{"atom":77,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[76,78]}},{"Repetition":{"atom":79,"min":0,"max":null,"tag":"Repetition"}},{"Named":{"name":"languages","atom":80}},{"Str":{"pattern":")"}},{"Sequence":{"atoms":[73,74,82]}},{"Repetition":{"atom":72,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[2,3,19,21,22,71,84]}},{"Entity":{"atom":97}},{"Str":{"pattern":"ANSI"}},{"Named":{"name":"publisher","atom":87}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Std "}},{"Repetition":{"atom":90,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":58}},{"Entity":{"atom":70}},{"Repetition":{"atom":93,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":83}},{"Repetition":{"atom":95,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[88,89,91,92,94,96]}},{"Alternative":{"atoms":[0,86]}}],"root":98},"bindings":[{"capture":"publisher","path":"publisher","type":"string","card":null,"preprocess":null},{"capture":"copublisher","path":"copublishers[].copublisher","type":"string","card":null,"preprocess":null},{"capture":"number_with_part","path":"number_with_part","type":"string","card":null,"preprocess":null},{"capture":"date","path":"date","type":"string","card":null,"preprocess":null},{"capture":"languages","path":"languages","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule organization: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule organization: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule organization: branches 2 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule organization: branches 5 and 6 are order-dependent (shared first bytes; ordered choice is decisive)","rule identifier: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"ANSI C63.4","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/IEEE C63.4","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI Std A119.1","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/ansi/parser.rb: ANSI [copublishers] [Std] number\n# [:year][(languages)]. The number alternatives cover letter-prefixed\n# forms (C37.06.1, N323A) and plain dotted forms (802.1b-1995).\n#\n# Edition-2 notes: letter_head_part / plain_part / year_digits bodies are\n# inlined at the capture sites (a capture wrapping a rule ref expands to\n# element hashes, while the inlined body binds as one scalar string).\n# The copublishers wrapper stays a capture so the tree keeps the\n# {copublishers: [...]} shape the builder reads; the repeats collect by\n# occurrence under copublishers[].copublisher.\n\ngrammar PubidAnsi version \"0.1.0\" edition 2 {\n organization = \"ISO\" / \"IEC\" / \"IEEE\" / \"SAE\" / \"ASME\" / \"ASTM\"\n # The copublisher body is inlined to raw terms: bare rule refs next to\n # a capture drop the capture or materialize stray {slash:} nodes.\n copublisher_item = \"/\" [\" \"] ( \"ISO\" / \"IEC\" / \"IEEE\" / \"SAE\" / \"ASME\" / \"ASTM\" ) as copublisher\n copublishers = ( 1*copublisher_item ) as copublishers\n std_keyword = [\"Std \"]\n number_with_part = {\n (\n ( 1*(%x41-5A) 1*(%x30-39) *3(\".\" 1*(%x30-39)) [*1(%x41-5A)] [(\"-\" 1*(%x30-39))] )\n / ( 1*(%x30-39) *2(\".\" 1*(%x30-39) [*1(%x61-7A)]) [(\"-\" 1*(%x30-39))] )\n ) as number_with_part\n }\n date = \":\" ( (\"19\" / \"20\") 2*(%x30-39) !(%x30-39) ) as date\n languages = ( *( 2*(%x61-7A) [\",\"] ) ) as languages\n language = \"(\" languages \")\"\n identifier_with_copublishers = {\n \"ANSI\" as publisher copublishers \" \" [\"Std \"] number_with_part [date] [language]\n }\n identifier_sole = {\n \"ANSI\" as publisher \" \" [\"Std \"] number_with_part [date] [language]\n }\n identifier = identifier_with_copublishers / identifier_sole\n upper = %x41-5A\n lower = %x61-7A\n digit = %x30-39\n dot = \".\"\n dash = \"-\"\n colon = \":\"\n slash = \"/\"\n space = \" \"\n entry identifier: identifier\n\n bindings identifier {\n publisher -> publisher (string)\n copublisher -> copublishers[].copublisher (string)\n number_with_part -> number_with_part (string)\n date -> date (string)\n languages -> languages (string)\n }\n\n test {\n accept \"ANSI C63.4\"\n accept \"ANSI/IEEE C63.4\"\n accept \"ANSI Std A119.1\"\n reject \"nonsense\"\n }\n}\n","source_hash":"7af31e7ba304c87eeb0d2ca1b94e534831a333153e1cb8db789e7c55eda6cc07","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:3871a8d8fe4577b6f268aedc1d5c0011206f37aff7b3dc0aeeb3ed146f26acad","checksum":"sha256:a545e04d1dca9458894cf7a5a06fc6b4897772df3ab2d31c2b45114fab0dc3b0","validated":{"lint_errors":0,"lint_warnings":5,"tests_total":4,"tests_failures":0,"self_test":true}}
1
+ {"bindings":null,"version":"0.1.0","grammar":"PubidAnsi","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":121}},{"Str":{"pattern":"ANSI"}},{"Named":{"name":"publisher","atom":1}},{"Entity":{"atom":17}},{"Entity":{"atom":15}},{"Str":{"pattern":"/"}},{"Str":{"pattern":" "}},{"Repetition":{"atom":6,"min":0,"max":1,"tag":"Maybe"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Alternative":{"atoms":[9,10]}},{"Repetition":{"atom":11,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[8,12]}},{"Named":{"name":"copublisher","atom":13}},{"Sequence":{"atoms":[5,7,14]}},{"Repetition":{"atom":4,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"copublishers","atom":16}},{"Str":{"pattern":" "}},{"Str":{"pattern":"-"}},{"Named":{"name":"number_separator","atom":19}},{"Alternative":{"atoms":[18,20]}},{"Str":{"pattern":"Std "}},{"Repetition":{"atom":22,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":84}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":25,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":27,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":30,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[29,31]}},{"Repetition":{"atom":32,"min":0,"max":3,"tag":"Repetition"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":34,"min":0,"max":1,"tag":"Repetition"}},{"Repetition":{"atom":35,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":38,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[37,39]}},{"Repetition":{"atom":40,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"-"}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"20"}},{"Alternative":{"atoms":[43,44]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":46,"min":2,"max":2,"tag":"Repetition"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Str":{"pattern":":"}},{"Alternative":{"atoms":[48,49]}},{"Lookahead":{"atom":50,"positive":false}},{"Sequence":{"atoms":[42,45,47,51]}},{"Repetition":{"atom":52,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[26,28,33,36,41,53]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":55,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":58,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":60,"min":0,"max":1,"tag":"Repetition"}},{"Repetition":{"atom":61,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[57,59,62]}},{"Repetition":{"atom":63,"min":0,"max":2,"tag":"Repetition"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":66,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[65,67]}},{"Repetition":{"atom":68,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"-"}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"20"}},{"Alternative":{"atoms":[71,72]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":74,"min":2,"max":2,"tag":"Repetition"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Str":{"pattern":":"}},{"Alternative":{"atoms":[76,77]}},{"Lookahead":{"atom":78,"positive":false}},{"Sequence":{"atoms":[70,73,75,79]}},{"Repetition":{"atom":80,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[56,64,69,81]}},{"Alternative":{"atoms":[54,82]}},{"Named":{"name":"number_with_part","atom":83}},{"Entity":{"atom":93}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Named":{"name":"revision","atom":87}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Alternative":{"atoms":[89,90]}},{"Lookahead":{"atom":91,"positive":false}},{"Sequence":{"atoms":[86,88,92]}},{"Repetition":{"atom":85,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":106}},{"Str":{"pattern":":"}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"20"}},{"Alternative":{"atoms":[97,98]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":100,"min":2,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Lookahead":{"atom":102,"positive":false}},{"Sequence":{"atoms":[99,101,103]}},{"Named":{"name":"date","atom":104}},{"Sequence":{"atoms":[96,105]}},{"Repetition":{"atom":95,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":119}},{"Str":{"pattern":"("}},{"Entity":{"atom":117}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Repetition":{"atom":111,"min":2,"max":null,"tag":"Repetition"}},{"Str":{"pattern":","}},{"Repetition":{"atom":113,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[112,114]}},{"Repetition":{"atom":115,"min":0,"max":null,"tag":"Repetition"}},{"Named":{"name":"languages","atom":116}},{"Str":{"pattern":")"}},{"Sequence":{"atoms":[109,110,118]}},{"Repetition":{"atom":108,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[2,3,21,23,24,94,107,120]}},{"Entity":{"atom":135}},{"Str":{"pattern":"ANSI"}},{"Named":{"name":"publisher","atom":123}},{"Str":{"pattern":" "}},{"Str":{"pattern":"Std "}},{"Repetition":{"atom":126,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":84}},{"Entity":{"atom":93}},{"Repetition":{"atom":129,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":106}},{"Repetition":{"atom":131,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":119}},{"Repetition":{"atom":133,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[124,125,127,128,130,132,134]}},{"Alternative":{"atoms":[0,122]}}],"root":136},"bindings":[{"capture":"publisher","path":"publisher","type":"string","card":null,"preprocess":null},{"capture":"copublisher","path":"copublishers[].copublisher","type":"string","card":null,"preprocess":null},{"capture":"number_separator","path":"number_separator","type":"string","card":null,"preprocess":null},{"capture":"number_with_part","path":"number_with_part","type":"string","card":null,"preprocess":null},{"capture":"revision","path":"revision","type":"string","card":null,"preprocess":null},{"capture":"date","path":"date","type":"string","card":null,"preprocess":null},{"capture":"languages","path":"languages","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule identifier: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"ANSI C63.4","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/IEEE C63.4","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI Std A119.1","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI X9.62-2005","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/UL 94-2023","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/NISO Z39.88-2004","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/ASHRAE/IES 90.1-2019","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/AAMI ST79:2017","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/ISA-5.1-2009","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/ANS-8.1-2014","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/ISA-61511-1-2018","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI/TIA-568.2-D","expect":{}},{"entry":"identifier","kind":"accept","input":"ANSI X9.8-1-2007","expect":{}},{"entry":"identifier","kind":"reject","input":"ANSI/TIA-568.2-DE","expect":{}},{"entry":"identifier","kind":"reject","input":"ANSI X9.8-1-2007:2009","expect":{}},{"entry":"identifier","kind":"reject","input":"ANSI/ul 94-2023","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/ansi/parser.rb: ANSI [copublishers] [Std] number\n# [:year][(languages)]. The number alternatives cover letter-prefixed\n# forms (C37.06.1, N323A) and plain dotted forms (802.1b-1995).\n#\n# Edition-2 notes: letter_head_part / plain_part / year_digits bodies are\n# inlined at the capture sites (a capture wrapping a rule ref expands to\n# element hashes, while the inlined body binds as one scalar string).\n# The copublishers wrapper stays a capture so the tree keeps the\n# {copublishers: [...]} shape the builder reads; the repeats collect by\n# occurrence under copublishers[].copublisher.\n\ngrammar PubidAnsi version \"0.1.0\" edition 2 {\n # Any uppercase developer acronym co-publishes (relaton#45): ASHRAE,\n # UL, NISO, INCITS, HL7, ASC ... An uppercase letter, then uppercase\n # letters or digits. The copublisher body is inlined to raw terms: bare\n # rule refs next to a capture drop the capture or materialize stray\n # {slash:} nodes.\n copublisher_item = \"/\" [\" \"] ( %x41-5A 1*(%x41-5A / %x30-39) ) as copublisher\n copublishers = ( 1*copublisher_item ) as copublishers\n std_keyword = [\"Std \"]\n number_with_part = {\n (\n ( 1*(%x41-5A) 1*(%x30-39) *3(\".\" 1*(%x30-39)) [*1(%x41-5A)] [(\"-\" 1*(%x30-39))] [(\"-\" (\"19\" / \"20\") 2*2(%x30-39) !(%x30-39 / \":\"))] )\n / ( 1*(%x30-39) *2(\".\" 1*(%x30-39) [*1(%x61-7A)]) [(\"-\" 1*(%x30-39))] [(\"-\" (\"19\" / \"20\") 2*2(%x30-39) !(%x30-39 / \":\"))] )\n ) as number_with_part\n }\n # A revision letter after a dash: \"ANSI/TIA-568.2-D\". One uppercase\n # letter, not the start of a word.\n revision = \"-\" ( %x41-5A ) as revision !(%x41-5A / %x30-39)\n date = \":\" ( (\"19\" / \"20\") 2*(%x30-39) !(%x30-39) ) as date\n languages = ( *( 2*(%x61-7A) [\",\"] ) ) as languages\n language = \"(\" languages \")\"\n identifier_with_copublishers = {\n \"ANSI\" as publisher copublishers ( \" \" / ( \"-\" as number_separator ) ) [\"Std \"] number_with_part [revision] [date] [language]\n }\n identifier_sole = {\n \"ANSI\" as publisher \" \" [\"Std \"] number_with_part [revision] [date] [language]\n }\n identifier = identifier_with_copublishers / identifier_sole\n upper = %x41-5A\n lower = %x61-7A\n digit = %x30-39\n dot = \".\"\n dash = \"-\"\n colon = \":\"\n slash = \"/\"\n space = \" \"\n entry identifier: identifier\n\n bindings identifier {\n publisher -> publisher (string)\n copublisher -> copublishers[].copublisher (string)\n number_separator -> number_separator (string)\n number_with_part -> number_with_part (string)\n revision -> revision (string)\n date -> date (string)\n languages -> languages (string)\n }\n\n test {\n accept \"ANSI C63.4\"\n accept \"ANSI/IEEE C63.4\"\n accept \"ANSI Std A119.1\"\n accept \"ANSI X9.62-2005\"\n accept \"ANSI/UL 94-2023\"\n accept \"ANSI/NISO Z39.88-2004\"\n accept \"ANSI/ASHRAE/IES 90.1-2019\"\n accept \"ANSI/AAMI ST79:2017\"\n accept \"ANSI/ISA-5.1-2009\"\n accept \"ANSI/ANS-8.1-2014\"\n accept \"ANSI/ISA-61511-1-2018\"\n accept \"ANSI/TIA-568.2-D\"\n accept \"ANSI X9.8-1-2007\"\n reject \"ANSI/TIA-568.2-DE\"\n reject \"ANSI X9.8-1-2007:2009\"\n reject \"ANSI/ul 94-2023\"\n reject \"nonsense\"\n }\n}\n","source_hash":"7f83a90c91a2f4d44f6f237f6846c459b2f7267bca93dfe4d35d398acc86bac4","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:a06924c35d3c09a9312502da2680f1b4443a6e9ed883b9d65677669c4765f845","checksum":"sha256:4c8463acb6b5bda76db7dc5804dec123b74ca298f3f5ac35aee3b11f07284c57","validated":{"lint_errors":0,"lint_warnings":1,"tests_total":17,"tests_failures":0,"self_test":true}}
@@ -0,0 +1 @@
1
+ {"bindings":null,"version":"0.1.0","grammar":"PubidArxiv","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Entity":{"atom":8}},{"Re":{"pattern":"(?i:arXiv)"}},{"Entity":{"atom":3}},{"Str":{"pattern":":"}},{"Named":{"name":"colon","atom":2}},{"Entity":{"atom":6}},{"Str":{"pattern":" "}},{"Alternative":{"atoms":[4,5]}},{"Sequence":{"atoms":[1,7]}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":21}},{"Entity":{"atom":15}},{"Entity":{"atom":13}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":12,"min":4,"max":4,"tag":"Repetition"}},{"Named":{"name":"yymm","atom":14}},{"Str":{"pattern":"."}},{"Entity":{"atom":20}},{"Entity":{"atom":13}},{"Repetition":{"atom":18,"min":4,"max":5,"tag":"Repetition"}},{"Named":{"name":"number","atom":19}},{"Sequence":{"atoms":[11,16,17]}},{"Entity":{"atom":52}},{"Entity":{"atom":31}},{"Entity":{"atom":25}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Entity":{"atom":25}},{"Str":{"pattern":"-"}},{"Alternative":{"atoms":[26,27]}},{"Repetition":{"atom":28,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[24,29]}},{"Named":{"name":"archive","atom":30}},{"Str":{"pattern":"."}},{"Entity":{"atom":43}},{"Entity":{"atom":37}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Alternative":{"atoms":[35,36]}},{"Entity":{"atom":37}},{"Str":{"pattern":"-"}},{"Alternative":{"atoms":[38,39]}},{"Repetition":{"atom":40,"min":0,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[34,41]}},{"Named":{"name":"subject_class","atom":42}},{"Sequence":{"atoms":[32,33]}},{"Repetition":{"atom":44,"min":0,"max":1,"tag":"Maybe"}},{"Str":{"pattern":"/"}},{"Entity":{"atom":15}},{"Entity":{"atom":51}},{"Entity":{"atom":13}},{"Repetition":{"atom":49,"min":3,"max":3,"tag":"Repetition"}},{"Named":{"name":"number","atom":50}},{"Sequence":{"atoms":[23,45,46,47,48]}},{"Alternative":{"atoms":[10,22]}},{"Entity":{"atom":59}},{"Str":{"pattern":"v"}},{"Entity":{"atom":13}},{"Repetition":{"atom":56,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"version","atom":57}},{"Sequence":{"atoms":[55,58]}},{"Repetition":{"atom":54,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[9,53,60]}}],"root":61},"bindings":[{"capture":"archive","path":"archive","type":"string","card":null,"preprocess":null},{"capture":"subject_class","path":"subject_class","type":"string","card":null,"preprocess":null},{"capture":"yymm","path":"yymm","type":"string","card":null,"preprocess":null},{"capture":"number","path":"number","type":"string","card":null,"preprocess":null},{"capture":"version","path":"version","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"arXiv:2301.00001v1","expect":{}},{"entry":"identifier","kind":"accept","input":"arxiv:0704.0001","expect":{}},{"entry":"identifier","kind":"accept","input":"arXiv hep-th/9901001v2","expect":{}},{"entry":"identifier","kind":"accept","input":"math.GT/0309136","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}},{"entry":"identifier","kind":"reject","input":"2301.001","expect":{}},{"entry":"identifier","kind":"reject","input":"hep-th/99010","expect":{}},{"entry":"identifier","kind":"example","input":"arXiv:2301.00001v1","expect":{"yymm":"2301","number":"00001","version":"1"}},{"entry":"identifier","kind":"example","input":"0704.0001","expect":{"yymm":"0704","number":"0001"}},{"entry":"identifier","kind":"example","input":"hep-th/9901001","expect":{"archive":"hep-th","yymm":"9901","number":"001"}},{"entry":"identifier","kind":"example","input":"math.GT/0309136v2","expect":{"archive":"math","subject_class":"GT","yymm":"0309","number":"136","version":"2"}}],"docs":{},"source":"# arXiv e-print identifiers, per\n# https://info.arxiv.org/help/arxiv_identifier_for_services.html:\n# new form YYMM.NNNN[vN] (0704-1412) and YYMM.NNNNN[vN] (1501 onward)\n# old form archive[.SC]/YYMMNNN[vN] (9108-0703)\n# with an optional, case-insensitive \"arXiv:\" or \"arXiv \" prefix.\n# The date ranges, the month and v0 are checked by the Ruby builder.\n\ngrammar PubidArxiv version \"0.1.0\" edition 2 {\n digit = %x30-39\n lower = %x61-7A\n letter = %x41-5A / %x61-7A\n arxiv_prefix = %i\"arXiv\" (colon / space)\n yymm = (4digit) as yymm\n new_number = (4*5digit) as number\n new_id = yymm \".\" new_number\n archive = (lower *(lower / \"-\")) as archive\n subject_class = (letter *(letter / \"-\")) as subject_class\n old_number = (3digit) as number\n old_id = archive [\".\" subject_class] \"/\" yymm old_number\n version = \"v\" (1*digit) as version\n identifier = [arxiv_prefix] (new_id / old_id) [version]\n space = \" \"\n colon = \":\"\n entry identifier: identifier\n\n # Typed model bindings: every bound capture lands on the\n # consumer model's field of the same name.\n bindings identifier {\n archive -> archive (string)\n subject_class -> subject_class (string)\n yymm -> yymm (string)\n number -> number (string)\n version -> version (string)\n }\n\n\n test {\n accept \"arXiv:2301.00001v1\"\n accept \"arxiv:0704.0001\"\n accept \"arXiv hep-th/9901001v2\"\n accept \"math.GT/0309136\"\n reject \"nonsense\"\n reject \"2301.001\"\n reject \"hep-th/99010\"\n example \"arXiv:2301.00001v1\" { yymm: \"2301\" number: \"00001\" version: \"1\" }\n example \"0704.0001\" { yymm: \"0704\" number: \"0001\" }\n example \"hep-th/9901001\" { archive: \"hep-th\" yymm: \"9901\" number: \"001\" }\n example \"math.GT/0309136v2\" { archive: \"math\" subject_class: \"GT\" yymm: \"0309\" number: \"136\" version: \"2\" }\n }\n}\n","source_hash":"c4b4676d738856a7717100c2a3a0545fa1e5a6b83fbf8b09b08dcbe1c33c4a5e","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.5.1.0","edition":2,"semantics_hash":"sha256:a7a76fd8f3dbc2635edef63cbb9451aba802e36dea8c4b616ddfdeed626834d1","checksum":"sha256:123c27a1f1a4e2f0744d39b70828f66e48bf2841168011daf0dc5b8a6034523e","validated":{"lint_errors":0,"lint_warnings":0,"tests_total":11,"tests_failures":0,"self_test":true}}