pubid 2.0.2 → 2.0.3

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/data/ieee/update_codes.yaml +2 -2
  3. data/data/parg/aiee.json +1 -1
  4. data/data/parg/aiee.parg +99 -9
  5. data/data/parg/iala.json +1 -1
  6. data/data/parg/ieee.json +1 -1
  7. data/data/parg/ire.json +1 -1
  8. data/data/parg/ire.parg +51 -12
  9. data/data/parg/iso.json +1 -1
  10. data/data/parg/iso.parg +751 -0
  11. data/data/parg/jis.json +1 -1
  12. data/data/parg/nesc.json +1 -1
  13. data/data/parg/nesc.parg +97 -12
  14. data/data/parg/parg.json +1 -1
  15. data/lib/pubid/iala/builder.rb +48 -39
  16. data/lib/pubid/iala/identifier.rb +1 -1
  17. data/lib/pubid/ieee/CLAUDE.md +2 -0
  18. data/lib/pubid/ieee/aiee/identifier.rb +1 -1
  19. data/lib/pubid/ieee/builder.rb +175 -28
  20. data/lib/pubid/ieee/components/code.rb +46 -7
  21. data/lib/pubid/ieee/identifiers/base.rb +4 -1
  22. data/lib/pubid/ieee/identifiers/joint_development.rb +7 -3
  23. data/lib/pubid/ieee/ire/identifier.rb +1 -1
  24. data/lib/pubid/ieee/nesc/builder.rb +1 -1
  25. data/lib/pubid/ieee/project_renderer.rb +5 -1
  26. data/lib/pubid/ieee/renderer.rb +4 -2
  27. data/lib/pubid/ieee/urn_generator.rb +4 -1
  28. data/lib/pubid/iho/CLAUDE.md +15 -6
  29. data/lib/pubid/iho/urn_generator.rb +9 -6
  30. data/lib/pubid/iho/urn_parser.rb +43 -40
  31. data/lib/pubid/iso/CLAUDE.md +66 -0
  32. data/lib/pubid/iso/builder.rb +228 -14
  33. data/lib/pubid/iso/identifier.rb +22 -12
  34. data/lib/pubid/iso/normalizer.rb +5 -4
  35. data/lib/pubid/iso/urn_parser.rb +13 -8
  36. data/lib/pubid/jis/CLAUDE.md +36 -0
  37. data/lib/pubid/jis/builder.rb +12 -12
  38. data/lib/pubid/jis/identifier.rb +11 -1
  39. data/lib/pubid/jis/identifiers/welding_engineering_standard.rb +35 -0
  40. data/lib/pubid/jis/identifiers.rb +2 -0
  41. data/lib/pubid/jis/renderer.rb +1 -1
  42. data/lib/pubid/jis/supplement_identifier.rb +5 -5
  43. data/lib/pubid/jis/urn_parser.rb +2 -1
  44. data/lib/pubid/jis.rb +3 -2
  45. data/lib/pubid/version.rb +1 -1
  46. metadata +5 -2
