Skip to content

Commit 7cd2683

Browse files
committed
nesc/ieee: preprint draft-stage rules + prefix-tolerant nesc guard
- c2_preprint: dotted canonical (C2.2012.Preprint), dash alias (C2-2012-Preprint), catalogue slash tail (C2-2002/Preprint) - preprint_proposal: 'Preprint Proposal(s) for the YYYY Edition of the National Electrical Safety Code' -> the edition-year preprint (longest-literal-first: 'Proposals' / 'Proposal'; the (NESC(R)) tail is consumed without capture, mirroring c2_standard) - ieee nesc_identifier: the optional 'IEEE Std ' prefix moves ahead of the lookahead guard — a guard anchored at position 0 rejected every prefixed catalogue spelling, so prefixed NESC forms never routed to nesc (and prefixed renders never reparsed)
1 parent b052d61 commit 7cd2683

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎artifacts/ieee.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎grammars/ieee.parg‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ grammar PubidIeee version "0.1.0" {
131131
combined_aiee_identifier = ((&(aiee.aiee_identifier) ((aiee.aiee_identifier)) as first_aiee) space "and" space ((aiee.aiee_identifier)) as second_aiee)
132132
aiee_identifier = ((&(aiee.aiee_prefix) ((aiee.aiee_identifier)) as aiee))
133133
ire_identifier = ((&((ire.ire_identifier_year_first / ire.ire_identifier_prefix_first)) ((ire.ire_identifier)) as ire))
134-
nesc_identifier = ((&((nesc.draft_nesc / nesc.name_first / nesc.c2_standard / nesc.year_first)) (((([("IEEE" space "Std" space)]) (((nesc.nesc_identifier)) as nesc))))))
134+
# The optional "IEEE Std " prefix precedes the guard: IEEE catalogues
135+
# NESC documents with the prefix ("IEEE Std C2.2012.Preprint"), so a
136+
# guard anchored at position 0 would reject every prefixed spelling.
137+
nesc_identifier = (([("IEEE" space "Std" space)] &((nesc.draft_nesc / nesc.preprint_proposal / nesc.name_first / nesc.c2_preprint / nesc.c2_standard / nesc.year_first)) (((nesc.nesc_identifier)) as nesc)))
135138
psi_draft = (((slash "D" [dash] (((digits)) as draft_version))))
136139
psi_date = ((comma ((month_name / month_numeric) as month) (space / dash) (year_digits) as year) / (([space] dash [space]) (year_digits) as year [(dash (2digit) as month)]))
137140
ieee_astm_si_psi = ((((("IEEE/ASTM" / "IEEE/ ASTM" / "IEEE"))) as publishers) space (("PSI" / "SI")) as si_type ((space / ".")) ((digits)) as number [(((("." ((year_digits)) as year))))] [(((psi_draft [psi_date])) / ((psi_date [psi_draft])))] [parenthetical])

‎grammars/nesc.parg‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ grammar PubidNesc version "0.1.0" {
99
space = " "
1010
comma = ","
1111
dash = "-"
12+
dot = "."
13+
slash = "/"
1214

1315
year = 4digit
1416
c2_code = "C2" as code
@@ -24,7 +26,15 @@ grammar PubidNesc version "0.1.0" {
2426
year_first = ((year) as year) space (((nesc_full_name) as full_name [(registered) as name_registered] [(space "(" (nesc_abbr) as paren_abbr [(registered) as paren_registered] ")")]) / (((nesc_abbr) as abbr [(registered) as abbr_registered]))) [(space variant)] [(comma space edition)]
2527
name_first = ((nesc_full_name [registered]) comma space c2_code dash (year) as year [(space "-" space (variant) as variant)])
2628
draft_nesc = (("Draft") as draft space nesc_name [registered] comma space (month) space (year) as year)
27-
nesc_identifier = draft_nesc / name_first / c2_standard / year_first
29+
# Preprint is a draft STAGE of the C2 code (NESC terminology for its
30+
# pre-edition drafts), not a variant: dotted is the canonical spelling
31+
# (C2.2012.Preprint); dash (C2-2012-Preprint) and the catalogue's
32+
# slash tail (C2-2002/Preprint) are aliases. The verbose
33+
# "Preprint Proposal(s) for the YYYY Edition of ..." forms cite the same
34+
# draft by its target edition year.
35+
c2_preprint = (c2_code ((dot (year) as year dot) / (dash (year) as year dash) / (dash (year) as year slash)) ("Preprint") as preprint)
36+
preprint_proposal = (("Preprint") as preprint space ("Proposals" / "Proposal") space "for" space "the" space (year) as year space "Edition" space "of" space "the" space nesc_full_name [(space "(" nesc_abbr [registered] ")")])
37+
nesc_identifier = draft_nesc / preprint_proposal / name_first / c2_preprint / c2_standard / year_first
2838

2939
entry nesc_identifier: nesc_identifier
3040

@@ -33,6 +43,11 @@ grammar PubidNesc version "0.1.0" {
3343
accept "2023 NESC"
3444
accept "National Electrical Safety Code, C2-2017"
3545
accept "Draft NESC, January 2016"
46+
accept "C2.2012.Preprint"
47+
accept "C2-2012-Preprint"
48+
accept "C2-2002/Preprint"
49+
accept "Preprint Proposal for the 2017 Edition of the National Electrical Safety Code"
50+
accept "Preprint Proposals for the 2022 Edition of the National Electrical Safety Code (NESC(R))"
3651
reject "nonsense"
3752
}
3853
}

0 commit comments

Comments
 (0)