@pubid/pubid 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifact/corpus.json.gz +0 -0
- package/dist/conformance/cli.js +5 -1
- package/dist/flavors/amca/grammar.d.ts +4 -0
- package/dist/flavors/amca/grammar.js +87 -0
- package/dist/flavors/amca/index.d.ts +4 -0
- package/dist/flavors/amca/index.js +76 -0
- package/dist/flavors/amca/model.d.ts +29 -0
- package/dist/flavors/amca/model.js +146 -0
- package/dist/flavors/ansi/index.d.ts +24 -0
- package/dist/flavors/ansi/index.js +147 -0
- package/dist/flavors/api/grammar.d.ts +4 -0
- package/dist/flavors/api/grammar.js +79 -0
- package/dist/flavors/api/index.d.ts +4 -0
- package/dist/flavors/api/index.js +71 -0
- package/dist/flavors/api/model.d.ts +27 -0
- package/dist/flavors/api/model.js +114 -0
- package/dist/flavors/ashrae/grammar.d.ts +2 -0
- package/dist/flavors/ashrae/grammar.js +667 -0
- package/dist/flavors/ashrae/index.d.ts +4 -0
- package/dist/flavors/ashrae/index.js +306 -0
- package/dist/flavors/ashrae/model.d.ts +87 -0
- package/dist/flavors/ashrae/model.js +335 -0
- package/dist/flavors/ashrae/preprocessor.d.ts +7 -0
- package/dist/flavors/ashrae/preprocessor.js +44 -0
- package/dist/flavors/asme/grammar.d.ts +2 -0
- package/dist/flavors/asme/grammar.js +200 -0
- package/dist/flavors/asme/index.d.ts +4 -0
- package/dist/flavors/asme/index.js +138 -0
- package/dist/flavors/asme/model.d.ts +34 -0
- package/dist/flavors/asme/model.js +123 -0
- package/dist/flavors/astm/grammar.d.ts +2 -0
- package/dist/flavors/astm/grammar.js +110 -0
- package/dist/flavors/astm/index.d.ts +2 -0
- package/dist/flavors/astm/index.js +127 -0
- package/dist/flavors/astm/model.d.ts +42 -0
- package/dist/flavors/astm/model.js +263 -0
- package/dist/flavors/bipm/index.d.ts +30 -0
- package/dist/flavors/bipm/index.js +434 -0
- package/dist/flavors/bsi/grammar.d.ts +4 -0
- package/dist/flavors/bsi/grammar.js +535 -0
- package/dist/flavors/bsi/index.d.ts +4 -0
- package/dist/flavors/bsi/index.js +941 -0
- package/dist/flavors/bsi/model.d.ts +127 -0
- package/dist/flavors/bsi/model.js +863 -0
- package/dist/flavors/calconnect/index.d.ts +21 -0
- package/dist/flavors/calconnect/index.js +113 -0
- package/dist/flavors/cen_cenelec/grammar.d.ts +4 -0
- package/dist/flavors/cen_cenelec/grammar.js +107 -0
- package/dist/flavors/cen_cenelec/index.d.ts +5 -0
- package/dist/flavors/cen_cenelec/index.js +263 -0
- package/dist/flavors/cen_cenelec/model.d.ts +45 -0
- package/dist/flavors/cen_cenelec/model.js +490 -0
- package/dist/flavors/cie/grammar.d.ts +5 -0
- package/dist/flavors/cie/grammar.js +127 -0
- package/dist/flavors/cie/index.d.ts +2 -0
- package/dist/flavors/cie/index.js +311 -0
- package/dist/flavors/cie/model.d.ts +122 -0
- package/dist/flavors/cie/model.js +464 -0
- package/dist/flavors/csa/grammar.d.ts +6 -0
- package/dist/flavors/csa/grammar.js +239 -0
- package/dist/flavors/csa/index.d.ts +2 -0
- package/dist/flavors/csa/index.js +634 -0
- package/dist/flavors/csa/model.d.ts +33 -0
- package/dist/flavors/csa/model.js +505 -0
- package/dist/flavors/doi/index.d.ts +13 -0
- package/dist/flavors/doi/index.js +65 -0
- package/dist/flavors/easc/index.d.ts +4 -0
- package/dist/flavors/easc/index.js +107 -0
- package/dist/flavors/ecma/index.d.ts +4 -0
- package/dist/flavors/ecma/index.js +117 -0
- package/dist/flavors/etsi/index.d.ts +14 -0
- package/dist/flavors/etsi/index.js +307 -0
- package/dist/flavors/evs/grammar.d.ts +2 -0
- package/dist/flavors/evs/grammar.js +22 -0
- package/dist/flavors/evs/index.d.ts +2 -0
- package/dist/flavors/evs/index.js +24 -0
- package/dist/flavors/evs/model.d.ts +19 -0
- package/dist/flavors/evs/model.js +36 -0
- package/dist/flavors/gb/index.d.ts +24 -0
- package/dist/flavors/gb/index.js +111 -0
- package/dist/flavors/gost/grammar.d.ts +2 -0
- package/dist/flavors/gost/grammar.js +46 -0
- package/dist/flavors/gost/index.d.ts +2 -0
- package/dist/flavors/gost/index.js +165 -0
- package/dist/flavors/gost/model.d.ts +61 -0
- package/dist/flavors/gost/model.js +147 -0
- package/dist/flavors/gost/prefix_routes.d.ts +15 -0
- package/dist/flavors/gost/prefix_routes.js +192 -0
- package/dist/flavors/iala/index.d.ts +32 -0
- package/dist/flavors/iala/index.js +300 -0
- package/dist/flavors/iana/index.d.ts +19 -0
- package/dist/flavors/iana/index.js +71 -0
- package/dist/flavors/idf/grammar.d.ts +2 -0
- package/dist/flavors/idf/grammar.js +71 -0
- package/dist/flavors/idf/index.d.ts +2 -0
- package/dist/flavors/idf/index.js +100 -0
- package/dist/flavors/idf/model.d.ts +54 -0
- package/dist/flavors/idf/model.js +359 -0
- package/dist/flavors/iec/grammar.d.ts +3 -0
- package/dist/flavors/iec/grammar.js +187 -0
- package/dist/flavors/iec/index.d.ts +4 -0
- package/dist/flavors/iec/index.js +507 -0
- package/dist/flavors/iec/model.d.ts +54 -0
- package/dist/flavors/iec/model.js +437 -0
- package/dist/flavors/ieee/grammar.d.ts +2 -0
- package/dist/flavors/ieee/grammar.js +626 -0
- package/dist/flavors/ieee/index.d.ts +3 -0
- package/dist/flavors/ieee/index.js +1186 -0
- package/dist/flavors/ieee/model.d.ts +142 -0
- package/dist/flavors/ieee/model.js +1148 -0
- package/dist/flavors/ieee/preprocessor.d.ts +8 -0
- package/dist/flavors/ieee/preprocessor.js +410 -0
- package/dist/flavors/ieee/update_codes.d.ts +8 -0
- package/dist/flavors/ieee/update_codes.js +191 -0
- package/dist/flavors/ietf/index.d.ts +30 -0
- package/dist/flavors/ietf/index.js +151 -0
- package/dist/flavors/iho/index.d.ts +4 -0
- package/dist/flavors/iho/index.js +126 -0
- package/dist/flavors/index.d.ts +9 -0
- package/dist/flavors/index.js +136 -0
- package/dist/flavors/isbn/index.d.ts +13 -0
- package/dist/flavors/isbn/index.js +97 -0
- package/dist/flavors/iso/grammar.d.ts +2 -0
- package/dist/flavors/iso/grammar.js +207 -0
- package/dist/flavors/iso/index.d.ts +2 -0
- package/dist/flavors/iso/index.js +343 -0
- package/dist/flavors/iso/model.d.ts +159 -0
- package/dist/flavors/iso/model.js +802 -0
- package/dist/flavors/iso/stages.generated.d.ts +13 -0
- package/dist/flavors/iso/stages.generated.js +391 -0
- package/dist/flavors/itu/grammar.d.ts +4 -0
- package/dist/flavors/itu/grammar.js +205 -0
- package/dist/flavors/itu/index.d.ts +2 -0
- package/dist/flavors/itu/index.js +224 -0
- package/dist/flavors/itu/model.d.ts +184 -0
- package/dist/flavors/itu/model.js +599 -0
- package/dist/flavors/jcgm/index.d.ts +7 -0
- package/dist/flavors/jcgm/index.js +300 -0
- package/dist/flavors/jis/index.d.ts +4 -0
- package/dist/flavors/jis/index.js +267 -0
- package/dist/flavors/nist/grammar.d.ts +2 -0
- package/dist/flavors/nist/grammar.js +287 -0
- package/dist/flavors/nist/index.d.ts +2 -0
- package/dist/flavors/nist/index.js +1244 -0
- package/dist/flavors/nist/model.d.ts +155 -0
- package/dist/flavors/nist/model.js +823 -0
- package/dist/flavors/nist/preprocessor.d.ts +11 -0
- package/dist/flavors/nist/preprocessor.js +281 -0
- package/dist/flavors/oasis/index.d.ts +23 -0
- package/dist/flavors/oasis/index.js +110 -0
- package/dist/flavors/ogc/index.d.ts +20 -0
- package/dist/flavors/ogc/index.js +75 -0
- package/dist/flavors/oiml/grammar.d.ts +2 -0
- package/dist/flavors/oiml/grammar.js +180 -0
- package/dist/flavors/oiml/implementation.d.ts +9 -0
- package/dist/flavors/oiml/implementation.js +16 -0
- package/dist/flavors/oiml/model.d.ts +4 -0
- package/dist/flavors/oiml/model.js +462 -0
- package/dist/flavors/omg/index.d.ts +14 -0
- package/dist/flavors/omg/index.js +73 -0
- package/dist/flavors/plateau/index.d.ts +4 -0
- package/dist/flavors/plateau/index.js +97 -0
- package/dist/flavors/tgpp/index.d.ts +4 -0
- package/dist/flavors/tgpp/index.js +122 -0
- package/dist/flavors/un/index.d.ts +13 -0
- package/dist/flavors/un/index.js +90 -0
- package/dist/flavors/w3c/index.d.ts +14 -0
- package/dist/flavors/w3c/index.js +148 -0
- package/dist/flavors/xsf/index.d.ts +18 -0
- package/dist/flavors/xsf/index.js +65 -0
- package/dist/grammar/engine.d.ts +78 -0
- package/dist/grammar/engine.js +351 -0
- package/dist/model/attribute.d.ts +54 -0
- package/dist/model/attribute.js +53 -0
- package/dist/model/builder.d.ts +39 -0
- package/dist/model/builder.js +124 -0
- package/dist/model/component.d.ts +70 -0
- package/dist/model/component.js +170 -0
- package/dist/model/identifier.d.ts +83 -0
- package/dist/model/identifier.js +270 -0
- package/dist/model/urn-generator.d.ts +27 -0
- package/dist/model/urn-generator.js +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
import { match, ref, str } from "../../grammar/engine.js";
|
|
2
|
+
/**
|
|
3
|
+
* Port of lib/pubid/ieee/parser.rb (and the aiee/ire/nesc sub-parsers),
|
|
4
|
+
* 1:1. The identifier alternation order is load-bearing.
|
|
5
|
+
|
|
6
|
+
* Parslet notes preserved from the Ruby: sequences fold strings away when a
|
|
7
|
+
* capture appears; `.as()` wraps the whole then-chain it closes; duplicate
|
|
8
|
+
* capture keys in one sequence raise ("Duplicate subtrees"), which the Ruby
|
|
9
|
+
* grammar avoids by design (distinct :trailing_year vs :year keys etc.).
|
|
10
|
+
*/
|
|
11
|
+
const MONTHS = [
|
|
12
|
+
"Sept.", "Oct.", "Nov.", "Dec.", "Jan.", "Feb.", "Mar.", "Apr.",
|
|
13
|
+
"Jun.", "Jul.", "Aug.",
|
|
14
|
+
"January", "February", "March", "April", "May", "June", "July",
|
|
15
|
+
"August", "September", "October", "November", "December",
|
|
16
|
+
"Jan", "Feb", "Mar", "Apr", "Jun", "Jul", "Aug", "Sep", "Sept",
|
|
17
|
+
"Oct", "Nov", "Dec",
|
|
18
|
+
];
|
|
19
|
+
function literalAlternation(tokens) {
|
|
20
|
+
const sorted = [...new Set(tokens)].sort((a, b) => b.length - a.length);
|
|
21
|
+
return sorted.map((t) => str(t)).reduce((a, b) => a.or(b));
|
|
22
|
+
}
|
|
23
|
+
function buildRules() {
|
|
24
|
+
const rules = {};
|
|
25
|
+
const rule = (name, build) => {
|
|
26
|
+
rules[name] = build();
|
|
27
|
+
};
|
|
28
|
+
// Forward-safe rule read (mirrors parslet's named-rule indirection).
|
|
29
|
+
const R = (name) => ref(rules, name);
|
|
30
|
+
const space = str(" ");
|
|
31
|
+
const dash = str("-");
|
|
32
|
+
const dot = str(".");
|
|
33
|
+
const slash = str("/");
|
|
34
|
+
const comma = str(", ");
|
|
35
|
+
const digit = match("[0-9]");
|
|
36
|
+
const digits = digit.repeat(1, Infinity);
|
|
37
|
+
const upper = match("[A-Z]");
|
|
38
|
+
const lower = match("[a-z]");
|
|
39
|
+
const letter = match("[A-Za-z]");
|
|
40
|
+
const anyChar = match("[\\s\\S]");
|
|
41
|
+
const spaceMaybe = () => space.maybe();
|
|
42
|
+
const dashMaybe = () => dash.maybe();
|
|
43
|
+
const monthName = () => literalAlternation(MONTHS);
|
|
44
|
+
const absent = (p) => p.absent();
|
|
45
|
+
rule("year_digits", () => str("19").or(str("20")).then(digit.repeat(2, 2)).then(lower.repeat(0, 2)).then(absent(digits)));
|
|
46
|
+
rule("month_numeric", () => str("0").then(match("[1-9]")).or(str("1").then(match("[0-2]"))));
|
|
47
|
+
rule("date_with_month_text", () => monthName().as("month").then(space).then(R("year_digits").as("year")));
|
|
48
|
+
rule("date_with_month_numeric", () => R("year_digits").as("year").then(dash).then(R("month_numeric").as("month")));
|
|
49
|
+
rule("date_standalone", () => ref(rules, "date_with_month_text")
|
|
50
|
+
.or(ref(rules, "date_with_month_numeric"))
|
|
51
|
+
.or(R("year_digits").as("year")));
|
|
52
|
+
rule("trailing_month_year", () => (comma.or(space)
|
|
53
|
+
.then(monthName().as("trailing_month"))
|
|
54
|
+
.then(space)
|
|
55
|
+
.then(R("year_digits").as("trailing_year"))).or(comma.or(space)
|
|
56
|
+
.then(R("month_numeric").as("trailing_month"))
|
|
57
|
+
.then(space.or(dash))
|
|
58
|
+
.then(R("year_digits").as("trailing_year"))));
|
|
59
|
+
rule("organization", () => literalAlternation([
|
|
60
|
+
"IEEE", "AIEE", "ANSI", "ASA", "ANS", "IEC", "ISO", "ASTM", "CSA",
|
|
61
|
+
"ASME", "NACE", "NSF", "ASHRAE", "NCTA", "AESC", "EIA",
|
|
62
|
+
"USEMCSC", "AMPP", "USAS", "EAB", "MPAI",
|
|
63
|
+
]));
|
|
64
|
+
rule("complex_org_prefix", () => str("ANSI/IEEE-ANS").or(str("ANSI/IEEE")).or(str("ANSI")));
|
|
65
|
+
rule("characteristic_ieee_number", () => (str("C").then(digit.repeat(2, 2)).then(dot).then(digits).then(match("[a-z]").repeat(0, Infinity).maybe())).or(str("802").then(dot).then(digits).then(match("[a-z]").repeat(0, Infinity).maybe())).or(str("P").then(digits.repeat(1, Infinity))));
|
|
66
|
+
rule("publisher", () => R("complex_org_prefix").or(R("organization")).as("publisher"));
|
|
67
|
+
rule("copublisher", () => str("/ISO/IEC").as("copublisher")
|
|
68
|
+
.or(str("/IEC/ISO").as("copublisher"))
|
|
69
|
+
.or(slash.then(spaceMaybe()).then(R("organization").as("copublisher"))));
|
|
70
|
+
rule("conformance", () => (spaceMaybe().then(slash)
|
|
71
|
+
.then(str("Conformance"))
|
|
72
|
+
.then(match("[0-9]").repeat(1, Infinity).as("conf_number"))
|
|
73
|
+
.then(dash)
|
|
74
|
+
.then(R("year_digits").as("conf_year"))).as("conformance"));
|
|
75
|
+
rule("ashrae_copub", () => (slash.then(str("ASHRAE")).then(space)
|
|
76
|
+
.then(str("Guideline").then(space).maybe())
|
|
77
|
+
.then(digits.as("ashrae_number"))
|
|
78
|
+
.then(dash.then(R("year_digits").as("ashrae_year")).maybe())).as("ashrae_copub"));
|
|
79
|
+
rule("ieee_crossref", () => (slash.then(str("C")).then(digits).then(dot).then(digits).then(dot).then(digits)
|
|
80
|
+
.then(dash).then(R("year_digits"))).as("ieee_crossref"));
|
|
81
|
+
rule("ipcea_copub", () => (slash.then(str("IPCEA")).then(space)
|
|
82
|
+
.then(match("[A-Za-z0-9.\\-]").repeat(1, Infinity))).as("ipcea_copub"));
|
|
83
|
+
rule("s_designation", () => (R("publisher").then(space).maybe()).maybe()
|
|
84
|
+
.then((ref(rules, "type_word").as("type").then(spaceMaybe()).maybe()).maybe())
|
|
85
|
+
.then(str("S").then(dash).then(digits).as("s_number"))
|
|
86
|
+
.then(ref(rules, "ipcea_copub").maybe())
|
|
87
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
88
|
+
rule("number", () => (str("P").maybe()
|
|
89
|
+
.then(upper.repeat(0, Infinity)).then(digits).then(digits.or(upper).repeat(0, Infinity))
|
|
90
|
+
.then(dash.then(digits).then(absent(R("year_digits"))).then(dash.then(digits).repeat(0, Infinity)).maybe())
|
|
91
|
+
.then(lower.maybe())).as("number"));
|
|
92
|
+
rule("type_word", () => str("Draft Std")
|
|
93
|
+
.or(str("STD"))
|
|
94
|
+
.or(str("Standard"))
|
|
95
|
+
.or(str("Std No."))
|
|
96
|
+
.or(str("Std"))
|
|
97
|
+
.or(str("PTC"))
|
|
98
|
+
.or(match("[Nn]").then(str("o.")))
|
|
99
|
+
.or(match("[Nn]").then(str("o")))
|
|
100
|
+
.or(str("No")));
|
|
101
|
+
rule("part", () => (dot.or(dash)).then(match("[0-9A-Za-z]").repeat(1, Infinity).as("part")));
|
|
102
|
+
rule("subpart", () => (dot.or(dash).or(str("_"))).then((str("REV").or(str("Rev")).maybe()
|
|
103
|
+
.then(match("[0-9a-z]").repeat(1, Infinity))
|
|
104
|
+
.then(dot.then(digits).maybe())).as("subpart")));
|
|
105
|
+
rule("year", () => dot.or(dash).then(ref(rules, "date_standalone")).then(str("(E)").maybe()));
|
|
106
|
+
rule("draft_status", () => literalAlternation([
|
|
107
|
+
"Active Unapproved", "Active Approved", "Unapproved", "Approved", "Active",
|
|
108
|
+
]).then(space));
|
|
109
|
+
rule("draft_prefix", () => spaceMaybe().then(slash.or(str("_")).or(dash).or(space)));
|
|
110
|
+
rule("draft_version", () => absent(str("R").then(dash))
|
|
111
|
+
.then(str("D").then(absent(str("IS"))).maybe())
|
|
112
|
+
.then((match("[0-9]").repeat(1, 2).then(dot).then(match("[0-9]").repeat(1, 2)).then(lower.maybe())).or(dot.then(digits))
|
|
113
|
+
.or(digits.then(str("+")).then(digits))
|
|
114
|
+
.or(digits.then(dot.maybe()).then(str("e")).then(digits))
|
|
115
|
+
.or(str("-").maybe()
|
|
116
|
+
.then(match("[0-9A-Za-z]").repeat(1, Infinity))
|
|
117
|
+
.then(str("-d").or(str("_").then(match("[0-9A-Za-z]").repeat(0, Infinity))).maybe())).as("draft_version")));
|
|
118
|
+
rule("draft_date", () => (comma.or(space).then(monthName().as("month")).then(space).then(R("year_digits").as("year"))).or(
|
|
119
|
+
// Space-separated bare year after the draft designator
|
|
120
|
+
// ("IEEE Draft Std P14764/D1 2004, Nov 2004" - the "D1 2004" draft
|
|
121
|
+
// carries its own year, with the print date still trailing).
|
|
122
|
+
space.then(R("year_digits").as("year"))).or(comma.or(space).then(R("month_numeric").as("month")).then(space.or(dash)).then(R("year_digits").as("year"))).or((spaceMaybe().then(comma).then(spaceMaybe()).or(space)).then(monthName().as("month")).then((space.then(digits.as("day")).then(comma.or(space).or(dash)).then(R("year_digits").as("year"))).or(space.then(digits.as("day")).maybe().then(comma).then(R("year_digits").as("year"))).or(comma.then(spaceMaybe()).then(R("year_digits").as("year")))
|
|
123
|
+
.or(space.then(R("year_digits").as("year"))))));
|
|
124
|
+
rule("fdraft", () => (slash
|
|
125
|
+
.then(literalAlternation(["FDIS", "CDV", "CD", "WD", "PWI", "NP"]))
|
|
126
|
+
.then((comma.or(space).then(monthName().as("month")).then(space).then(R("year_digits").as("year"))).or(comma.or(space).then(R("year_digits").as("year"))).maybe())
|
|
127
|
+
.then(ref(rules, "parenthetical").maybe())).as("fdraft"));
|
|
128
|
+
rule("draft", () => (ref(rules, "draft_prefix")
|
|
129
|
+
.then(ref(rules, "draft_version").repeat(1, 2))
|
|
130
|
+
.then(dot.then(digits.as("revision")).maybe())
|
|
131
|
+
.then(ref(rules, "draft_date").maybe())).as("draft"));
|
|
132
|
+
rule("revision_suffix", () => slash.then(str("R")).then(dash).then(match("[0-9A-Za-z]").repeat(1, Infinity).as("revision")));
|
|
133
|
+
rule("edition", () => (comma.then(R("year_digits").as("edition_year")).then(str(" Edition"))).or(space.or(dash)
|
|
134
|
+
.then(str("Edition "))
|
|
135
|
+
.then((digits.then(dot).then(digits)).as("edition"))
|
|
136
|
+
.then(str(" - ").or(space).or(dash))
|
|
137
|
+
.then(R("year_digits").as("edition_year"))
|
|
138
|
+
.then(dash.then(digit.repeat(2, 2).as("edition_month")).maybe())));
|
|
139
|
+
rule("part_subpart_year", () => (ref(rules, "part").then(ref(rules, "subpart").repeat(1, 2)).then(ref(rules, "year"))).or(ref(rules, "part").then(ref(rules, "subpart")).then(ref(rules, "year")))
|
|
140
|
+
.or(ref(rules, "part").then(ref(rules, "year")))
|
|
141
|
+
.or(ref(rules, "part").then(ref(rules, "subpart")))
|
|
142
|
+
.or(ref(rules, "year"))
|
|
143
|
+
.or(ref(rules, "part")));
|
|
144
|
+
rule("corrigendum", () => (str("_").or(slash).or(dash).or(space)
|
|
145
|
+
.then(str("Corrigendum").or(str("Cor")))
|
|
146
|
+
.then(dash.or(dot).or(space).maybe())
|
|
147
|
+
.then(spaceMaybe())
|
|
148
|
+
.then(digits.as("cor_number").maybe())
|
|
149
|
+
.then((dash.or(str(":")).or(space)).then(R("year_digits").as("cor_year")).maybe())).as("corrigendum"));
|
|
150
|
+
rule("amendment", () => (str("_").or(slash).or(dash).or(space)
|
|
151
|
+
.then(str("Amendment").or(str("Amd")))
|
|
152
|
+
.then(dash.or(dot).or(space).maybe())
|
|
153
|
+
.then(spaceMaybe())
|
|
154
|
+
.then(digits.as("amd_number").maybe())
|
|
155
|
+
.then((dash.or(str(":")).or(space)).then(R("year_digits").as("amd_year")).maybe())).as("amendment"));
|
|
156
|
+
rule("interpretation", () => (slash.then(str("INT")).then((dash.or(str(":")).or(space)).then(R("year_digits").as("int_year")).maybe())).as("interpretation"));
|
|
157
|
+
rule("reaffirmed", () => (str("Reaffirmed ").then(R("year_digits").as("year"))).or(space.maybe().then(str("(R")).then(R("year_digits").as("year")).then(str(")"))).as("reaffirmed"));
|
|
158
|
+
rule("redline", () => (space.then(dash.then(space).maybe())
|
|
159
|
+
.then(literalAlternation(["Redline", "REDLINE", "redline"]))).as("redline"));
|
|
160
|
+
rule("book_nickname", () => space.then(str("[")).then(match("[^\\]]").repeat(1, Infinity).as("nickname")).then(str("]")));
|
|
161
|
+
const relationshipType = () => literalAlternation([
|
|
162
|
+
"Draft Amendment to ", "DRAFT Amendment to ", "Draft Revision of ",
|
|
163
|
+
"Previously designated as ", "Reaffirmation of ", "Redesignation of ",
|
|
164
|
+
"redesignated as ", "Supersedes ", "Supercedes ", "Includes ",
|
|
165
|
+
"Revision of ", "Revison of ", "Amendment to ", "Corrigendum to ",
|
|
166
|
+
"Corrigenda to ", "incorporates ", "Incorporating ", "Incorporates ",
|
|
167
|
+
"Adoption of ", "Supplement to ",
|
|
168
|
+
]);
|
|
169
|
+
rule("relationship_type", () => (literalAlternation(["Draft Amendment to ", "DRAFT Amendment to "]).as("draft_amendment_to")).or(str("Draft Revision of ").as("draft_revision_of"))
|
|
170
|
+
.or(str("Previously designated as ").as("previously_designated_as"))
|
|
171
|
+
.or(str("Reaffirmation of ").as("reaffirmation_of"))
|
|
172
|
+
.or(literalAlternation(["Redesignation of ", "redesignated as "]).as("redesignation_of"))
|
|
173
|
+
.or(literalAlternation(["Supersedes ", "Supercedes "]).as("supersedes"))
|
|
174
|
+
.or(str("Includes ").as("includes"))
|
|
175
|
+
.or(literalAlternation(["Revision of ", "Revison of "]).as("revision_of"))
|
|
176
|
+
.or(str("Amendment to ").as("amendment_to"))
|
|
177
|
+
.or(literalAlternation(["Corrigendum to ", "Corrigenda to "]).as("corrigendum_to"))
|
|
178
|
+
.or(literalAlternation(["incorporates ", "Incorporating ", "Incorporates "]).as("incorporates"))
|
|
179
|
+
.or(str("Adoption of ").as("adoption_of"))
|
|
180
|
+
.or(str("Supplement to ").as("supplement_to")));
|
|
181
|
+
rule("relationship_separator", () => space.maybe().then(slash).then(space.maybe()).or(space.maybe().then(str(";")).then(space.maybe())).or(space.maybe().then(dash).then(space.maybe())));
|
|
182
|
+
rule("relationship_break", () => ref(rules, "relationship_separator").then(spaceMaybe()).then(ref(rules, "relationship_type")));
|
|
183
|
+
rule("identifier_string", () => (absent(str(", and "))
|
|
184
|
+
.then(absent(str(" and ")))
|
|
185
|
+
.then(absent(str(", ")))
|
|
186
|
+
.then(absent(str(" as amended by ")))
|
|
187
|
+
.then(absent(ref(rules, "relationship_break")))
|
|
188
|
+
.then(absent(str(")")))
|
|
189
|
+
.then(anyChar)).repeat(1, Infinity));
|
|
190
|
+
rule("identifier_list", () => ref(rules, "identifier_string").as("id").then((str(", and ").or(str(" and ")).or(str(", ")).then(ref(rules, "identifier_string").as("id"))).repeat(0, Infinity)));
|
|
191
|
+
rule("as_amended_by_clause", () => str(" as amended by IEEE's ").then(ref(rules, "identifier_list").as("amendments"))
|
|
192
|
+
.or(str(" as amended by ").then(ref(rules, "identifier_list").as("amendments")))
|
|
193
|
+
.or(str(" and its approved amendments").as("approved_amendments")));
|
|
194
|
+
rule("relationship_clause", () => spaceMaybe().then(str("("))
|
|
195
|
+
.then(ref(rules, "relationship_type").as("relationship_type"))
|
|
196
|
+
.then(ref(rules, "identifier_list").as("related_ids"))
|
|
197
|
+
.then(ref(rules, "as_amended_by_clause").maybe())
|
|
198
|
+
.then((ref(rules, "relationship_separator")
|
|
199
|
+
.then(ref(rules, "relationship_type").as("relationship_type"))
|
|
200
|
+
.then(ref(rules, "identifier_list").as("related_ids"))
|
|
201
|
+
.then(ref(rules, "as_amended_by_clause").maybe())).repeat(0, Infinity).as("additional_rels"))
|
|
202
|
+
.then(str(")")));
|
|
203
|
+
rule("title_portion", () => str(":").then(space).then(match("[^\\n]").repeat(1, Infinity).as("title")));
|
|
204
|
+
rule("approved_draft_suffix", () => space.then(str("- (Approved Draft)")).or(space.then(str("(Approved Draft)"))));
|
|
205
|
+
rule("additional_parameters", () => (spaceMaybe().then(str("(")).then(ref(rules, "reaffirmed")
|
|
206
|
+
.or(str("Revision of IEEE Std ").then(spaceMaybe())
|
|
207
|
+
.then(match("[^)]").repeat(1, Infinity).as("revision_of")))
|
|
208
|
+
.or(str("Revison of IEEE Std ").then(spaceMaybe())
|
|
209
|
+
.then(match("[^)]").repeat(1, Infinity).as("revision_of")))
|
|
210
|
+
.or(str("Revision to IEEE Std ").then(spaceMaybe())
|
|
211
|
+
.then(match("[^)]").repeat(1, Infinity).as("revision_of")))
|
|
212
|
+
.or(str("Revison to IEEE Std ").then(spaceMaybe())
|
|
213
|
+
.then(match("[^)]").repeat(1, Infinity).as("revision_of")))
|
|
214
|
+
.or(literalAlternation(["DRAFT", "Draft", "draft"]).then(str(" Amendment to "))
|
|
215
|
+
.then(match("[^)]").repeat(1, Infinity).as("draft_amendment_to")))
|
|
216
|
+
.or(str("Amendment to IEEE Std ").then(spaceMaybe())
|
|
217
|
+
.then(match("[^)]").repeat(1, Infinity).as("amendment_to")))
|
|
218
|
+
.or(str("Adoption of ").then(match("[^)]").repeat(1, Infinity).as("adoption")))
|
|
219
|
+
.or(str("Notebooks").then(spaceMaybe())
|
|
220
|
+
.then(match("[^,\\)]").repeat(1, Infinity).as("notebooks")))
|
|
221
|
+
.or(str("Standard Newspaper(s)").then(spaceMaybe())
|
|
222
|
+
.then(match("[^,\\)]").repeat(1, Infinity).as("standard_newspapers")))
|
|
223
|
+
.or(match("[^)]").repeat(1, Infinity).as("parenthetical_content")))
|
|
224
|
+
.then(str(")").maybe())).as("parameters"));
|
|
225
|
+
rule("parenthetical", () => ref(rules, "relationship_clause").or(ref(rules, "additional_parameters")));
|
|
226
|
+
rule("iec_ieee_copublished", () => str("IEC/IEEE")
|
|
227
|
+
.then(space)
|
|
228
|
+
.then(absent(str("P")))
|
|
229
|
+
.then(match("[^0-9\\n]").repeat(0, Infinity).then(digit).present())
|
|
230
|
+
.then(match("[^\\n]").repeat(1, Infinity).as("content")));
|
|
231
|
+
rule("joint_development_ieee_format", () => literalAlternation(["ISO/IEC/IEEE", "ISO/IEEE", "IEC/IEEE", "IEEE/CSA"]).as("joint_publishers")
|
|
232
|
+
.then(space)
|
|
233
|
+
.then(str("P"))
|
|
234
|
+
.then(digits.as("number"))
|
|
235
|
+
.then((dot.or(dash)).then(digits.as("part")).maybe())
|
|
236
|
+
.then(slash.then(digits).then(dot.then(digits).maybe())
|
|
237
|
+
.then(dash.then(digits.as("draft_version")).maybe()).maybe())
|
|
238
|
+
.then(slash.then(str("D")).then(digits.as("draft_version"))
|
|
239
|
+
.or(comma.then(literalAlternation(["CDV", "FDIS", "CD", "DIS"]).as("iec_stage")).then(digits.maybe().as("stage_iteration"))).maybe())
|
|
240
|
+
.then(ref(rules, "edition").maybe())
|
|
241
|
+
.then((dash.then(R("year_digits").as("year"))).or(comma.maybe().then(space).then(monthName().as("month")).then(spaceMaybe())
|
|
242
|
+
.then(R("year_digits").as("year"))).maybe())
|
|
243
|
+
.then(ref(rules, "revision_suffix").maybe()));
|
|
244
|
+
rule("joint_development_iso_format", () => {
|
|
245
|
+
const isoLed = literalAlternation([
|
|
246
|
+
"ISO/IEC/IEEE", "IEEE/ISO/IEC", "IEEE/IEC/ISO", "ISO/IEEE",
|
|
247
|
+
]);
|
|
248
|
+
const stagedOnly = literalAlternation([
|
|
249
|
+
"IEC/IEEE", "IEEE/IEC", "ISO/IEC", "IEEE",
|
|
250
|
+
]);
|
|
251
|
+
const isoStage = () => str("FDIS")
|
|
252
|
+
.or(str("FCD"))
|
|
253
|
+
.or(str("CDV"))
|
|
254
|
+
.or(str("DIS").then(digit.maybe()))
|
|
255
|
+
.or(str("CD").then(digit.maybe()))
|
|
256
|
+
.or(str("WD"))
|
|
257
|
+
.or(str("PWI"))
|
|
258
|
+
.or(str("NP"))
|
|
259
|
+
.as("iso_stage");
|
|
260
|
+
const stdNoise = () => (space.then(str("Std"))).maybe();
|
|
261
|
+
// The dash-year and ", Month YYYY" spellings are the catalogue-PRINTED
|
|
262
|
+
// joint form; tag them so the builder routes to a Standard. A
|
|
263
|
+
// dash-joined part is tagged too (printed parts spell the dash).
|
|
264
|
+
const dateClause = () => (str(":").then(R("year_digits").as("year"))).or(dash.then(R("year_digits").as("year"))
|
|
265
|
+
.then(dash.then(R("month_numeric").as("month")).maybe())
|
|
266
|
+
.then(str("").as("printed_dash_year"))).or((comma.or(space)).then(monthName().as("month")).then(space)
|
|
267
|
+
.then(R("year_digits").as("year"))
|
|
268
|
+
.then(str("").as("printed_month_year"))).maybe();
|
|
269
|
+
return (isoLed.as("joint_publishers").then(space)
|
|
270
|
+
.then(isoStage().then(stdNoise()).then(space)
|
|
271
|
+
.or(str("").as("iso_published").then(spaceMaybe())))
|
|
272
|
+
.or(stagedOnly.as("joint_publishers").then(space).then(isoStage()).then(stdNoise()).then(space)))
|
|
273
|
+
.then(str("P").maybe())
|
|
274
|
+
.then(digits.as("number"))
|
|
275
|
+
.then((dot.then(absent(R("year_digits"))).then(digits.as("part")))
|
|
276
|
+
.or(dash.then(str("").as("part_dash")).then(absent(R("year_digits")))
|
|
277
|
+
.then(digits.as("part")))
|
|
278
|
+
.maybe())
|
|
279
|
+
.then(dateClause())
|
|
280
|
+
.then((slash.then(str("D")).then(dashMaybe())
|
|
281
|
+
.then(match("[0-9.]").repeat(1, Infinity).as("draft_version"))
|
|
282
|
+
.then(((comma.or(space)).then(monthName().as("draft_month")).then(space)
|
|
283
|
+
.then(R("year_digits").as("draft_year"))).or(comma.then(R("year_digits").as("draft_year"))).maybe())).maybe())
|
|
284
|
+
.then((slash.then(str("Amd")).then(dot.or(space).maybe())
|
|
285
|
+
.then(digits.as("amd_number"))
|
|
286
|
+
.then((str(":").or(dash)).then(R("year_digits").as("amd_year")).maybe())).maybe())
|
|
287
|
+
.then(ref(rules, "edition").maybe())
|
|
288
|
+
.then(ref(rules, "revision_suffix").maybe())
|
|
289
|
+
.then(ref(rules, "parenthetical").maybe());
|
|
290
|
+
});
|
|
291
|
+
rule("joint_development_embedded_stage", () => literalAlternation([
|
|
292
|
+
"ISO/IEC/IEEE", "IEEE/ISO/IEC", "IEEE/IEC/ISO", "ISO/IEEE",
|
|
293
|
+
"IEC/IEEE", "IEEE/IEC", "ISO/IEC", "IEEE",
|
|
294
|
+
]).as("joint_publishers")
|
|
295
|
+
.then(space)
|
|
296
|
+
.then(str("P").maybe())
|
|
297
|
+
.then(digits.as("number"))
|
|
298
|
+
.then((dot.or(dash)).then(absent(R("year_digits"))).then(digits.as("part")).maybe())
|
|
299
|
+
.then(dot)
|
|
300
|
+
.then(str("FDIS")
|
|
301
|
+
.or(str("FCD"))
|
|
302
|
+
.or(str("CDV"))
|
|
303
|
+
.or(str("DIS").then(digit.maybe()))
|
|
304
|
+
.or(str("CD").then(digit.maybe()))
|
|
305
|
+
.or(str("WD"))
|
|
306
|
+
.or(str("PWI"))
|
|
307
|
+
.or(str("NP"))
|
|
308
|
+
.as("iso_stage"))
|
|
309
|
+
.then(absent(digit.or(letter)))
|
|
310
|
+
.then((str(":").then(R("year_digits").as("year"))).or(dash.then(R("year_digits").as("year"))
|
|
311
|
+
.then(dash.then(R("month_numeric").as("month")).maybe())).or((comma.or(space)).then(monthName().as("month")).then(space)
|
|
312
|
+
.then(R("year_digits").as("year"))).maybe()));
|
|
313
|
+
rule("number_first_identifier", () => ref(rules, "number")
|
|
314
|
+
.then(dash.then(R("year_digits").as("year")).maybe())
|
|
315
|
+
.then(space)
|
|
316
|
+
.then((R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers"))).as("publishers"))
|
|
317
|
+
.then(space)
|
|
318
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
319
|
+
.then(match("[^\\n]").repeat(0, Infinity).as("title")));
|
|
320
|
+
rule("ieee_p_identifier", () => (str("IEEE").as("publisher").then(space).maybe())
|
|
321
|
+
.then(ref(rules, "number"))
|
|
322
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())
|
|
323
|
+
.then((slash.then(digits.as("draft_version"))).as("digit_draft").maybe())
|
|
324
|
+
.then(ref(rules, "fdraft").maybe())
|
|
325
|
+
.then(ref(rules, "trailing_month_year").maybe())
|
|
326
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
327
|
+
.then(ref(rules, "draft").maybe())
|
|
328
|
+
.then(ref(rules, "revision_suffix").maybe())
|
|
329
|
+
.then(ref(rules, "trailing_month_year").maybe())
|
|
330
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
331
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
332
|
+
rule("ansi_p_identifier", () => str("ANSI").as("publisher")
|
|
333
|
+
.then(space)
|
|
334
|
+
.then(str("P"))
|
|
335
|
+
.then(spaceMaybe())
|
|
336
|
+
.then(ref(rules, "number"))
|
|
337
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())
|
|
338
|
+
.then(ref(rules, "trailing_month_year").maybe())
|
|
339
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
340
|
+
.then(ref(rules, "draft").maybe())
|
|
341
|
+
.then(ref(rules, "revision_suffix").maybe())
|
|
342
|
+
.then(ref(rules, "trailing_month_year").maybe())
|
|
343
|
+
.then((comma.or(space)).then(R("year_digits").as("trailing_year")).maybe())
|
|
344
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
345
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
346
|
+
rule("ieee_draft_p_identifier", () => (str("IEEE").as("publisher").then(space).maybe())
|
|
347
|
+
.then(ref(rules, "draft_status").as("draft_status").maybe())
|
|
348
|
+
.then(str("Draft"))
|
|
349
|
+
.then(space)
|
|
350
|
+
.then(ref(rules, "number"))
|
|
351
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())
|
|
352
|
+
.then((space.then(monthName().as("trailing_month")).then(space)
|
|
353
|
+
.then(R("year_digits").as("trailing_year"))).or(space.then(R("month_numeric").as("trailing_month")).then(space.or(dash))
|
|
354
|
+
.then(R("year_digits").as("trailing_year"))).maybe())
|
|
355
|
+
.then(ref(rules, "draft").maybe())
|
|
356
|
+
.then(ref(rules, "revision_suffix").maybe())
|
|
357
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
358
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
359
|
+
rule("ieee_approved_draft_identifier", () => str("IEEE").as("publisher")
|
|
360
|
+
.then(space)
|
|
361
|
+
.then(str("Approved"))
|
|
362
|
+
.then(space)
|
|
363
|
+
.then(str("Draft Std").or(str("Std")).as("type"))
|
|
364
|
+
.then(space)
|
|
365
|
+
.then(str("P").maybe())
|
|
366
|
+
.then(ref(rules, "number"))
|
|
367
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())
|
|
368
|
+
.then(ref(rules, "draft").maybe())
|
|
369
|
+
.then(ref(rules, "revision_suffix").maybe())
|
|
370
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
371
|
+
// --- AIEE sub-parser ----------------------------------------------------
|
|
372
|
+
rule("aiee_year", () => str("18").then(digit.repeat(2, 2))
|
|
373
|
+
.or(str("19").then(literalAlternation(["0", "1", "2", "3", "4", "5"]).then(digit)))
|
|
374
|
+
.or(str("196").then(match("[0-3]"))));
|
|
375
|
+
rule("aiee_prefix", () => literalAlternation(["IEEE-AIEE", "A.I.E.E.", "A. I. E. E.", "AIEE"]).as("publisher"));
|
|
376
|
+
rule("aiee_type", () => literalAlternation([
|
|
377
|
+
"Standard No.", "Standard No", "Std No.", "Std No", "Std", "Nos",
|
|
378
|
+
"No.", "No", "no", "Standard", "Trans.",
|
|
379
|
+
]).as("type"));
|
|
380
|
+
rule("aiee_number", () => ((upper.repeat(2, 3).then(dash).then(digits)).or(digits.then(upper).then(absent(space.then(str("and"))))).or(digits.then(dot).then(digits))
|
|
381
|
+
.or(digits.as("main_number").then(space)
|
|
382
|
+
.then((str("(").then(digits.as("alt_number")).then(str(")"))).as("parenthetical")))
|
|
383
|
+
.or(digits.then(absent(space.then(str("and")).then(space).then(digits))))).as("number"));
|
|
384
|
+
rule("aiee_date_short", () => space.maybe().then(dash).then(R("aiee_year").as("year")));
|
|
385
|
+
rule("aiee_date_long", () => spaceMaybe().then(((str(",").or(dot)).as("separator").then(spaceMaybe())
|
|
386
|
+
.then(monthName().as("month").then(space).maybe())
|
|
387
|
+
.then(R("aiee_year").as("year"))).or(monthName().as("month").then(dash).then(R("aiee_year").as("year")))));
|
|
388
|
+
rule("aiee_date", () => ref(rules, "aiee_date_short").or(ref(rules, "aiee_date_long")).maybe());
|
|
389
|
+
rule("aiee_identifier", () => ref(rules, "aiee_prefix")
|
|
390
|
+
.then(space)
|
|
391
|
+
.then(ref(rules, "aiee_type").then(space).maybe())
|
|
392
|
+
.then(ref(rules, "aiee_number"))
|
|
393
|
+
.then(ref(rules, "aiee_date")));
|
|
394
|
+
// --- IRE sub-parser -----------------------------------------------------
|
|
395
|
+
rule("ire_year_full", () => str("191").then(digit.repeat(1, 1))
|
|
396
|
+
.or(str("19").then(literalAlternation(["2", "3", "4", "5"])).then(digit))
|
|
397
|
+
.or(str("196").then(match("[0-3]"))));
|
|
398
|
+
rule("ire_year_short", () => match("[1-6]").then(digit));
|
|
399
|
+
rule("ire_prefix", () => str("IEEE-IRE").or(str("IRE")).as("publisher"));
|
|
400
|
+
rule("ire_type", () => literalAlternation(["Trans.", "Standard", "Std"]).as("type"));
|
|
401
|
+
rule("ire_number", () => ((digits.then(space.or(dot)).then(upper).then(digits)).or(digits.then(dot).then(str("IRE")).then(digits).then(dot).then(digits).then(upper).then(digits)).or(upper.repeat(2, 4).then(dash).then(digits))
|
|
402
|
+
.or(digits)).as("number"));
|
|
403
|
+
rule("ire_date", () => (spaceMaybe().then(dash.or(str(",")).maybe()).then(spaceMaybe())
|
|
404
|
+
.then(ref(rules, "ire_year_full").or(ref(rules, "ire_year_short")).as("year"))).maybe());
|
|
405
|
+
rule("ire_identifier", () => (ref(rules, "ire_year_full").or(ref(rules, "ire_year_short")).as("year")
|
|
406
|
+
.then(space)
|
|
407
|
+
.then(ref(rules, "ire_prefix"))
|
|
408
|
+
.then(space)
|
|
409
|
+
.then(ref(rules, "ire_type").then(space).maybe())
|
|
410
|
+
.then(ref(rules, "ire_number"))
|
|
411
|
+
.then(spaceMaybe().then(dash.or(str(",")).maybe()).then(spaceMaybe())
|
|
412
|
+
.then(ref(rules, "ire_year_full").as("full_year")).maybe())).or(ref(rules, "ire_prefix")
|
|
413
|
+
.then(space)
|
|
414
|
+
.then(ref(rules, "ire_type").then(space).maybe())
|
|
415
|
+
.then(ref(rules, "ire_number"))
|
|
416
|
+
.then(ref(rules, "ire_date"))));
|
|
417
|
+
// --- NESC sub-parser ----------------------------------------------------
|
|
418
|
+
rule("nesc_c2_code", () => str("C2").as("code"));
|
|
419
|
+
rule("nesc_full_name", () => str("National Electrical Safety Code").or(str("National Electric Safety Code")));
|
|
420
|
+
rule("nesc_registered", () => str("(R)"));
|
|
421
|
+
rule("nesc_edition", () => literalAlternation([
|
|
422
|
+
"Premier Edition", "First Edition", "Second Edition", "Third Edition",
|
|
423
|
+
"Fourth Edition", "Fifth Edition", "Sixth Edition", "Seventh Edition",
|
|
424
|
+
"Eighth Edition", "Ninth Edition", "Tenth Edition",
|
|
425
|
+
]).as("edition"));
|
|
426
|
+
rule("nesc_variant", () => str("Handbook").or(str("Redline")).as("variant"));
|
|
427
|
+
rule("nesc_month", () => literalAlternation([
|
|
428
|
+
"January", "February", "March", "April", "May", "June", "July",
|
|
429
|
+
"August", "September", "October", "November", "December",
|
|
430
|
+
]).as("month"));
|
|
431
|
+
rule("nesc_c2_standard", () => ref(rules, "nesc_c2_code")
|
|
432
|
+
.then(dash)
|
|
433
|
+
.then(digit.repeat(4, 4).as("year"))
|
|
434
|
+
.then(str(",").maybe().then(space).maybe())
|
|
435
|
+
.then(ref(rules, "nesc_full_name"))
|
|
436
|
+
.then(ref(rules, "nesc_registered").maybe())
|
|
437
|
+
.then(space.then(str("(")).then(str("NESC")).then(ref(rules, "nesc_registered").maybe())
|
|
438
|
+
.then(str(")")).maybe()));
|
|
439
|
+
rule("nesc_year_first", () => str("IEEE").then(space).then(str("Std")).then(space).maybe()
|
|
440
|
+
.then(digit.repeat(4, 4).as("year"))
|
|
441
|
+
.then(space)
|
|
442
|
+
.then((ref(rules, "nesc_full_name").as("full_name")
|
|
443
|
+
.then(ref(rules, "nesc_registered").as("name_registered").maybe())
|
|
444
|
+
.then(space.then(str("(")).then(str("NESC").as("paren_abbr"))
|
|
445
|
+
.then(ref(rules, "nesc_registered").as("paren_registered").maybe())
|
|
446
|
+
.then(str(")")).maybe())).or(str("NESC").as("abbr").then(ref(rules, "nesc_registered").as("abbr_registered").maybe())))
|
|
447
|
+
.then(space.then(ref(rules, "nesc_variant")).maybe())
|
|
448
|
+
.then(str(",").then(space).then(ref(rules, "nesc_edition")).maybe()));
|
|
449
|
+
rule("nesc_name_first", () => ref(rules, "nesc_full_name")
|
|
450
|
+
.then(ref(rules, "nesc_registered").maybe())
|
|
451
|
+
.then(str(","))
|
|
452
|
+
.then(space)
|
|
453
|
+
.then(ref(rules, "nesc_c2_code"))
|
|
454
|
+
.then(dash)
|
|
455
|
+
.then(digit.repeat(4, 4).as("year"))
|
|
456
|
+
.then(space.then(str("-")).then(space).then(ref(rules, "nesc_variant")).as("variant").maybe()));
|
|
457
|
+
rule("nesc_draft_nesc", () => str("Draft").as("draft")
|
|
458
|
+
.then(space)
|
|
459
|
+
.then(ref(rules, "nesc_full_name").or(str("NESC")))
|
|
460
|
+
.then(ref(rules, "nesc_registered").maybe())
|
|
461
|
+
.then(str(","))
|
|
462
|
+
.then(space)
|
|
463
|
+
.then(ref(rules, "nesc_month"))
|
|
464
|
+
.then(space)
|
|
465
|
+
.then(digit.repeat(4, 4).as("year")));
|
|
466
|
+
rule("nesc_identifier", () => ref(rules, "nesc_draft_nesc")
|
|
467
|
+
.or(ref(rules, "nesc_name_first"))
|
|
468
|
+
.or(ref(rules, "nesc_c2_standard"))
|
|
469
|
+
.or(ref(rules, "nesc_year_first")));
|
|
470
|
+
// --- PSI/SI -------------------------------------------------------------
|
|
471
|
+
rule("psi_draft", () => slash.then(str("D")).then(dashMaybe()).then(digits.as("draft_version")));
|
|
472
|
+
rule("psi_date", () => (comma.then(monthName().or(R("month_numeric")).as("month")).then(space.or(dash))
|
|
473
|
+
.then(R("year_digits").as("year"))).or(dash.then(R("year_digits").as("year"))
|
|
474
|
+
.then(dash.then(digit.repeat(2, 2).as("month")).maybe())));
|
|
475
|
+
rule("ieee_astm_si_psi", () => str("IEEE/ASTM").or(str("IEEE")).as("publishers")
|
|
476
|
+
.then(space)
|
|
477
|
+
.then(str("PSI").or(str("SI")).as("si_type"))
|
|
478
|
+
.then(space.or(str(".")))
|
|
479
|
+
.then(digits.as("number"))
|
|
480
|
+
.then(str(".").then(R("year_digits").as("year")).maybe())
|
|
481
|
+
.then((ref(rules, "psi_draft").then(ref(rules, "psi_date").maybe())).or(ref(rules, "psi_date").then(ref(rules, "psi_draft").maybe())).maybe())
|
|
482
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
483
|
+
rule("no_prefix_ieee", () => R("characteristic_ieee_number").as("number")
|
|
484
|
+
.then((dash.then(letter)).maybe().as("suffix"))
|
|
485
|
+
.then((dash.then(R("year_digits"))).maybe().as("year"))
|
|
486
|
+
.then(ref(rules, "draft").maybe())
|
|
487
|
+
.then(str("(E)").or(str("(F)")).maybe())
|
|
488
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
489
|
+
rule("corrigendum_identifier", () => (R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers")).as("publishers")
|
|
490
|
+
.then(space).maybe()).maybe()
|
|
491
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
492
|
+
.then(ref(rules, "number"))
|
|
493
|
+
.then(ref(rules, "part_subpart_year").maybe())
|
|
494
|
+
.as("base")
|
|
495
|
+
.then(slash.or(dash).or(space))
|
|
496
|
+
.then(str("Cor"))
|
|
497
|
+
.then(dash.or(dot).or(space).maybe())
|
|
498
|
+
.then(spaceMaybe())
|
|
499
|
+
.then(digits.as("cor_number"))
|
|
500
|
+
.then((dash.or(str(":")).or(space)).then(R("year_digits").as("cor_year")).maybe())
|
|
501
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
502
|
+
rule("interpretation_identifier", () => (R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers")).as("publishers")
|
|
503
|
+
.then(space).maybe()).maybe()
|
|
504
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
505
|
+
.then(ref(rules, "number"))
|
|
506
|
+
.then(ref(rules, "part_subpart_year").maybe())
|
|
507
|
+
.as("base")
|
|
508
|
+
.then(slash.or(dash).or(space))
|
|
509
|
+
.then(str("INT"))
|
|
510
|
+
.then((dash.or(str(":")).or(space)).then(R("year_digits").as("int_year")).maybe())
|
|
511
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
512
|
+
rule("conformance_identifier", () => (R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers")).as("publishers")
|
|
513
|
+
.then(space).maybe()).maybe()
|
|
514
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
515
|
+
.then(ref(rules, "number"))
|
|
516
|
+
.then(ref(rules, "part_subpart_year").maybe())
|
|
517
|
+
.as("base")
|
|
518
|
+
.then(slash.or(dash).or(space))
|
|
519
|
+
.then(str("Conformance"))
|
|
520
|
+
.then(match("[0-9]").repeat(1, Infinity).as("conf_number"))
|
|
521
|
+
.then(dash)
|
|
522
|
+
.then(R("year_digits").as("conf_year"))
|
|
523
|
+
.then(ref(rules, "parenthetical").maybe()));
|
|
524
|
+
rule("multi_numbered_identifier", () => ((R("publisher").then(space).maybe()).maybe()
|
|
525
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
526
|
+
.then(ref(rules, "number"))
|
|
527
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())).as("primary_identifier")
|
|
528
|
+
.then(((slash.then(str("C")).then(digits).then(dot).then(digits).then(dot).then(digits)
|
|
529
|
+
.then(dash).then(R("year_digits"))).as("secondary_crossref")))
|
|
530
|
+
.or(str(",").then(space)
|
|
531
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
532
|
+
.then(ref(rules, "number"))
|
|
533
|
+
.then(dash)
|
|
534
|
+
.then(R("year_digits"))
|
|
535
|
+
.as("secondary_joint")));
|
|
536
|
+
rule("csa_dual_published", () => (R("publisher").then(space)
|
|
537
|
+
.then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
|
|
538
|
+
.then(ref(rules, "number"))
|
|
539
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())).as("ieee_portion")
|
|
540
|
+
.then(slash)
|
|
541
|
+
.then(str("CSA"))
|
|
542
|
+
.then(space)
|
|
543
|
+
.then(((str("C").then(digit.repeat(2, 2)).then(dot).then(digit).then(space)
|
|
544
|
+
.then(str("No").or(str("NO"))).then(dot)
|
|
545
|
+
.then(space).then(match("[0-9.]").repeat(1, Infinity))
|
|
546
|
+
.then(dash.or(str(":"))).then(digit.repeat(2, 2))).or(str("C").then(match("[0-9.]").repeat(1, Infinity)).then(dash).then(digit.repeat(2, 2))).or(str("C").then(digit.repeat(2, 2)).then(dot).then(digit).then(space)
|
|
547
|
+
.then(str("No").or(str("NO")))
|
|
548
|
+
.then(dot).then(space).then(match("[0-9.]").repeat(1, Infinity))
|
|
549
|
+
.then(str(":")).then(digit.repeat(2, 2))).or(str("C").then(match("[0-9.]").repeat(1, Infinity)).then(str(":")).then(digit.repeat(2, 2)))).as("csa_portion")));
|
|
550
|
+
rule("combined_aiee_identifier", () => ref(rules, "aiee_identifier").as("first_aiee")
|
|
551
|
+
.then(space)
|
|
552
|
+
.then(str("and"))
|
|
553
|
+
.then(space)
|
|
554
|
+
.then(ref(rules, "aiee_identifier").as("second_aiee")));
|
|
555
|
+
rule("aiee_delegation", () => ((str("IEEE-AIEE").then(space).then(literalAlternation(["No.", "Nos", "No", "Standard", "Trans."]))).or(str("A.I.E.E.").then(space).then(literalAlternation(["No.", "Nos", "No"]))).or(str("A. I. E. E.").then(space).then(literalAlternation(["No.", "Nos", "No", "Standard"]))).or(str("AIEE").then(space).then(literalAlternation(["No.", "Nos", "No", "Standard", "Trans.", "Std"])))).present()
|
|
556
|
+
.then(ref(rules, "aiee_identifier").as("aiee")));
|
|
557
|
+
rule("ire_delegation", () => ((match("[1-6]").then(digit).then(space).then(str("IRE"))).or(str("19").then(digit.repeat(2, 2)).then(space).then(str("IRE"))).or(str("IRE").then(space).then(digits.or(str("Standard")).or(str("Std")).or(str("Trans")))).or(str("IEEE-IRE").then(space))).present()
|
|
558
|
+
.then(ref(rules, "ire_identifier").as("ire")));
|
|
559
|
+
rule("nesc_delegation", () => (str("C2-").then(R("year_digits"))).or(R("year_digits").then(space).then(str("NESC").or(str("National Electrical Safety Code")))).or(str("Draft").then(space).then(str("NESC").or(str("National Electrical Safety Code")))).or(str("National Electrical Safety Code").then(str(",")).then(space).then(str("C2-"))).or(
|
|
560
|
+
// Catalogue form: "IEEE Std YYYY NESC …" / "IEEE Std YYYY National
|
|
561
|
+
// Electrical Safety Code" - must not fall through to the generic
|
|
562
|
+
// standard grammar, which would read YYYY as a number.
|
|
563
|
+
str("IEEE").then(space).then(str("Std")).then(space).then(R("year_digits")).then(space)
|
|
564
|
+
.then(str("NESC").or(str("National Electrical Safety Code")))).present()
|
|
565
|
+
.then(ref(rules, "nesc_identifier").as("nesc")));
|
|
566
|
+
rule("identifier", () => ref(rules, "combined_aiee_identifier")
|
|
567
|
+
.or(ref(rules, "aiee_delegation"))
|
|
568
|
+
.or(ref(rules, "combined_aiee_identifier"))
|
|
569
|
+
.or(ref(rules, "ire_delegation"))
|
|
570
|
+
.or(ref(rules, "nesc_delegation"))
|
|
571
|
+
.or(ref(rules, "ieee_astm_si_psi"))
|
|
572
|
+
.or(ref(rules, "multi_numbered_identifier"))
|
|
573
|
+
.or(ref(rules, "csa_dual_published"))
|
|
574
|
+
.or(ref(rules, "s_designation"))
|
|
575
|
+
.or(ref(rules, "corrigendum_identifier"))
|
|
576
|
+
.or(ref(rules, "interpretation_identifier"))
|
|
577
|
+
.or(ref(rules, "conformance_identifier"))
|
|
578
|
+
.or(ref(rules, "joint_development_ieee_format"))
|
|
579
|
+
.or(ref(rules, "joint_development_iso_format"))
|
|
580
|
+
.or(ref(rules, "joint_development_embedded_stage"))
|
|
581
|
+
.or(ref(rules, "iec_ieee_copublished"))
|
|
582
|
+
.or(ref(rules, "number_first_identifier"))
|
|
583
|
+
.or(ref(rules, "ieee_approved_draft_identifier"))
|
|
584
|
+
.or(ref(rules, "ieee_draft_p_identifier"))
|
|
585
|
+
.or(ref(rules, "ieee_p_identifier"))
|
|
586
|
+
.or(ref(rules, "ansi_p_identifier"))
|
|
587
|
+
.or((R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers")).as("publishers")
|
|
588
|
+
.then(space).maybe()).maybe()
|
|
589
|
+
.then(ref(rules, "draft_status").as("draft_status").maybe())
|
|
590
|
+
.then(str("Draft Std").as("type").then(spaceMaybe()).maybe())
|
|
591
|
+
.then(ref(rules, "type_word").as("type")
|
|
592
|
+
.then(space.then(str("No")).then(space).maybe())
|
|
593
|
+
.then(spaceMaybe()).maybe())
|
|
594
|
+
.then(ref(rules, "number"))
|
|
595
|
+
.then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())
|
|
596
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
597
|
+
.then(ref(rules, "amendment").maybe())
|
|
598
|
+
.then(ref(rules, "interpretation").maybe())
|
|
599
|
+
.then(ref(rules, "conformance").maybe())
|
|
600
|
+
.then(ref(rules, "ashrae_copub").maybe())
|
|
601
|
+
.then(ref(rules, "ieee_crossref").maybe())
|
|
602
|
+
.then(ref(rules, "draft").maybe())
|
|
603
|
+
.then(ref(rules, "revision_suffix").maybe())
|
|
604
|
+
.then(ref(rules, "trailing_month_year").maybe())
|
|
605
|
+
.then(
|
|
606
|
+
// The ASHRAE joint suffix may also trail a draft+date
|
|
607
|
+
// ("IEEE P1635/D13, December, 2017/ASHRAE Guideline 21").
|
|
608
|
+
ref(rules, "ashrae_copub").maybe())
|
|
609
|
+
.then(
|
|
610
|
+
// A bracketed narrative may sit between the base and a trailing
|
|
611
|
+
// corrigendum ("IEEE Std 671-1985 [Corrigendum to …]/Cor. 1-2010").
|
|
612
|
+
ref(rules, "book_nickname").maybe())
|
|
613
|
+
.then(ref(rules, "corrigendum").maybe())
|
|
614
|
+
.then(ref(rules, "edition").maybe())
|
|
615
|
+
.then(ref(rules, "parenthetical").maybe())
|
|
616
|
+
.then(ref(rules, "book_nickname").maybe())
|
|
617
|
+
.then(ref(rules, "redline").maybe())
|
|
618
|
+
.then(ref(rules, "title_portion").maybe())
|
|
619
|
+
.then(ref(rules, "approved_draft_suffix").maybe()))
|
|
620
|
+
.or(ref(rules, "no_prefix_ieee")));
|
|
621
|
+
return rules;
|
|
622
|
+
}
|
|
623
|
+
export const ieeeGrammar = {
|
|
624
|
+
rules: buildRules(),
|
|
625
|
+
root: "identifier",
|
|
626
|
+
};
|