data/data/parg/ire.json CHANGED
@@ -1 +1 @@
1
- {"bindings":null,"version":"0.1.0","grammar":"PubidIre","shape":"parsanol-tree/v2","binding_version":1,"entries":{"ire_identifier":{"root":"ire_identifier","grammar":{"atoms":[{"Entity":{"atom":90}},{"Entity":{"atom":23}},{"Entity":{"atom":18}},{"Str":{"pattern":"191"}},{"Entity":{"atom":5}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[3,4]}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"2"}},{"Str":{"pattern":"3"}},{"Str":{"pattern":"4"}},{"Str":{"pattern":"5"}},{"Alternative":{"atoms":[8,9,10,11]}},{"Entity":{"atom":5}},{"Sequence":{"atoms":[7,12,13]}},{"Str":{"pattern":"196"}},{"Re":{"pattern":"[\\x30-\\x33]"}},{"Sequence":{"atoms":[15,16]}},{"Alternative":{"atoms":[6,14,17]}},{"Entity":{"atom":22}},{"Re":{"pattern":"[\\x31-\\x36]"}},{"Entity":{"atom":5}},{"Sequence":{"atoms":[20,21]}},{"Alternative":{"atoms":[2,19]}},{"Named":{"name":"year","atom":1}},{"Entity":{"atom":26}},{"Str":{"pattern":" "}},{"Entity":{"atom":31}},{"Str":{"pattern":"IEEE-IRE"}},{"Str":{"pattern":"IRE"}},{"Alternative":{"atoms":[28,29]}},{"Named":{"name":"publisher","atom":30}},{"Entity":{"atom":26}},{"Entity":{"atom":38}},{"Str":{"pattern":"Trans."}},{"Str":{"pattern":"Standard"}},{"Str":{"pattern":"Std"}},{"Alternative":{"atoms":[34,35,36]}},{"Named":{"name":"type","atom":37}},{"Entity":{"atom":26}},{"Sequence":{"atoms":[33,39]}},{"Repetition":{"atom":40,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":71}},{"Entity":{"atom":45}},{"Entity":{"atom":5}},{"Repetition":{"atom":44,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":26}},{"Entity":{"atom":48}},{"Str":{"pattern":"."}},{"Alternative":{"atoms":[46,47]}},{"Entity":{"atom":51}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Entity":{"atom":45}},{"Sequence":{"atoms":[43,49,50,52]}},{"Entity":{"atom":45}},{"Entity":{"atom":48}},{"Str":{"pattern":"IRE"}},{"Entity":{"atom":45}},{"Entity":{"atom":48}},{"Entity":{"atom":45}},{"Entity":{"atom":51}},{"Entity":{"atom":45}},{"Sequence":{"atoms":[54,55,56,57,58,59,60,61]}},{"Entity":{"atom":51}},{"Repetition":{"atom":63,"min":2,"max":4,"tag":"Repetition"}},{"Entity":{"atom":66}},{"Str":{"pattern":"-"}},{"Entity":{"atom":45}},{"Sequence":{"atoms":[64,65,67]}},{"Entity":{"atom":45}},{"Alternative":{"atoms":[53,62,68,69]}},{"Named":{"name":"number","atom":70}},{"Entity":{"atom":85}},{"Entity":{"atom":26}},{"Entity":{"atom":66}},{"Str":{"pattern":","}},{"Alternative":{"atoms":[74,75]}},{"Repetition":{"atom":76,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":26}},{"Repetition":{"atom":78,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[73,77,79]}},{"Entity":{"atom":66}},{"Str":{"pattern":","}},{"Alternative":{"atoms":[81,82]}},{"Entity":{"atom":26}},{"Alternative":{"atoms":[80,83,84]}},{"Entity":{"atom":18}},{"Named":{"name":"full_year","atom":86}},{"Sequence":{"atoms":[72,87]}},{"Repetition":{"atom":88,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[24,25,27,32,41,42,89]}},{"Entity":{"atom":105}},{"Entity":{"atom":31}},{"Entity":{"atom":26}},{"Entity":{"atom":38}},{"Entity":{"atom":26}},{"Sequence":{"atoms":[94,95]}},{"Repetition":{"atom":96,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":71}},{"Entity":{"atom":104}},{"Entity":{"atom":85}},{"Entity":{"atom":23}},{"Named":{"name":"year","atom":101}},{"Sequence":{"atoms":[100,102]}},{"Repetition":{"atom":103,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[92,93,97,98,99]}},{"Alternative":{"atoms":[0,91]}}],"root":106},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule year_full: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule year_full: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule year_full: branches 2 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule year: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule yr_sep: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"ire_identifier","render":{},"derive":{},"tests":[{"entry":"ire_identifier","kind":"accept","input":"IRE Trans. PGI-7","expect":{}},{"entry":"ire_identifier","kind":"accept","input":"1930 IRE 20","expect":{}},{"entry":"ire_identifier","kind":"accept","input":"IRE Standard 15 S1","expect":{}},{"entry":"ire_identifier","kind":"accept","input":"IRE 28","expect":{}},{"entry":"ire_identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/ieee/ire/parser.rb — IRE (pre-IEEE) designations:\n# year-first and prefix-first forms, types (Trans./Standard/Std),\n# numbers (dotted letters, IRE-glued, letters-dash) and dates.\n# Consumed by the ieee grammar via `use ire`.\n\ngrammar PubidIre version \"0.1.0\" mode \"v1\" {\n digit = %x30-39\n upper = %x41-5A\n digits = 1*digit\n space = \" \"\n dash = \"-\"\n dot = \".\"\n\n year_short = (%x31-36 digit)\n year_full = ((\"191\" digit)) / ((\"19\" (\"2\" / \"3\" / \"4\" / \"5\") digit)) / ((\"196\" %x30-33))\n year = year_full / year_short\n ire_prefix = (\"IEEE-IRE\" / \"IRE\") as publisher\n ire_type = (\"Trans.\" / \"Standard\" / \"Std\") as type\n number = (((digits (space / dot) upper digits)) / ((digits dot \"IRE\" digits dot digits upper digits)) / ((2*4upper dash digits)) / (digits)) as number\n yr_sep = (space [(dash / \",\")] [space]) / (dash / \",\") / space\n date = [yr_sep (year) as year]\n\n # The trailing optional is flattened on purpose: a nested [([x] [y])]\n # compiles to branches that commit past the leading space in the\n # pure-Ruby VM, losing the backtrack the year-less forms need.\n ire_identifier_year_first = ((year) as year) space ire_prefix space [(ire_type space)] number [yr_sep (year_full) as full_year]\n ire_identifier_prefix_first = ire_prefix space [(ire_type space)] number date\n ire_identifier = ire_identifier_year_first / ire_identifier_prefix_first\n\n entry ire_identifier: ire_identifier\n\n test {\n accept \"IRE Trans. PGI-7\"\n accept \"1930 IRE 20\"\n accept \"IRE Standard 15 S1\"\n accept \"IRE 28\"\n reject \"nonsense\"\n }\n}\n","source_hash":"d03632e39bdb02326680d909c3634785c2c88da6ff7b761f2815a3b656328406","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":1,"checksum":"sha256:85510f79e03cca412cf5854e82bdcec18ff143394a3c3cddf68aeba4e026bf68"}
1
+ {"bindings":null,"version":"0.1.0","grammar":"PubidIre","shape":"parsanol-tree/v2","binding_version":1,"entries":{"ire_identifier":{"root":"ire_identifier","grammar":{"atoms":[{"Entity":{"atom":105}},{"Str":{"pattern":"191"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[1,2]}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"2"}},{"Str":{"pattern":"3"}},{"Str":{"pattern":"4"}},{"Str":{"pattern":"5"}},{"Alternative":{"atoms":[5,6,7,8]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[4,9,10]}},{"Str":{"pattern":"196"}},{"Re":{"pattern":"[\\x30-\\x33]"}},{"Sequence":{"atoms":[12,13]}},{"Re":{"pattern":"[\\x31-\\x36]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[15,16]}},{"Alternative":{"atoms":[3,11,14,17]}},{"Named":{"name":"year","atom":18}},{"Str":{"pattern":" "}},{"Entity":{"atom":25}},{"Str":{"pattern":"IEEE-IRE"}},{"Str":{"pattern":"IRE"}},{"Alternative":{"atoms":[22,23]}},{"Named":{"name":"publisher","atom":24}},{"Str":{"pattern":" "}},{"Entity":{"atom":32}},{"Str":{"pattern":"Trans."}},{"Str":{"pattern":"Standard"}},{"Str":{"pattern":"Std"}},{"Alternative":{"atoms":[28,29,30]}},{"Named":{"name":"type","atom":31}},{"Str":{"pattern":" "}},{"Sequence":{"atoms":[27,33]}},{"Repetition":{"atom":34,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":68}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":37,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":" "}},{"Str":{"pattern":"."}},{"Alternative":{"atoms":[39,40]}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":43,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[38,41,42,44]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":46,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Str":{"pattern":"IRE"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":50,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":53,"min":1,"max":null,"tag":"Repetition"}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":56,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[47,48,49,51,52,54,55,57]}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":59,"min":2,"max":4,"tag":"Repetition"}},{"Str":{"pattern":"-"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":62,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[60,61,63]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":65,"min":1,"max":null,"tag":"Repetition"}},{"Alternative":{"atoms":[45,58,64,66]}},{"Named":{"name":"number","atom":67}},{"Entity":{"atom":86}},{"Entity":{"atom":71}},{"Str":{"pattern":" "}},{"Entity":{"atom":73}},{"Str":{"pattern":"-"}},{"Named":{"name":"dash","atom":72}},{"Str":{"pattern":","}},{"Alternative":{"atoms":[74,75]}},{"Repetition":{"atom":76,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":71}},{"Repetition":{"atom":78,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[70,77,79]}},{"Entity":{"atom":73}},{"Named":{"name":"dash","atom":81}},{"Str":{"pattern":","}},{"Alternative":{"atoms":[82,83]}},{"Entity":{"atom":71}},{"Alternative":{"atoms":[80,84,85]}},{"Str":{"pattern":"191"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[87,88]}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"2"}},{"Str":{"pattern":"3"}},{"Str":{"pattern":"4"}},{"Str":{"pattern":"5"}},{"Alternative":{"atoms":[91,92,93,94]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[90,95,96]}},{"Str":{"pattern":"196"}},{"Re":{"pattern":"[\\x30-\\x33]"}},{"Sequence":{"atoms":[98,99]}},{"Alternative":{"atoms":[89,97,100]}},{"Named":{"name":"full_year","atom":101}},{"Sequence":{"atoms":[69,102]}},{"Repetition":{"atom":103,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[19,20,21,26,35,36,104]}},{"Entity":{"atom":136}},{"Entity":{"atom":25}},{"Str":{"pattern":" "}},{"Entity":{"atom":32}},{"Str":{"pattern":" "}},{"Sequence":{"atoms":[109,110]}},{"Repetition":{"atom":111,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":68}},{"Entity":{"atom":86}},{"Str":{"pattern":"191"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[115,116]}},{"Str":{"pattern":"19"}},{"Str":{"pattern":"2"}},{"Str":{"pattern":"3"}},{"Str":{"pattern":"4"}},{"Str":{"pattern":"5"}},{"Alternative":{"atoms":[119,120,121,122]}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[118,123,124]}},{"Str":{"pattern":"196"}},{"Re":{"pattern":"[\\x30-\\x33]"}},{"Sequence":{"atoms":[126,127]}},{"Re":{"pattern":"[\\x31-\\x36]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Sequence":{"atoms":[129,130]}},{"Alternative":{"atoms":[117,125,128,131]}},{"Named":{"name":"year","atom":132}},{"Sequence":{"atoms":[114,133]}},{"Repetition":{"atom":134,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[107,108,112,113,135]}},{"Alternative":{"atoms":[0,106]}}],"root":137},"bindings":[{"capture":"publisher","path":"publisher","type":"string","card":null,"preprocess":null},{"capture":"type","path":"type","type":"string","card":null,"preprocess":null},{"capture":"number","path":"number","type":"string","card":null,"preprocess":null},{"capture":"year","path":"year","type":"string","card":null,"preprocess":null},{"capture":"full_year","path":"full_year","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule year_full: branches 1 and 2 are order-dependent (shared first bytes; ordered choice is decisive)","rule year_full: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule year_full: branches 2 and 3 are order-dependent (shared first bytes; ordered choice is decisive)","rule yr_sep: branches 1 and 3 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"ire_identifier","render":{},"derive":{},"tests":[{"entry":"ire_identifier","kind":"accept","input":"IRE Trans. PGI-7","expect":{}},{"entry":"ire_identifier","kind":"accept","input":"1930 IRE 20","expect":{}},{"entry":"ire_identifier","kind":"accept","input":"IRE Standard 15 S1","expect":{}},{"entry":"ire_identifier","kind":"accept","input":"IRE 28","expect":{}},{"entry":"ire_identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/ieee/ire/parser.rb — IRE (pre-IEEE) designations:\n# year-first and prefix-first forms, types (Trans./Standard/Std),\n# numbers (dotted letters, IRE-glued, letters-dash) and dates.\n# Consumed by the ieee grammar via `use ire`.\n#\n# Edition-2 notes: the year / year_full bodies are inlined at every\n# capture site (a capture wrapping a rule ref expands to element hashes,\n# while the inlined body binds as one scalar string), and the helper\n# spaces around captures stay raw literals (a parenthesized ref\n# materializes a stray named node).\n\ngrammar PubidIre version \"0.1.0\" edition 2 {\n digit = %x30-39\n upper = %x41-5A\n space = \" \"\n dash = \"-\"\n dot = \".\"\n\n year_short = (%x31-36 %x30-39)\n year_full = ((\"191\" %x30-39)) / ((\"19\" (\"2\" / \"3\" / \"4\" / \"5\") %x30-39)) / ((\"196\" %x30-33))\n ire_prefix = (\"IEEE-IRE\" / \"IRE\") as publisher\n ire_type = (\"Trans.\" / \"Standard\" / \"Std\") as type\n number = {\n (\n ( 1*(%x30-39) (\" \" / \".\") %x41-5A 1*(%x30-39) )\n / ( 1*(%x30-39) \".\" \"IRE\" 1*(%x30-39) \".\" 1*(%x30-39) %x41-5A 1*(%x30-39) )\n / ( 2*4%x41-5A \"-\" 1*(%x30-39) )\n / ( 1*(%x30-39) )\n ) as number\n }\n yr_sep = (space [(dash / \",\")] [space]) / (dash / \",\") / space\n\n # The trailing optional stays flattened on purpose: a nested\n # [([x] [y])] compiles to branches that commit past the leading space\n # in the pure-Ruby VM, losing the backtrack the year-less forms need.\n ire_identifier_year_first = {\n (\n (\"191\" %x30-39)\n / (\"19\" (\"2\" / \"3\" / \"4\" / \"5\") %x30-39)\n / (\"196\" %x30-33)\n / (%x31-36 %x30-39)\n ) as year\n \" \" ire_prefix \" \" [ire_type \" \"] number\n [ yr_sep (\n (\"191\" %x30-39)\n / (\"19\" (\"2\" / \"3\" / \"4\" / \"5\") %x30-39)\n / (\"196\" %x30-33)\n ) as full_year ]\n }\n ire_identifier_prefix_first = {\n ire_prefix \" \" [ire_type \" \"] number\n [ yr_sep (\n (\"191\" %x30-39)\n / (\"19\" (\"2\" / \"3\" / \"4\" / \"5\") %x30-39)\n / (\"196\" %x30-33)\n / (%x31-36 %x30-39)\n ) as year ]\n }\n ire_identifier = ire_identifier_year_first / ire_identifier_prefix_first\n\n entry ire_identifier: ire_identifier\n\n bindings ire_identifier {\n publisher -> publisher (string)\n type -> type (string)\n number -> number (string)\n year -> year (string)\n full_year -> full_year (string)\n }\n\n test {\n accept \"IRE Trans. PGI-7\"\n accept \"1930 IRE 20\"\n accept \"IRE Standard 15 S1\"\n accept \"IRE 28\"\n reject \"nonsense\"\n }\n}\n","source_hash":"c4e0006d9f6995e5c75e03b2f277fc9a078ca5d49367bbc17a48ac994b53ba8e","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:d381eee0583376c50b1e0c48b3cef50380a2368fedf6932e592fff4469845e84"}
data/data/parg/ire.parg CHANGED
@@ -2,33 +2,72 @@
2
2
  # year-first and prefix-first forms, types (Trans./Standard/Std),
3
3
  # numbers (dotted letters, IRE-glued, letters-dash) and dates.
4
4
  # Consumed by the ieee grammar via `use ire`.
5
+ #
6
+ # Edition-2 notes: the year / year_full bodies are inlined at every
7
+ # capture site (a capture wrapping a rule ref expands to element hashes,
8
+ # while the inlined body binds as one scalar string), and the helper
9
+ # spaces around captures stay raw literals (a parenthesized ref
10
+ # materializes a stray named node).
5
11
 
6
- grammar PubidIre version "0.1.0" {
12
+ grammar PubidIre version "0.1.0" edition 2 {
7
13
  digit = %x30-39
8
14
  upper = %x41-5A
9
- digits = 1*digit
10
15
  space = " "
11
16
  dash = "-"
12
17
  dot = "."
13
18
 
14
- year_short = (%x31-36 digit)
15
- year_full = (("191" digit)) / (("19" ("2" / "3" / "4" / "5") digit)) / (("196" %x30-33))
16
- year = year_full / year_short
19
+ year_short = (%x31-36 %x30-39)
20
+ year_full = (("191" %x30-39)) / (("19" ("2" / "3" / "4" / "5") %x30-39)) / (("196" %x30-33))
17
21
  ire_prefix = ("IEEE-IRE" / "IRE") as publisher
18
22
  ire_type = ("Trans." / "Standard" / "Std") as type
19
- number = (((digits (space / dot) upper digits)) / ((digits dot "IRE" digits dot digits upper digits)) / ((2*4upper dash digits)) / (digits)) as number
23
+ number = {
24
+ (
25
+ ( 1*(%x30-39) (" " / ".") %x41-5A 1*(%x30-39) )
26
+ / ( 1*(%x30-39) "." "IRE" 1*(%x30-39) "." 1*(%x30-39) %x41-5A 1*(%x30-39) )
27
+ / ( 2*4%x41-5A "-" 1*(%x30-39) )
28
+ / ( 1*(%x30-39) )
29
+ ) as number
30
+ }
20
31
  yr_sep = (space [(dash / ",")] [space]) / (dash / ",") / space
21
- date = [yr_sep (year) as year]
22
32
 
23
- # The trailing optional is flattened on purpose: a nested [([x] [y])]
24
- # compiles to branches that commit past the leading space in the
25
- # pure-Ruby VM, losing the backtrack the year-less forms need.
26
- ire_identifier_year_first = ((year) as year) space ire_prefix space [(ire_type space)] number [yr_sep (year_full) as full_year]
27
- ire_identifier_prefix_first = ire_prefix space [(ire_type space)] number date
33
+ # The trailing optional stays flattened on purpose: a nested
34
+ # [([x] [y])] compiles to branches that commit past the leading space
35
+ # in the pure-Ruby VM, losing the backtrack the year-less forms need.
36
+ ire_identifier_year_first = {
37
+ (
38
+ ("191" %x30-39)
39
+ / ("19" ("2" / "3" / "4" / "5") %x30-39)
40
+ / ("196" %x30-33)
41
+ / (%x31-36 %x30-39)
42
+ ) as year
43
+ " " ire_prefix " " [ire_type " "] number
44
+ [ yr_sep (
45
+ ("191" %x30-39)
46
+ / ("19" ("2" / "3" / "4" / "5") %x30-39)
47
+ / ("196" %x30-33)
48
+ ) as full_year ]
49
+ }
50
+ ire_identifier_prefix_first = {
51
+ ire_prefix " " [ire_type " "] number
52
+ [ yr_sep (
53
+ ("191" %x30-39)
54
+ / ("19" ("2" / "3" / "4" / "5") %x30-39)
55
+ / ("196" %x30-33)
56
+ / (%x31-36 %x30-39)
57
+ ) as year ]
58
+ }
28
59
  ire_identifier = ire_identifier_year_first / ire_identifier_prefix_first
29
60
 
30
61
  entry ire_identifier: ire_identifier
31
62
 
63
+ bindings ire_identifier {
64
+ publisher -> publisher (string)
65
+ type -> type (string)
66
+ number -> number (string)
67
+ year -> year (string)
68
+ full_year -> full_year (string)
69
+ }
70
+
32
71
  test {
33
72
  accept "IRE Trans. PGI-7"
34
73
  accept "1930 IRE 20"