@pubid/pubid 0.1.8 → 0.1.9

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 (76) hide show
  1. package/artifact/corpus.json.gz +0 -0
  2. package/dist/flavors/cen_cenelec/grammar.js +10 -4
  3. package/dist/flavors/cen_cenelec/index.js +20 -1
  4. package/dist/flavors/cen_cenelec/model.d.ts +1 -0
  5. package/dist/flavors/cen_cenelec/model.js +4 -1
  6. package/dist/flavors/evs/grammar.js +53 -7
  7. package/dist/flavors/evs/index.js +74 -7
  8. package/dist/flavors/evs/model.d.ts +37 -1
  9. package/dist/flavors/evs/model.js +173 -11
  10. package/dist/flavors/ieee/artifact_tree.d.ts +2 -0
  11. package/dist/flavors/ieee/artifact_tree.js +36 -0
  12. package/dist/flavors/ieee/grammar.js +99 -19
  13. package/dist/flavors/ieee/index.js +312 -18
  14. package/dist/flavors/ieee/model.d.ts +5 -0
  15. package/dist/flavors/ieee/model.js +130 -20
  16. package/dist/flavors/ieee/preprocessor.js +3 -6
  17. package/dist/flavors/nist/grammar.js +18 -9
  18. package/dist/flavors/nist/index.js +16 -7
  19. package/dist/flavors/nist/preprocessor.js +9 -1
  20. package/dist/parg/runtime.d.ts +25 -0
  21. package/dist/parg/runtime.js +76 -0
  22. package/dist/parg/suite.d.ts +4 -0
  23. package/dist/parg/suite.js +14 -0
  24. package/dist/urn/parsers.js +7 -0
  25. package/package.json +6 -4
  26. package/vendor/parg/adobe.json +1 -0
  27. package/vendor/parg/aiee.json +1 -0
  28. package/vendor/parg/amca.json +1 -0
  29. package/vendor/parg/ansi.json +1 -0
  30. package/vendor/parg/api.json +1 -0
  31. package/vendor/parg/ashrae.json +1 -0
  32. package/vendor/parg/asme.json +1 -0
  33. package/vendor/parg/astm.json +1 -0
  34. package/vendor/parg/bipm.json +1 -0
  35. package/vendor/parg/bsi.json +1 -0
  36. package/vendor/parg/calconnect.json +1 -0
  37. package/vendor/parg/ccsds.json +1 -0
  38. package/vendor/parg/cen_cenelec.json +1 -0
  39. package/vendor/parg/cie.json +1 -0
  40. package/vendor/parg/csa.json +1 -0
  41. package/vendor/parg/doi.json +1 -0
  42. package/vendor/parg/easc.json +1 -0
  43. package/vendor/parg/ecma.json +1 -0
  44. package/vendor/parg/etsi.json +1 -0
  45. package/vendor/parg/evs.json +1 -0
  46. package/vendor/parg/gb.json +1 -0
  47. package/vendor/parg/gost.json +1 -0
  48. package/vendor/parg/iala.json +1 -0
  49. package/vendor/parg/iana.json +1 -0
  50. package/vendor/parg/idf.json +1 -0
  51. package/vendor/parg/iec.json +1 -0
  52. package/vendor/parg/ieee.json +1 -0
  53. package/vendor/parg/ietf.json +1 -0
  54. package/vendor/parg/ire.json +1 -0
  55. package/vendor/parg/isbn.json +1 -0
  56. package/vendor/parg/iso.json +1 -0
  57. package/vendor/parg/itu.json +1 -0
  58. package/vendor/parg/jcgm.json +1 -0
  59. package/vendor/parg/jis.json +1 -0
  60. package/vendor/parg/nesc.json +1 -0
  61. package/vendor/parg/nist.json +1 -0
  62. package/vendor/parg/oasis.json +1 -0
  63. package/vendor/parg/ogc.json +1 -0
  64. package/vendor/parg/oiml.json +1 -0
  65. package/vendor/parg/omg.json +1 -0
  66. package/vendor/parg/parg.json +1 -0
  67. package/vendor/parg/plateau.json +1 -0
  68. package/vendor/parg/sae.json +1 -0
  69. package/vendor/parg/tgpp.json +1 -0
  70. package/vendor/parg/un.json +1 -0
  71. package/vendor/parg/w3c.json +1 -0
  72. package/vendor/parg/xsf.json +1 -0
  73. package/dist/pg/runtime.d.ts +0 -85
  74. package/dist/pg/runtime.js +0 -170
  75. package/dist/pg/suite.d.ts +0 -20
  76. package/dist/pg/suite.js +0 -90
