@pubid/pubid 0.1.58 → 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.
- package/dist/flavors/ansi/index.d.ts +1 -22
- package/dist/flavors/ansi/index.js +106 -132
- package/dist/flavors/ansi/model.d.ts +60 -0
- package/dist/flavors/ansi/model.js +107 -0
- package/dist/flavors/index.js +3 -0
- package/dist/flavors/register-types.d.ts +2 -1
- package/dist/flavors/register-types.js +2 -1
- package/dist/flavors/wmo/index.d.ts +3 -0
- package/dist/flavors/wmo/index.js +47 -0
- package/dist/flavors/wmo/model.d.ts +82 -0
- package/dist/flavors/wmo/model.js +135 -0
- package/dist/pubid-urn/schemas/ansi.js +3 -0
- package/dist/pubid-urn/schemas/index.js +2 -0
- package/dist/pubid-urn/schemas/wmo.d.ts +8 -0
- package/dist/pubid-urn/schemas/wmo.js +16 -0
- package/dist/urn/parsers.js +76 -0
- package/package.json +1 -1
- package/vendor/parg/ansi.json +1 -1
- package/vendor/parg/itu.json +1 -1
- package/vendor/parg/wmo.json +1 -0
|
@@ -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);
|
|
@@ -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");
|
|
@@ -53,6 +53,7 @@ import { saeSchema } from "./sae.js";
|
|
|
53
53
|
import { tgppSchema } from "./tgpp.js";
|
|
54
54
|
import { unSchema } from "./un.js";
|
|
55
55
|
import { w3cSchema } from "./w3c.js";
|
|
56
|
+
import { wmoSchema } from "./wmo.js";
|
|
56
57
|
import { xsfSchema } from "./xsf.js";
|
|
57
58
|
/** All flavor schemas, in the ruby registry order (alphabetical by module). */
|
|
58
59
|
export const PUBID_URN_SCHEMAS = [
|
|
@@ -105,5 +106,6 @@ export const PUBID_URN_SCHEMAS = [
|
|
|
105
106
|
tgppSchema,
|
|
106
107
|
unSchema,
|
|
107
108
|
w3cSchema,
|
|
109
|
+
wmoSchema,
|
|
108
110
|
xsfSchema,
|
|
109
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
|
+
});
|
package/dist/urn/parsers.js
CHANGED
|
@@ -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.
|
|
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",
|
package/vendor/parg/ansi.json
CHANGED
|
@@ -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}}
|