@@ -32,6 +32,10 @@ function buildRules() {
32
32
  const dot = str(".");
33
33
  const slash = str("/");
34
34
  const comma = str(", ");
35
+ // The artifact's date tails use the bare "," literal with an optional
36
+ // space ("," [space]) / space), which accepts the glued "D3.0,May 2008"
37
+ // spellings the comma rule (", ") cannot see.
38
+ const commaGlued = () => str(",").then(spaceMaybe()).or(comma).or(space);
35
39
  const digit = match("[0-9]");
36
40
  const digits = digit.repeat(1, Infinity);
37
41
  const upper = match("[A-Z]");
@@ -53,10 +57,10 @@ function buildRules() {
53
57
  rule("date_standalone", () => ref(rules, "date_with_month_text")
54
58
  .or(ref(rules, "date_with_month_numeric"))
55
59
  .or(R("year_digits").as("year")));
56
- rule("trailing_month_year", () => (comma.or(space)
60
+ rule("trailing_month_year", () => (commaGlued()
57
61
  .then(monthName().as("trailing_month"))
58
62
  .then(space)
59
- .then(R("year_digits").as("trailing_year"))).or(comma.or(space)
63
+ .then(R("year_digits").as("trailing_year"))).or(str(",").or(space)
60
64
  .then(R("month_numeric").as("trailing_month"))
61
65
  .then(space.or(dash))
62
66
  .then(R("year_digits").as("trailing_year"))));
@@ -91,7 +95,6 @@ function buildRules() {
91
95
  .then(ref(rules, "parenthetical").maybe()));
92
96
  rule("number", () => (str("P").maybe()
93
97
  .then(upper.repeat(0, Infinity)).then(digits).then(digits.or(upper).repeat(0, Infinity))
94
- .then(dash.then(digits).then(absent(R("year_digits"))).then(dash.then(digits).repeat(0, Infinity)).maybe())
95
98
  .then(lower.maybe())).as("number"));
96
99
  rule("type_word", () => str("Draft Std")
97
100
  .or(str("STD"))
@@ -102,7 +105,13 @@ function buildRules() {
102
105
  .or(match("[Nn]").then(str("o.")))
103
106
  .or(match("[Nn]").then(str("o")))
104
107
  .or(str("No")));
105
- rule("part", () => (dot.or(dash)).then(match("[0-9A-Za-z]").repeat(1, Infinity).as("part")));
108
+ rule("part", () => (dot.or(dash)).as("part_sep")
109
+ .then(absent(str("REV").or(str("Rev")).or(str("rev"))
110
+ .then(spaceMaybe())
111
+ .then(match("[0-9A-Za-z]")))
112
+ .then(match("[0-9A-Za-z]"))
113
+ .repeat(1, Infinity)
114
+ .as("part")));
106
115
  rule("subpart", () => (dot.or(dash).or(str("_"))).then((str("REV").or(str("Rev")).maybe()
107
116
  .then(match("[0-9a-z]").repeat(1, Infinity))
108
117
  .then(dot.then(digits).maybe())).as("subpart")));
@@ -114,20 +123,26 @@ function buildRules() {
114
123
  rule("draft_version", () => absent(str("R").then(dash))
115
124
  .then(str("D").then(absent(str("IS"))).maybe())
116
125
  .then((match("[0-9]").repeat(1, 2).then(dot).then(match("[0-9]").repeat(1, 2)).then(lower.maybe())).or(dot.then(digits))
126
+ // The artifact's dot-led version: "." + non-year alnum/dot run
127
+ // (the ".D" of "/Ddraft.D=FDIS").
128
+ .or(dot.then(absent(R("year_digits"))).then(match("[0-9A-Za-z.]").repeat(1, Infinity)))
117
129
  .or(digits.then(str("+")).then(digits))
118
130
  .or(digits.then(dot.maybe()).then(str("e")).then(digits))
119
131
  .or(str("-").maybe()
120
132
  .then(match("[0-9A-Za-z]").repeat(1, Infinity))
121
133
  .then(str("-d").or(str("_").then(match("[0-9A-Za-z]").repeat(0, Infinity))).maybe())).as("draft_version")));
122
- rule("draft_date", () => (comma.or(space).then(monthName().as("month")).then(space).then(R("year_digits").as("year"))).or(
134
+ rule("draft_date", () => (
135
+ // The canonical forced-comma render (", Feb, 2011") comma-joins
136
+ // the month and year, matching the joint tails.
137
+ commaGlued().then(monthName().as("month")).then(space.or(comma)).then(R("year_digits").as("year"))).or(
123
138
  // Space-separated bare year after the draft designator
124
139
  // ("IEEE Draft Std P14764/D1 2004, Nov 2004" - the "D1 2004" draft
125
140
  // carries its own year, with the print date still trailing).
126
- 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")))
141
+ space.then(R("year_digits").as("year"))).or(str(",").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")))
127
142
  .or(space.then(R("year_digits").as("year"))))));
128
- rule("fdraft", () => (slash
143
+ rule("fdraft", () => (slash.or(str("_"))
129
144
  .then(literalAlternation(["FDIS", "CDV", "CD", "WD", "PWI", "NP"]))
130
- .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())
145
+ .then((commaGlued().then(monthName().as("month")).then(space).then(R("year_digits").as("year"))).or(comma.or(space).then(R("year_digits").as("year"))).maybe())
131
146
  .then(ref(rules, "parenthetical").maybe())).as("fdraft"));
132
147
  rule("draft", () => (ref(rules, "draft_prefix")
133
148
  .then(ref(rules, "draft_version").repeat(1, 2))
@@ -311,9 +326,21 @@ function buildRules() {
311
326
  .or(stagedOnly.as("joint_publishers").then(space).then(isoStage()).then(stdNoise()).then(space)))
312
327
  .then(str("P").as("project_marker").maybe())
313
328
  .then(digits.as("number"))
314
- .then((dot.then(absent(R("year_digits"))).then(digits.as("part")))
329
+ .then(
330
+ // Digits-only parts keep their tree under any date spelling. A
331
+ // letter-suffixed part is the ISO print with a COLON year only
332
+ // (pubid#215: "8802-1AC:2018") - a dash-year letter part
333
+ // ("8802-1AC-2018") belongs to the later joint-IEEE rules, so
334
+ // the colon lookahead gates it.
335
+ (dot.then(absent(R("year_digits"))).then(digits.as("part")))
315
336
  .or(dash.then(str("").as("part_dash")).then(absent(R("year_digits")))
316
337
  .then(digits.as("part")))
338
+ .or(dot.then(absent(R("year_digits")))
339
+ .then(digits.then(match("[A-Za-z]").repeat(1, Infinity)).as("part"))
340
+ .then(str(":").present()))
341
+ .or(dash.then(str("").as("part_dash")).then(absent(R("year_digits")))
342
+ .then(digits.then(match("[A-Za-z]").repeat(1, Infinity)).as("part"))
343
+ .then(str(":").present()))
317
344
  .maybe())
318
345
  .then(dateClause())
319
346
  .then(
@@ -331,14 +358,27 @@ function buildRules() {
331
358
  .then(dot.then(digits.then(match("[A-Za-z]").repeat(0, 1)).as("draft_iso_iteration")).maybe()))
332
359
  .or(slash.then(str("D")).then(dashMaybe())
333
360
  .then(match("[0-9.]").repeat(1, Infinity).as("draft_version"))
334
- .then(((comma.or(space)).then(monthName().as("draft_month")).then(space)
361
+ .then(((comma.or(space)).then(monthName().as("draft_month")).then(space.or(comma))
335
362
  .then(R("year_digits").as("draft_year"))).or(comma.then(R("year_digits").as("draft_year"))).maybe())).maybe())
336
363
  .then((slash.then(str("Amd")).then(dot.or(space).maybe())
337
364
  .then(digits.as("amd_number"))
338
365
  .then((str(":").or(dash)).then(R("year_digits").as("amd_year")).maybe())).maybe())
366
+ // The ISO print's dotted corrigendum tail (pubid#215):
367
+ // "8802-1AC:2018/Cor.1:2020(E)".
368
+ .then(ref(rules, "corrigendum").maybe())
339
369
  .then(ref(rules, "edition").maybe())
340
370
  .then(ref(rules, "revision_suffix").maybe())
341
- .then(ref(rules, "parenthetical").maybe());
371
+ // The joint rule's trailing parenthetical is the NARROW one (a
372
+ // language/edition marker or P&V) - the reference's relationship
373
+ // vocabulary does not accept mis-typed narratives ("Revison of…"),
374
+ // so the loose catch-all would over-accept ahead of the redline.
375
+ .then((spaceMaybe().then(str("("))
376
+ .then(match("[A-Z]").then(match("[/][A-Z]").repeat(0, Infinity)).as("edition_marker"))
377
+ .then(str(")"))
378
+ .or(spaceMaybe().then(str("(P&V)")).as("parenthetical_content"))).maybe())
379
+ // The joint ISO-print redline is a distinct document (pubid#215):
380
+ // "15289:2015(E) - Redline".
381
+ .then(ref(rules, "redline").maybe());
342
382
  });
343
383
  // The stage-less ISO/IEC label with a colon year and the ISO/IEC
344
384
  // edition marker: "ISO/IEC 13210:1994 (E)" - the ISO/IEC portion of a
@@ -533,8 +573,34 @@ function buildRules() {
533
573
  .then(ref(rules, "nesc_month"))
534
574
  .then(space)
535
575
  .then(digit.repeat(4, 4).as("year")));
576
+ // Preprint is a draft STAGE of the C2 code (NESC terminology for its
577
+ // pre-edition drafts), not a variant: dotted is the canonical spelling
578
+ // (C2.2012.Preprint); dash (C2-2012-Preprint) and the catalogue's
579
+ // slash tail (C2-2002/Preprint) are aliases. The verbose
580
+ // "Preprint Proposal(s) for the YYYY Edition of ..." forms cite the
581
+ // same draft by its target edition year. Longest literal first —
582
+ // "Proposals" / "Proposal" — the choice does not retry the shorter
583
+ // alternative when the continuation fails.
584
+ rule("nesc_c2_preprint", () => ref(rules, "nesc_c2_code")
585
+ .then(str(".").then(digit.repeat(4, 4).as("year")).then(str("."))
586
+ .or(dash.then(digit.repeat(4, 4).as("year")).then(dash))
587
+ .or(dash.then(digit.repeat(4, 4).as("year")).then(str("/"))))
588
+ .then(str("Preprint").as("preprint")));
589
+ rule("nesc_preprint_proposal", () => str("Preprint").as("preprint")
590
+ .then(space)
591
+ .then(str("Proposals").or(str("Proposal")))
592
+ .then(space)
593
+ .then(str("for")).then(space).then(str("the")).then(space)
594
+ .then(digit.repeat(4, 4).as("year"))
595
+ .then(space).then(str("Edition")).then(space)
596
+ .then(str("of")).then(space).then(str("the")).then(space)
597
+ .then(ref(rules, "nesc_full_name"))
598
+ .then(space.then(str("(")).then(str("NESC")).then(ref(rules, "nesc_registered").maybe())
599
+ .then(str(")")).maybe()));
536
600
  rule("nesc_identifier", () => ref(rules, "nesc_draft_nesc")
601
+ .or(ref(rules, "nesc_preprint_proposal"))
537
602
  .or(ref(rules, "nesc_name_first"))
603
+ .or(ref(rules, "nesc_c2_preprint"))
538
604
  .or(ref(rules, "nesc_c2_standard"))
539
605
  .or(ref(rules, "nesc_year_first")));
540
606
  // --- PSI/SI -------------------------------------------------------------
@@ -556,6 +622,17 @@ function buildRules() {
556
622
  .then(ref(rules, "draft").maybe())
557
623
  .then(str("(E)").or(str("(F)")).maybe())
558
624
  .then(ref(rules, "parenthetical").maybe()));
625
+ // The generic tail minus the publisher (parg line 154): the publisherled
626
+ // alternative REQUIRES its publishers, so bare type-word/number forms
627
+ // route here instead — WITHOUT the redline/book_nickname slots the
628
+ // publisherled tail carries (the gem rejects "802.3-2012 - Redline").
629
+ rule("publisherless_ieee", () => (ref(rules, "type_word").as("type").then(space).maybe())
630
+ .then(ref(rules, "number"))
631
+ .then(ref(rules, "part_subpart_year").or(ref(rules, "edition")).maybe())
632
+ .then(ref(rules, "corrigendum").maybe())
633
+ .then(ref(rules, "draft").maybe())
634
+ .then(ref(rules, "revision_suffix").maybe())
635
+ .then(ref(rules, "parenthetical").maybe()));
559
636
  rule("corrigendum_identifier", () => (R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers")).as("publishers")
560
637
  .then(space).maybe()).maybe()
561
638
  .then(ref(rules, "type_word").as("type").then(spaceMaybe()).maybe())
@@ -626,12 +703,14 @@ function buildRules() {
626
703
  .then(ref(rules, "aiee_identifier").as("aiee")));
627
704
  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()
628
705
  .then(ref(rules, "ire_identifier").as("ire")));
629
- 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(
630
- // Catalogue form: "IEEE Std YYYY NESC …" / "IEEE Std YYYY National
631
- // Electrical Safety Code" - must not fall through to the generic
632
- // standard grammar, which would read YYYY as a number.
633
- str("IEEE").then(space).then(str("Std")).then(space).then(R("year_digits")).then(space)
634
- .then(str("NESC").or(str("National Electrical Safety Code")))).present()
706
+ rule("nesc_delegation", () =>
707
+ // The optional "IEEE Std " prefix is consumed BEFORE the guard: the
708
+ // catalogue prints NESC documents with it ("IEEE Std C2.2012.Preprint",
709
+ // "IEEE Std 2017 NESC Handbook"), and a guard anchored at position 0
710
+ // rejects every prefixed spelling. nesc_year_first carries its own
711
+ // prefix .maybe(), so the consumed form still parses.
712
+ str("IEEE").then(space).then(str("Std")).then(space).maybe()
713
+ .then((str("C2").then(str(".").or(str("-")))).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("Preprint")).or(str("National Electrical Safety Code").then(str(",")).then(space).then(str("C2-"))).present())
635
714
  .then(ref(rules, "nesc_identifier").as("nesc")));
636
715
  rule("identifier", () => ref(rules, "combined_aiee_identifier")
637
716
  .or(ref(rules, "aiee_delegation"))
@@ -656,7 +735,7 @@ function buildRules() {
656
735
  .or(ref(rules, "ieee_p_identifier"))
657
736
  .or(ref(rules, "ansi_p_identifier"))
658
737
  .or((R("publisher").then(R("copublisher").repeat(0, Infinity).as("copublishers")).as("publishers")
659
- .then(space).maybe()).maybe()
738
+ .then(space))
660
739
  .then(ref(rules, "draft_status").as("draft_status").maybe())
661
740
  .then(str("Draft Std").as("type").then(spaceMaybe()).maybe())
662
741
  .then(ref(rules, "type_word").as("type")
@@ -688,7 +767,8 @@ function buildRules() {
688
767
  .then(ref(rules, "redline").maybe())
689
768
  .then(ref(rules, "title_portion").maybe())
690
769
  .then(ref(rules, "approved_draft_suffix").maybe()))
691
- .or(ref(rules, "no_prefix_ieee")));
770
+ .or(ref(rules, "no_prefix_ieee"))
771
+ .or(ref(rules, "publisherless_ieee")));
692
772
  return rules;
693
773
  }
694
774
  export const ieeeGrammar = {