pubid 2.0.0 → 2.0.2
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.
- checksums.yaml +4 -4
- data/data/parg/adobe.json +1 -1
- data/data/parg/aiee.json +1 -1
- data/data/parg/amca.json +1 -1
- data/data/parg/ansi.json +1 -1
- data/data/parg/api.json +1 -1
- data/data/parg/ashrae.json +1 -1
- data/data/parg/asme.json +1 -1
- data/data/parg/astm.json +1 -1
- data/data/parg/bipm.json +1 -1
- data/data/parg/bsi.json +1 -1
- data/data/parg/calconnect.json +1 -1
- data/data/parg/ccsds.json +1 -1
- data/data/parg/cen_cenelec.json +1 -1
- data/data/parg/cie.json +1 -1
- data/data/parg/csa.json +1 -1
- data/data/parg/doi.json +1 -1
- data/data/parg/easc.json +1 -1
- data/data/parg/ecma.json +1 -1
- data/data/parg/etsi.json +1 -1
- data/data/parg/evs.json +1 -1
- data/data/parg/gb.json +1 -1
- data/data/parg/gost.json +1 -1
- data/data/parg/iala.json +1 -1
- data/data/parg/iana.json +1 -1
- data/data/parg/idf.json +1 -1
- data/data/parg/iec.json +1 -1
- data/data/parg/ieee.json +1 -29571
- data/data/parg/ietf.json +1 -1
- data/data/parg/iho.json +1 -0
- data/data/parg/ire.json +1 -1
- data/data/parg/isbn.json +1 -1
- data/data/parg/iso.json +1 -8510
- data/data/parg/itu.json +1 -1
- data/data/parg/jcgm.json +1 -1
- data/data/parg/jis.json +1 -1
- data/data/parg/nesc.json +1 -1
- data/data/parg/nist.json +1 -9588
- data/data/parg/oasis.json +1 -1
- data/data/parg/ogc.json +1 -1
- data/data/parg/oiml.json +1 -1
- data/data/parg/omg.json +1 -1
- data/data/parg/parg.json +1 -1
- data/data/parg/plateau.json +1 -1
- data/data/parg/sae.json +1 -1
- data/data/parg/tables/typed_stages.yaml +1 -0
- data/data/parg/tgpp.json +1 -1
- data/data/parg/un.json +1 -1
- data/data/parg/w3c.json +1 -1
- data/data/parg/xsf.json +1 -1
- data/lib/pubid/adobe/identifier.rb +1 -1
- data/lib/pubid/adobe/parser.rb +2 -113
- data/lib/pubid/amca/identifiers/base.rb +1 -1
- data/lib/pubid/amca/parser.rb +1 -145
- data/lib/pubid/ansi/identifier.rb +1 -1
- data/lib/pubid/ansi/parser.rb +1 -82
- data/lib/pubid/api/builder.rb +32 -1
- data/lib/pubid/api/identifier.rb +1 -1
- data/lib/pubid/api/parser.rb +1 -131
- data/lib/pubid/ashrae/identifiers/base.rb +1 -1
- data/lib/pubid/ashrae/parser.rb +3 -710
- data/lib/pubid/asme/builder.rb +6 -4
- data/lib/pubid/asme/identifier.rb +1 -2
- data/lib/pubid/asme/parser.rb +1 -328
- data/lib/pubid/astm/builder.rb +12 -3
- data/lib/pubid/astm/identifier.rb +1 -2
- data/lib/pubid/astm/parser.rb +1 -227
- data/lib/pubid/bipm/identifier.rb +8 -1
- data/lib/pubid/bipm/parser.rb +2 -224
- data/lib/pubid/bsi/builder.rb +2 -4
- data/lib/pubid/bsi/parser.rb +1 -666
- data/lib/pubid/bsi/single_identifier.rb +38 -1
- data/lib/pubid/calconnect/identifier.rb +1 -1
- data/lib/pubid/calconnect/parser.rb +2 -40
- data/lib/pubid/ccsds/identifier.rb +1 -1
- data/lib/pubid/ccsds/parser.rb +1 -66
- data/lib/pubid/cen_cenelec/identifier.rb +16 -1
- data/lib/pubid/cen_cenelec/parser.rb +3 -136
- data/lib/pubid/cie/identifier.rb +1 -1
- data/lib/pubid/cie/parser.rb +3 -378
- data/lib/pubid/conformance.rb +1 -1
- data/lib/pubid/csa/builder.rb +41 -18
- data/lib/pubid/csa/identifier.rb +12 -4
- data/lib/pubid/csa/identifiers/amendment.rb +28 -0
- data/lib/pubid/csa/identifiers.rb +1 -0
- data/lib/pubid/csa/parser.rb +16 -397
- data/lib/pubid/doi/identifier.rb +1 -1
- data/lib/pubid/doi/parser.rb +2 -37
- data/lib/pubid/easc/builder.rb +1 -1
- data/lib/pubid/easc/identifier.rb +1 -1
- data/lib/pubid/easc/parser.rb +2 -70
- data/lib/pubid/ecma/CLAUDE.md +8 -1
- data/lib/pubid/ecma/identifier.rb +13 -8
- data/lib/pubid/ecma/parser.rb +2 -54
- data/lib/pubid/ecma/renderer.rb +3 -7
- data/lib/pubid/errors.rb +18 -13
- data/lib/pubid/etsi/builder.rb +8 -5
- data/lib/pubid/etsi/identifiers/base.rb +1 -1
- data/lib/pubid/etsi/parser.rb +1 -132
- data/lib/pubid/evs/identifier.rb +7 -0
- data/lib/pubid/evs/parser.rb +1 -8
- data/lib/pubid/evs.rb +1 -1
- data/lib/pubid/gb/identifier.rb +7 -1
- data/lib/pubid/gb/parser.rb +2 -51
- data/lib/pubid/gost/identifier.rb +9 -1
- data/lib/pubid/gost/parser.rb +4 -81
- data/lib/pubid/iala/parser.rb +2 -121
- data/lib/pubid/iana/identifier.rb +1 -1
- data/lib/pubid/iana/parser.rb +2 -24
- data/lib/pubid/identifier.rb +78 -1
- data/lib/pubid/idf/builder.rb +42 -0
- data/lib/pubid/idf/identifier.rb +1 -1
- data/lib/pubid/idf/parser.rb +1 -137
- data/lib/pubid/idf.rb +1 -2
- data/lib/pubid/iec/builder.rb +158 -50
- data/lib/pubid/iec/identifier.rb +1 -1
- data/lib/pubid/iec/parser.rb +3 -430
- data/lib/pubid/ieee/aiee/identifier.rb +2 -1
- data/lib/pubid/ieee/aiee.rb +0 -1
- data/lib/pubid/ieee/builder.rb +2 -2
- data/lib/pubid/ieee/identifiers/base.rb +1 -1
- data/lib/pubid/ieee/ire/identifier.rb +2 -1
- data/lib/pubid/ieee/ire.rb +0 -1
- data/lib/pubid/ieee/nesc.rb +0 -1
- data/lib/pubid/ieee/parser.rb +1 -1257
- data/lib/pubid/ietf/identifiers/base.rb +17 -1
- data/lib/pubid/ietf/parser.rb +2 -47
- data/lib/pubid/ietf/renderer.rb +17 -2
- data/lib/pubid/iho/CLAUDE.md +89 -0
- data/lib/pubid/iho/builder.rb +4 -1
- data/lib/pubid/iho/identifiers/base.rb +28 -2
- data/lib/pubid/iho/renderer.rb +8 -0
- data/lib/pubid/iho/urn_generator.rb +11 -1
- data/lib/pubid/iho/urn_parser.rb +21 -11
- data/lib/pubid/iho.rb +0 -1
- data/lib/pubid/isbn/identifier.rb +1 -1
- data/lib/pubid/isbn/parser.rb +2 -31
- data/lib/pubid/iso/builder.rb +1 -1
- data/lib/pubid/iso/identifiers/directives.rb +6 -3
- data/lib/pubid/iso/identifiers/guide.rb +6 -3
- data/lib/pubid/iso/identifiers/international_standard.rb +3 -1
- data/lib/pubid/iso/identifiers/international_workshop_agreement.rb +6 -3
- data/lib/pubid/iso/normalizer.rb +1 -1
- data/lib/pubid/iso/parser.rb +1 -539
- data/lib/pubid/iso/supplement_identifier.rb +6 -3
- data/lib/pubid/iso/utilities.rb +4 -5
- data/lib/pubid/iso.rb +1 -19
- data/lib/pubid/itu/builder.rb +36 -20
- data/lib/pubid/itu/identifiers/base.rb +15 -2
- data/lib/pubid/itu/parser.rb +1 -775
- data/lib/pubid/jcgm/builder.rb +35 -0
- data/lib/pubid/jcgm/parser.rb +1 -151
- data/lib/pubid/jcgm.rb +1 -2
- data/lib/pubid/jis/builder.rb +18 -29
- data/lib/pubid/jis/identifier.rb +1 -1
- data/lib/pubid/jis/parser.rb +1 -128
- data/lib/pubid/nist/builder.rb +5 -1
- data/lib/pubid/nist/caster.rb +13 -3
- data/lib/pubid/nist/identifiers/base.rb +37 -2
- data/lib/pubid/nist/identifiers/circular.rb +2 -2
- data/lib/pubid/nist/identifiers/circular_supplement.rb +2 -2
- data/lib/pubid/nist/identifiers/commercial_standards_monthly.rb +2 -2
- data/lib/pubid/nist/identifiers/crpl_report.rb +2 -2
- data/lib/pubid/nist/identifiers/handbook.rb +2 -2
- data/lib/pubid/nist/identifiers/internal_report.rb +2 -2
- data/lib/pubid/nist/identifiers/miscellaneous_publication.rb +2 -2
- data/lib/pubid/nist/identifiers/monograph.rb +2 -2
- data/lib/pubid/nist/identifiers/report.rb +2 -2
- data/lib/pubid/nist/parser.rb +19 -775
- data/lib/pubid/nist/router.rb +4 -1
- data/lib/pubid/nist/supplement_identifier.rb +2 -2
- data/lib/pubid/oasis/identifier.rb +1 -1
- data/lib/pubid/oasis/parser.rb +2 -16
- data/lib/pubid/ogc/identifier.rb +1 -1
- data/lib/pubid/ogc/parser.rb +2 -26
- data/lib/pubid/oiml/identifiers/certification_system.rb +7 -0
- data/lib/pubid/oiml/identifiers/dual_published.rb +2 -2
- data/lib/pubid/oiml/parser.rb +1 -303
- data/lib/pubid/oiml.rb +1 -2
- data/lib/pubid/omg/identifier.rb +6 -1
- data/lib/pubid/omg/parser.rb +2 -76
- data/lib/pubid/parg/artifact.rb +22 -3
- data/lib/pubid/parg/model.rb +98 -0
- data/lib/pubid/parg.rb +1 -0
- data/lib/pubid/parser.rb +5 -4
- data/lib/pubid/parsers/mr_string.rb +1 -1
- data/lib/pubid/plateau/parser.rb +1 -66
- data/lib/pubid/plateau.rb +1 -2
- data/lib/pubid/renderers/directives_renderer.rb +1 -1
- data/lib/pubid/renderers/iwa_renderer.rb +1 -1
- data/lib/pubid/renderers/publisher_stripper.rb +82 -0
- data/lib/pubid/renderers/supplement_renderer.rb +1 -1
- data/lib/pubid/renderers.rb +1 -0
- data/lib/pubid/sae/identifiers/base.rb +1 -1
- data/lib/pubid/sae/parser.rb +1 -48
- data/lib/pubid/tgpp/identifier.rb +1 -1
- data/lib/pubid/tgpp/parser.rb +2 -59
- data/lib/pubid/un/identifier.rb +1 -1
- data/lib/pubid/un/parser.rb +1 -18
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid/w3c/identifier.rb +1 -1
- data/lib/pubid/w3c/parser.rb +2 -27
- data/lib/pubid/xsf/identifier.rb +11 -7
- data/lib/pubid/xsf/parser.rb +3 -31
- data/lib/pubid/xsf/renderer.rb +2 -4
- data/lib/pubid.rb +8 -9
- metadata +15 -25
- data/lib/pubid/ieee/aiee/parser.rb +0 -130
- data/lib/pubid/ieee/ire/parser.rb +0 -109
- data/lib/pubid/ieee/nesc/parser.rb +0 -155
- data/lib/pubid/iho/parser.rb +0 -68
- data/lib/pubid/parser/common_parse_methods.rb +0 -13
- data/lib/pubid/parser/common_parse_rules.rb +0 -56
- data/lib/pubid/parser/grammar.rb +0 -96
data/data/parg/sae.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidSae","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"SAE"}},{"Named":{"name":"publisher","atom":0}},{"Entity":{"atom":3}},{"Str":{"pattern":" "}},{"Entity":{"atom":12}},{"Str":{"pattern":"AMS"}},{"Str":{"pattern":"AIR"}},{"Str":{"pattern":"ARP"}},{"Str":{"pattern":"AS"}},{"Str":{"pattern":"J"}},{"Str":{"pattern":"MA"}},{"Alternative":{"atoms":[5,6,7,8,9,10]}},{"Named":{"name":"type","atom":11}},{"Entity":{"atom":3}},{"Repetition":{"atom":13,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":29}},{"Entity":{"atom":17}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":16,"min":1,"max":1,"tag":"Repetition"}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[18,21]}},{"Entity":{"atom":20}},{"Repetition":{"atom":23,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":17}},{"Repetition":{"atom":25,"min":0,"max":1,"tag":"Repetition"}},{"Sequence":{"atoms":[24,26]}},{"Alternative":{"atoms":[22,27]}},{"Named":{"name":"number","atom":28}},{"Entity":{"atom":31}},{"Str":{"pattern":":"}},{"Entity":{"atom":
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidSae","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"SAE"}},{"Named":{"name":"publisher","atom":0}},{"Entity":{"atom":3}},{"Str":{"pattern":" "}},{"Entity":{"atom":12}},{"Str":{"pattern":"AMS"}},{"Str":{"pattern":"AIR"}},{"Str":{"pattern":"ARP"}},{"Str":{"pattern":"AS"}},{"Str":{"pattern":"J"}},{"Str":{"pattern":"MA"}},{"Alternative":{"atoms":[5,6,7,8,9,10]}},{"Named":{"name":"type","atom":11}},{"Entity":{"atom":3}},{"Repetition":{"atom":13,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":29}},{"Entity":{"atom":17}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Repetition":{"atom":16,"min":1,"max":1,"tag":"Repetition"}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[18,21]}},{"Entity":{"atom":20}},{"Repetition":{"atom":23,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":17}},{"Repetition":{"atom":25,"min":0,"max":1,"tag":"Repetition"}},{"Sequence":{"atoms":[24,26]}},{"Alternative":{"atoms":[22,27]}},{"Named":{"name":"number","atom":28}},{"Entity":{"atom":31}},{"Str":{"pattern":":"}},{"Named":{"name":"colon","atom":30}},{"Entity":{"atom":36}},{"Entity":{"atom":20}},{"Repetition":{"atom":34,"min":4,"max":4,"tag":"Repetition"}},{"Named":{"name":"year","atom":35}},{"Sequence":{"atoms":[32,33]}},{"Repetition":{"atom":37,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,2,4,14,15,38]}}],"root":39},"bindings":[{"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":"publisher","path":"publisher","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"SAE J1939","expect":{}},{"entry":"identifier","kind":"accept","input":"SAE AMS2430","expect":{}},{"entry":"identifier","kind":"accept","input":"SAE ARP4754A:2010","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/sae/parser.rb: SAE <AMS|AIR|ARP|AS|J|MA> <number>[:year]\n\ngrammar PubidSae version \"0.1.0\" edition 2 {\n doc_type = (\"AMS\" / \"AIR\" / \"ARP\" / \"AS\" / \"J\" / \"MA\") as type\n number = ((1*1letter 1*digit) / (1*digit *1letter)) as number\n year = (4digit) as year\n identifier = \"SAE\" as publisher space doc_type [space] number [(colon year)]\n letter = %x41-5A\n digit = %x30-39\n space = \" \"\n colon = \":\"\n entry identifier: identifier\n\n # Typed model bindings: every bound capture lands on the\n # consumer model's field of the same name.\n bindings identifier {\n type -> type (string)\n number -> number (string)\n year -> year (string)\n publisher -> publisher (string)\n }\n\n\n test {\n accept \"SAE J1939\"\n accept \"SAE AMS2430\"\n accept \"SAE ARP4754A:2010\"\n reject \"nonsense\"\n }\n}\n","source_hash":"2d3a161caeb9c059ce2600050b823aea373712c16cfa662e5f82166c6f7ee01a","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:cdcc10602aa864cbccccd23ab6baaeed8e7edc4e4a8075c6c7a8f90324d7b5e1"}
|
data/data/parg/tgpp.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidTgpp","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"3GPP "}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":6}},{"Str":{"pattern":"TR"}},{"Str":{"pattern":"TS"}},{"Alternative":{"atoms":[3,4]}},{"Named":{"name":"type","atom":5}},{"Entity":{"atom":8}},{"Str":{"pattern":" "}},{"Entity":{"atom":17}},{"Entity":{"atom":11}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":10,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Entity":{"atom":11}},{"Repetition":{"atom":14,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[12,13,15]}},{"Named":{"name":"number","atom":16}},{"Entity":{"atom":24}},{"Entity":{"atom":22}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Alternative":{"atoms":[20,21]}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"suffix","atom":23}},{"Repetition":{"atom":18,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":34}},{"Entity":{"atom":32}},{"Str":{"pattern":"-"}},{"Entity":{"atom":11}},{"Repetition":{"atom":29,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"part","atom":30}},{"Sequence":{"atoms":[28,31]}},{"Repetition":{"atom":27,"min":0,"max":null,"tag":"Repetition"}},{"Named":{"name":"parts","atom":33}},{"Entity":{"atom":36}},{"Str":{"pattern":":"}},{"Entity":{"atom":
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidTgpp","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"3GPP "}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":6}},{"Str":{"pattern":"TR"}},{"Str":{"pattern":"TS"}},{"Alternative":{"atoms":[3,4]}},{"Named":{"name":"type","atom":5}},{"Entity":{"atom":8}},{"Str":{"pattern":" "}},{"Entity":{"atom":17}},{"Entity":{"atom":11}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":10,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Entity":{"atom":11}},{"Repetition":{"atom":14,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[12,13,15]}},{"Named":{"name":"number","atom":16}},{"Entity":{"atom":24}},{"Entity":{"atom":22}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x61-\\x7a]"}},{"Alternative":{"atoms":[20,21]}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"suffix","atom":23}},{"Repetition":{"atom":18,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":34}},{"Entity":{"atom":32}},{"Str":{"pattern":"-"}},{"Entity":{"atom":11}},{"Repetition":{"atom":29,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"part","atom":30}},{"Sequence":{"atoms":[28,31]}},{"Repetition":{"atom":27,"min":0,"max":null,"tag":"Repetition"}},{"Named":{"name":"parts","atom":33}},{"Entity":{"atom":36}},{"Str":{"pattern":":"}},{"Named":{"name":"colon","atom":35}},{"Entity":{"atom":64}},{"Entity":{"atom":51}},{"Entity":{"atom":11}},{"Named":{"name":"digit","atom":40}},{"Repetition":{"atom":41,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Entity":{"atom":11}},{"Named":{"name":"digit","atom":44}},{"Repetition":{"atom":45,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Entity":{"atom":11}},{"Named":{"name":"digit","atom":48}},{"Repetition":{"atom":49,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[42,43,46,47,50]}},{"Entity":{"atom":53}},{"Re":{"pattern":"[\\x01-\\u{10ffff}]"}},{"Lookahead":{"atom":52,"positive":false}},{"Sequence":{"atoms":[39,54]}},{"Lookahead":{"atom":55,"positive":false}},{"Entity":{"atom":61}},{"Re":{"pattern":"[\\x01-\\x2e]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Re":{"pattern":"[\\x3b-\\u{10ffff}]"}},{"Alternative":{"atoms":[58,59,60]}},{"Repetition":{"atom":57,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"release","atom":62}},{"Sequence":{"atoms":[56,63]}},{"Sequence":{"atoms":[37,38]}},{"Repetition":{"atom":65,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":68}},{"Str":{"pattern":"/"}},{"Named":{"name":"slash","atom":67}},{"Entity":{"atom":80}},{"Entity":{"atom":11}},{"Repetition":{"atom":71,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Entity":{"atom":11}},{"Repetition":{"atom":74,"min":1,"max":null,"tag":"Repetition"}},{"Str":{"pattern":"."}},{"Entity":{"atom":11}},{"Repetition":{"atom":77,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[72,73,75,76,78]}},{"Named":{"name":"version","atom":79}},{"Sequence":{"atoms":[69,70]}},{"Repetition":{"atom":81,"min":0,"max":1,"tag":"Maybe"}},{"Sequence":{"atoms":[1,2,7,9,25,26,66,82]}}],"root":83},"bindings":[{"capture":"type","path":"type","type":"string","card":null,"preprocess":null},{"capture":"number","path":"number","type":"string","card":null,"preprocess":null},{"capture":"suffix","path":"suffix","type":"string","card":null,"preprocess":null},{"capture":"part","path":"parts[].part","type":"string","card":null,"preprocess":null},{"capture":"release","path":"release","type":"string","card":null,"preprocess":null},{"capture":"version","path":"version","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule release_char: branches 1 and 3 are order-dependent (first set not statically known)","rule release_char: branches 2 and 3 are order-dependent (first set not statically known)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"3GPP TS 21.101","expect":{}},{"entry":"identifier","kind":"accept","input":"TS 25.999","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/tgpp/parser.rb:\n# [3GPP ]<TR|TS> <NN.NNN>[suffix][-part…][:<release>][/<version>]\n# The release excludes \"/\" and \":\" (match[\"^/:\"]), byte-wise here; the\n# mistyped-version guard (!version…!any) is ported literally.\n\ngrammar PubidTgpp version \"0.1.0\" edition 2 {\n release_char = %x01-2E / %x30-39 / %x3B-10FFFF\n any_char = %x01-10FFFF\n type = (\"TR\" / \"TS\") as type\n number = (1*digit \".\" 1*digit) as number\n suffix = (1*letter) as suffix\n part = \"-\" (1*digit) as part\n parts = (*part) as parts\n version_core = 1*digit \".\" 1*digit \".\" 1*digit\n release = !(version_core !any_char) (1*release_char) as release\n version = (1*digit \".\" 1*digit \".\" 1*digit) as version\n identifier = [\"3GPP \"] type space number [suffix] parts [(colon release)] [(slash version)]\n letter = %x41-5A / %x61-7A\n digit = %x30-39\n space = \" \"\n colon = \":\"\n slash = \"/\"\n entry identifier: identifier\n\n bindings identifier {\n type -> type (string)\n number -> number (string)\n suffix -> suffix (string)\n part -> parts[].part (string)\n release -> release (string)\n version -> version (string)\n }\n\n\n test {\n accept \"3GPP TS 21.101\"\n accept \"TS 25.999\"\n reject \"nonsense\"\n }\n}\n","source_hash":"8208f08be56685a980b7c3adeb2a58d64b962c148028fe676b3e00eede72f13a","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:9bdb1d70089ba09ad10fcf091475fb938c7570282c26a20652df304e7f9693af"}
|
data/data/parg/un.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidUn","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"UN "}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidUn","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"UN "}},{"Repetition":{"atom":0,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":8}},{"Re":{"pattern":"[\\x41-\\x5a]"}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Re":{"pattern":"[.]"}},{"Alternative":{"atoms":[3,4,5]}},{"Repetition":{"atom":6,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"token","atom":7}},{"Str":{"pattern":"/"}},{"Entity":{"atom":8}},{"Sequence":{"atoms":[9,10]}},{"Repetition":{"atom":11,"min":1,"max":null,"tag":"Repetition"}},{"Sequence":{"atoms":[1,2,12]}}],"root":13},"bindings":[{"capture":"token","path":"token[].token","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"UN/CEFACT/TBG14","expect":{}},{"entry":"identifier","kind":"accept","input":"CEFACT/TBG14","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/un/parser.rb. `token` matches [A-Z0-9.] runs.\n#\n# Edition-2 typed bindings: `token` repeats (one per slash-separated\n# segment) and the builder walks every occurrence as a path element, so\n# the repeats collect under token[].token — a scalar binding would keep\n# only the first segment. The separator stays a raw \"/\" literal: a\n# parenthesized slash ref materializes a {slash:} node whose presence\n# the token-walking builder would read as an empty token.\n\ngrammar PubidUn version \"0.1.0\" edition 2 {\n token_char = %x41-5A / %x30-39 / %x2E\n token = ( 1*(%x41-5A / %x30-39 / %x2E) ) as token\n identifier = [\"UN \"] token 1*( \"/\" token )\n slash = \"/\"\n\n entry identifier: identifier\n\n bindings identifier {\n token -> token[].token (string)\n }\n\n test {\n accept \"UN/CEFACT/TBG14\"\n accept \"CEFACT/TBG14\"\n reject \"nonsense\"\n }\n}\n","source_hash":"ba53a065d999fb151e5b557dafbf245bcb4d8a6948017b198444242eee47fcfb","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:a71b6cfba806bd0802198e7cacb532cbb06136a375bf937f37823f7531f0e327"}
|
data/data/parg/w3c.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidW3c","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"W3C "}},{"Entity":{"atom":16}},{"Entity":{"atom":13}},{"Str":{"pattern":"DNOTE"}},{"Str":{"pattern":"NOTE"}},{"Str":{"pattern":"WD"}},{"Str":{"pattern":"CRD"}},{"Str":{"pattern":"CR"}},{"Str":{"pattern":"REC"}},{"Str":{"pattern":"PER"}},{"Str":{"pattern":"PR"}},{"Str":{"pattern":"SPSD"}},{"Str":{"pattern":"OBSL"}},{"Alternative":{"atoms":[3,4,5,6,7,8,9,10,11,12]}},{"Named":{"name":"type","atom":2}},{"Str":{"pattern":"-"}},{"Sequence":{"atoms":[14,15]}},{"Repetition":{"atom":1,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":22}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x01-\\u{10ffff}]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"rest","atom":21}},{"Sequence":{"atoms":[0,17,18]}}],"root":23},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule type_token: branches 4 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule type_token: branches 7 and 8 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"W3C REC-html40-19981224","expect":{}},{"entry":"identifier","kind":"accept","input":"W3C NOTE-datetime-19980827","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/w3c/parser.rb: split off the leading maturity token;\n# code/date boundary is builder-side by design. Token order matters for\n# shared prefixes (CRD before CR, PER before PR, DNOTE before NOTE).\n\ngrammar PubidW3c version \"0.1.0\" {\n any_char = %x01-10FFFF\n type_token = \"DNOTE\" / \"NOTE\" / \"WD\" / \"CRD\" / \"CR\" / \"REC\" / \"PER\" / \"PR\" / \"SPSD\" / \"OBSL\"\n type_part = type_token as type \"-\"\n rest = (1*any_char) as rest\n identifier = \"W3C \" [type_part] rest\n entry identifier: identifier\n\n test {\n accept \"W3C REC-html40-19981224\"\n accept \"W3C NOTE-datetime-19980827\"\n reject \"nonsense\"\n }\n}\n","source_hash":"
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidW3c","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"W3C "}},{"Entity":{"atom":16}},{"Entity":{"atom":13}},{"Str":{"pattern":"DNOTE"}},{"Str":{"pattern":"NOTE"}},{"Str":{"pattern":"WD"}},{"Str":{"pattern":"CRD"}},{"Str":{"pattern":"CR"}},{"Str":{"pattern":"REC"}},{"Str":{"pattern":"PER"}},{"Str":{"pattern":"PR"}},{"Str":{"pattern":"SPSD"}},{"Str":{"pattern":"OBSL"}},{"Alternative":{"atoms":[3,4,5,6,7,8,9,10,11,12]}},{"Named":{"name":"type","atom":2}},{"Str":{"pattern":"-"}},{"Sequence":{"atoms":[14,15]}},{"Repetition":{"atom":1,"min":0,"max":1,"tag":"Maybe"}},{"Entity":{"atom":22}},{"Entity":{"atom":20}},{"Re":{"pattern":"[\\x01-\\u{10ffff}]"}},{"Repetition":{"atom":19,"min":1,"max":null,"tag":"Repetition"}},{"Named":{"name":"rest","atom":21}},{"Sequence":{"atoms":[0,17,18]}}],"root":23},"bindings":[{"capture":"type","path":"type","type":"string","card":null,"preprocess":null},{"capture":"rest","path":"rest","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":["rule type_token: branches 4 and 5 are order-dependent (shared first bytes; ordered choice is decisive)","rule type_token: branches 7 and 8 are order-dependent (shared first bytes; ordered choice is decisive)"]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"W3C REC-html40-19981224","expect":{}},{"entry":"identifier","kind":"accept","input":"W3C NOTE-datetime-19980827","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/w3c/parser.rb: split off the leading maturity token;\n# code/date boundary is builder-side by design. Token order matters for\n# shared prefixes (CRD before CR, PER before PR, DNOTE before NOTE).\n\ngrammar PubidW3c version \"0.1.0\" edition 2 {\n any_char = %x01-10FFFF\n type_token = \"DNOTE\" / \"NOTE\" / \"WD\" / \"CRD\" / \"CR\" / \"REC\" / \"PER\" / \"PR\" / \"SPSD\" / \"OBSL\"\n type_part = type_token as type \"-\"\n rest = (1*any_char) as rest\n identifier = \"W3C \" [type_part] rest\n entry identifier: identifier\n\n # Typed model bindings: every bound capture lands on the\n # consumer model's field of the same name.\n bindings identifier {\n type -> type (string)\n rest -> rest (string)\n }\n\n\n test {\n accept \"W3C REC-html40-19981224\"\n accept \"W3C NOTE-datetime-19980827\"\n reject \"nonsense\"\n }\n}\n","source_hash":"f1c99f42c7492c18f63f735ee29f07b25aa24442d6d899308a7af8350b83a2d9","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:7d7f51422516dea82179ab39580f4c8ca877471c100c8d1621c6b076273c56ba"}
|
data/data/parg/xsf.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"bindings":null,"version":"0.1.0","grammar":"PubidXsf","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"XEP "}},{"Entity":{"atom":10}},{"Entity":{"atom":3}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":2,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":8}},{"Str":{"pattern":"README"}},{"Str":{"pattern":"xxxx"}},{"Alternative":{"atoms":[6,7]}},{"Alternative":{"atoms":[4,5]}},{"Named":{"name":"number","atom":9}},{"Sequence":{"atoms":[0,1]}}],"root":11},"bindings":[]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"XEP 0001","expect":{}},{"entry":"identifier","kind":"accept","input":"XEP README","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/xsf/parser.rb: \"XEP NNNN\" plus the two named\n# documents (README, xxxx) in SPECIAL_NUMBERS.\n grammar PubidXsf version \"0.1.0\" {\n digit = %x30-39\n special_number = \"README\" / \"xxxx\"\n number = (1*digit / special_number) as number\n identifier = \"XEP \" number\n entry identifier: identifier\n\n test {\n accept \"XEP 0001\"\n accept \"XEP README\"\n reject \"nonsense\"\n }\n}\n","source_hash":"
|
|
1
|
+
{"bindings":null,"version":"0.1.0","grammar":"PubidXsf","shape":"parsanol-tree/v2","binding_version":1,"entries":{"identifier":{"root":"identifier","grammar":{"atoms":[{"Str":{"pattern":"XEP "}},{"Entity":{"atom":10}},{"Entity":{"atom":3}},{"Re":{"pattern":"[\\x30-\\x39]"}},{"Repetition":{"atom":2,"min":1,"max":null,"tag":"Repetition"}},{"Entity":{"atom":8}},{"Str":{"pattern":"README"}},{"Str":{"pattern":"xxxx"}},{"Alternative":{"atoms":[6,7]}},{"Alternative":{"atoms":[4,5]}},{"Named":{"name":"number","atom":9}},{"Sequence":{"atoms":[0,1]}}],"root":11},"bindings":[{"capture":"number","path":"number","type":"string","card":null,"preprocess":null}]}},"preprocess":{},"tables":{},"lint":{"order_warnings":[]},"default_entry":"identifier","render":{},"derive":{},"tests":[{"entry":"identifier","kind":"accept","input":"XEP 0001","expect":{}},{"entry":"identifier","kind":"accept","input":"XEP README","expect":{}},{"entry":"identifier","kind":"reject","input":"nonsense","expect":{}}],"docs":{},"source":"# Port of lib/pubid/xsf/parser.rb: \"XEP NNNN\" plus the two named\n# documents (README, xxxx) in SPECIAL_NUMBERS.\n grammar PubidXsf version \"0.1.0\" edition 2 {\n digit = %x30-39\n special_number = \"README\" / \"xxxx\"\n number = (1*digit / special_number) as number\n identifier = \"XEP \" number\n entry identifier: identifier\n\n # Typed model bindings: every bound capture lands on the\n # consumer model's field of the same name.\n bindings identifier {\n number -> number (string)\n }\n\n\n test {\n accept \"XEP 0001\"\n accept \"XEP README\"\n reject \"nonsense\"\n }\n}\n","source_hash":"fdfa1a7c14e4430d5237cf1995240003797173c202dc8574d8c98c7f48f576d2","unicode_tables":"onigmo (Ruby 3.4.8)","compiler_version":"1.3.114","edition":2,"checksum":"sha256:8a983305c22e049b60a0c7c6ffdd06c36985eeb7efa4844ed6c4f3b96669ed16"}
|
data/lib/pubid/adobe/parser.rb
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "parslet"
|
|
4
|
-
|
|
5
3
|
module Pubid
|
|
6
4
|
module Adobe
|
|
7
|
-
#
|
|
5
|
+
# Grammar for Adobe identifiers.
|
|
8
6
|
#
|
|
9
7
|
# Canonical citation forms (what the renderer produces):
|
|
10
8
|
#
|
|
@@ -21,116 +19,7 @@ module Pubid
|
|
|
21
19
|
# ATN5014 (short alias)
|
|
22
20
|
# 5014 (bare number; data-repo context)
|
|
23
21
|
# adobe-glyph-list (bare slug)
|
|
24
|
-
class Parser
|
|
25
|
-
include ::Pubid::Parser::CommonParseRules
|
|
26
|
-
|
|
27
|
-
root :identifier
|
|
28
|
-
|
|
29
|
-
rule(:space) { str(" ") }
|
|
30
|
-
rule(:space?) { space.maybe }
|
|
31
|
-
rule(:hash) { str("#") }
|
|
32
|
-
rule(:dot) { str(".") }
|
|
33
|
-
rule(:dash) { str("-") }
|
|
34
|
-
|
|
35
|
-
# Canonical short prefix: "Adobe TN" with optional trailing space.
|
|
36
|
-
# Matches both "Adobe TN 5014" and "Adobe TN5014".
|
|
37
|
-
rule(:tech_note_tn_prefix) do
|
|
38
|
-
str("Adobe") >> space >> str("TN") >> space?.maybe
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Legacy long prefix: "Adobe Technical Note" with optional "#".
|
|
42
|
-
rule(:tech_note_long_prefix) do
|
|
43
|
-
str("Adobe") >> space >> str("Technical") >> space >> str("Note") >>
|
|
44
|
-
(space? >> hash.maybe >> space?).maybe
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Legacy short alias: "ATN" with optional trailing space.
|
|
48
|
-
rule(:tech_note_atn_prefix) do
|
|
49
|
-
str("ATN") >> space?.maybe
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
rule(:tech_note_prefix) do
|
|
53
|
-
tech_note_tn_prefix | tech_note_long_prefix | tech_note_atn_prefix
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
rule(:digits) do
|
|
57
|
-
match("[0-9]").repeat(1)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# 4-digit tech note number, optionally followed by ".<Slug>" from
|
|
61
|
-
# the filename form. The slug is captured but not required.
|
|
62
|
-
rule(:slug_chars) do
|
|
63
|
-
match("[A-Za-z0-9_]").repeat(1)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
rule(:tech_note) do
|
|
67
|
-
(tech_note_prefix >>
|
|
68
|
-
digits.as(:number) >>
|
|
69
|
-
(dot >> slug_chars.as(:slug)).maybe).as(:tech_note)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Bare number form (e.g. when the data repo passes just "5014"
|
|
73
|
-
# extracted from a filename). Not advertised in user docs; used
|
|
74
|
-
# internally by AdobeFetcher::Docid.
|
|
75
|
-
rule(:bare_number) do
|
|
76
|
-
digits.as(:number).as(:tech_note_bare)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# "Adobe Publication " prefix. Matched literally then discarded —
|
|
80
|
-
# the publication slug/version is parsed by the inner rule.
|
|
81
|
-
rule(:publication_prefix) do
|
|
82
|
-
str("Adobe") >> space >> str("Publication") >> space
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Publication slug. Lowercase ASCII letters and digits joined by `-`.
|
|
86
|
-
# Each segment starts with a letter (so a trailing `-<digits>` is
|
|
87
|
-
# unambiguously a version suffix, not part of the slug).
|
|
88
|
-
rule(:slug_segment) do
|
|
89
|
-
match("[a-z]") >> match("[a-z0-9]").repeat
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
rule(:slug_inner) do
|
|
93
|
-
slug_segment >> (dash >> slug_segment).repeat
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
rule(:publication_with_version) do
|
|
97
|
-
(slug_inner.as(:slug) >> dash >> digits.as(:version)).as(:publication_version)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
rule(:publication_slug_or_version) do
|
|
101
|
-
# Try with-version first so `adobe-japan1-7` doesn't get captured
|
|
102
|
-
# as slug `adobe-japan1-7` with no version. The flat `:slug` form
|
|
103
|
-
# is the fallback for unversioned slugs.
|
|
104
|
-
publication_with_version | slug_inner.as(:slug)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
rule(:publication) do
|
|
108
|
-
# Optional "Adobe Publication " prefix. The prefix is consumed
|
|
109
|
-
# but not captured — the inner rule produces :slug or
|
|
110
|
-
# :publication_version as before.
|
|
111
|
-
publication_prefix.maybe >> publication_slug_or_version
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
rule(:identifier) do
|
|
115
|
-
tech_note | bare_number | publication
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Parse a string and return the raw parslet tree.
|
|
119
|
-
# @param string [String]
|
|
120
|
-
# @return [Hash]
|
|
121
|
-
def self.parse(string)
|
|
122
|
-
unless string.is_a?(String)
|
|
123
|
-
raise ::Pubid::Errors::InvalidInputError,
|
|
124
|
-
::Pubid::INPUT_NOT_A_STRING_MESSAGE
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
if string.length > ::Pubid::MAX_INPUT_LENGTH
|
|
128
|
-
raise ::Pubid::Errors::InvalidInputError,
|
|
129
|
-
::Pubid::INPUT_TOO_LONG_MESSAGE
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
new.parse(string.strip)
|
|
133
|
-
end
|
|
22
|
+
class Parser
|
|
134
23
|
end
|
|
135
24
|
end
|
|
136
25
|
end
|
data/lib/pubid/amca/parser.rb
CHANGED
|
@@ -4,151 +4,7 @@ module Pubid
|
|
|
4
4
|
module Amca
|
|
5
5
|
# Parser class for ACMA identifiers
|
|
6
6
|
# Single Responsibility: Parsing ACMA identifier syntax
|
|
7
|
-
class Parser
|
|
8
|
-
# Basic building blocks
|
|
9
|
-
rule(:space) { str(" ") }
|
|
10
|
-
rule(:space?) { space.maybe }
|
|
11
|
-
rule(:dash) { str("-") }
|
|
12
|
-
rule(:slash) { str("/") }
|
|
13
|
-
rule(:lparen) { str("(") }
|
|
14
|
-
rule(:rparen) { str(")") }
|
|
15
|
-
rule(:dot) { str(".") }
|
|
16
|
-
|
|
17
|
-
rule(:digit) { match("[0-9]") }
|
|
18
|
-
rule(:digits) { digit.repeat(1) }
|
|
19
|
-
rule(:letter) { match("[A-Za-z]") }
|
|
20
|
-
|
|
21
|
-
# Year pattern (2 digits starting with 0-1, or 4 digits starting with 19 or 20)
|
|
22
|
-
rule(:year_digits) do
|
|
23
|
-
((str("19") | str("20")) >> digit.repeat(2, 2)) |
|
|
24
|
-
digit.repeat(2, 2)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Copublisher (ANSI/AMCA or AMCA)
|
|
28
|
-
rule(:copublisher) do
|
|
29
|
-
(str("ANSI") >> slash >> str("AMCA")) |
|
|
30
|
-
str("AMCA")
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Additional copublisher after year (e.g., /ASHRAE 51-16)
|
|
34
|
-
rule(:additional_copublisher) do
|
|
35
|
-
slash >> letter.repeat(2,
|
|
36
|
-
10) >> space >> digits >> (dash >> digits).maybe
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Code pattern (e.g., 210, 500-D, 99, 204)
|
|
40
|
-
rule(:code) do
|
|
41
|
-
(
|
|
42
|
-
digits >> # Main number
|
|
43
|
-
(dash >> letter).maybe >> # Optional letter suffix (500-D)
|
|
44
|
-
(dot >> digits).maybe # Optional decimal (not in fixtures but possible)
|
|
45
|
-
).as(:code)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Type (Standard or Publication)
|
|
49
|
-
rule(:type) do
|
|
50
|
-
str("Standard") | str("Publication")
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# Reaffirmation year (R2008, R2010, etc.)
|
|
54
|
-
rule(:reaffirmation) do
|
|
55
|
-
lparen >> str("R") >> digits.as(:reaffirmed) >> rparen
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Suffix
|
|
59
|
-
rule(:suffix) do
|
|
60
|
-
str("R") | str("P")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Publication revision (Rev. 01-23)
|
|
64
|
-
rule(:revision) do
|
|
65
|
-
lparen >> str("Rev") >> dot.maybe >> space >>
|
|
66
|
-
(digits >> dash >> digits).as(:revision) >> rparen
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Interpretation code (JW, KB, RG, AW, AH, or just a number)
|
|
70
|
-
rule(:interpretation_code) do
|
|
71
|
-
letter.repeat(2).as(:interpretation_code) | # Two-letter code
|
|
72
|
-
digits.as(:interpretation_code) # Number
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Interpretation keyword
|
|
76
|
-
rule(:interp_keyword) do
|
|
77
|
-
space >> str("Interp")
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# Main identifier rule
|
|
81
|
-
rule(:identifier) do
|
|
82
|
-
# Interpretation patterns (must come first as they're more specific)
|
|
83
|
-
interpretation_identifier |
|
|
84
|
-
# Publication patterns
|
|
85
|
-
publication_identifier |
|
|
86
|
-
# Standard patterns (must come last as they're the most general)
|
|
87
|
-
standard_identifier
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Interpretation pattern (e.g., AMCA 99 JW Interp, AMCA 204 – 1)
|
|
91
|
-
rule(:interpretation_identifier) do
|
|
92
|
-
(
|
|
93
|
-
copublisher.as(:copublisher).maybe >> space >>
|
|
94
|
-
code >>
|
|
95
|
-
space >>
|
|
96
|
-
# Either a letter code (JW, KB, etc.) or a dash-number pattern
|
|
97
|
-
(
|
|
98
|
-
(interpretation_code >> interp_keyword) |
|
|
99
|
-
((str("–") | str("-")) >> digits.as(:interpretation_year) >> interp_keyword.maybe)
|
|
100
|
-
)
|
|
101
|
-
).as(:interpretation) |
|
|
102
|
-
# Simple interpretation: AMCA 511 Interp
|
|
103
|
-
(
|
|
104
|
-
copublisher.as(:copublisher).maybe >> space >>
|
|
105
|
-
code >>
|
|
106
|
-
interp_keyword
|
|
107
|
-
).as(:interpretation)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Publication pattern (e.g., AMCA Publication 211-22 (Rev. 01-23))
|
|
111
|
-
rule(:publication_identifier) do
|
|
112
|
-
(
|
|
113
|
-
copublisher.as(:copublisher).maybe >> space >>
|
|
114
|
-
str("Publication").as(:publication_keyword) >> space >>
|
|
115
|
-
code >>
|
|
116
|
-
(dash >> year_digits.as(:year)).maybe >>
|
|
117
|
-
(space >> revision).maybe >>
|
|
118
|
-
(space >> reaffirmation).maybe
|
|
119
|
-
).as(:publication)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# Standard pattern (e.g., ANSI/AMCA 210-16, ANSI/AMCA Standard 99-25)
|
|
123
|
-
rule(:standard_identifier) do
|
|
124
|
-
(
|
|
125
|
-
copublisher.as(:copublisher).maybe >> space >>
|
|
126
|
-
type.as(:type).maybe >> space.maybe >>
|
|
127
|
-
code >>
|
|
128
|
-
(dash >> year_digits.as(:year)).maybe >>
|
|
129
|
-
(space >> additional_copublisher).maybe >>
|
|
130
|
-
suffix.maybe >>
|
|
131
|
-
(space >> reaffirmation).maybe
|
|
132
|
-
).as(:standard)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
root(:identifier)
|
|
136
|
-
|
|
137
|
-
def self.parse(string)
|
|
138
|
-
# Strip leading/trailing whitespace
|
|
139
|
-
cleaned = string.strip
|
|
140
|
-
|
|
141
|
-
# Normalize multiple spaces to single space
|
|
142
|
-
cleaned = cleaned.gsub(/\s+/, " ")
|
|
143
|
-
|
|
144
|
-
# Normalize en dash to regular dash
|
|
145
|
-
cleaned = cleaned.gsub("–", "-")
|
|
146
|
-
|
|
147
|
-
# Remove trailing periods and commas
|
|
148
|
-
cleaned = cleaned.gsub(/[,.]$/, "")
|
|
149
|
-
|
|
150
|
-
new.parse(cleaned)
|
|
151
|
-
end
|
|
7
|
+
class Parser
|
|
152
8
|
end
|
|
153
9
|
end
|
|
154
10
|
end
|
data/lib/pubid/ansi/parser.rb
CHANGED
|
@@ -4,88 +4,7 @@ module Pubid
|
|
|
4
4
|
module Ansi
|
|
5
5
|
# Parser for ANSI (American National Standards Institute) identifiers
|
|
6
6
|
# Examples: ANSI X3.4-1986, ANSI C63.4-2014, ANSI/ISO 9899:1990
|
|
7
|
-
class Parser
|
|
8
|
-
include ::Pubid::Parser::CommonParseRules
|
|
9
|
-
include ::Pubid::Parser::CommonParseMethods
|
|
10
|
-
|
|
11
|
-
root :identifier
|
|
12
|
-
|
|
13
|
-
# ANSI as sole publisher
|
|
14
|
-
rule(:publisher) do
|
|
15
|
-
str("ANSI").as(:publisher)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Copublishers: ISO, IEEE, IEC, etc.
|
|
19
|
-
ORGANIZATIONS = %w[ISO IEC IEEE SAE ASME ASTM].freeze
|
|
20
|
-
rule(:copublishers) do
|
|
21
|
-
(str("/") >> space? >> array_to_str(ORGANIZATIONS).as(:copublisher)).repeat(1).as(:copublishers)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Optional "Std" keyword
|
|
25
|
-
rule(:std_keyword) do
|
|
26
|
-
(str("Std") >> space).maybe
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Number with optional parts and subparts
|
|
30
|
-
# Examples:
|
|
31
|
-
# - X3.4-1986 (letter prefix, one dot, year)
|
|
32
|
-
# - C63.4-2014 (letter prefix, one dot, year)
|
|
33
|
-
# - C37.06.1-2000 (letter prefix, two dots, year)
|
|
34
|
-
# - C57.12.10-1988 (letter prefix, three dots, year)
|
|
35
|
-
# - N323A-1997 (letter prefix, number, letter suffix, year)
|
|
36
|
-
# - N42.49A-2011 (letter prefix, dot, number, letter suffix, year)
|
|
37
|
-
# - 9899 (just digits)
|
|
38
|
-
# - 802.3-2012 (digits with dot and year)
|
|
39
|
-
# - 802.1b-1995 (digits, dot, digits, letter, year)
|
|
40
|
-
rule(:number_with_part) do
|
|
41
|
-
(
|
|
42
|
-
# Letter prefix with multiple dots and optional letter suffix
|
|
43
|
-
# C37.06.1, C57.12.10, C63.25.1, N323A, N42.49A
|
|
44
|
-
(match["A-Z"].repeat(1) >>
|
|
45
|
-
digits >>
|
|
46
|
-
(str(".") >> digits).repeat(0, 3) >> # Allow up to 3 additional dot-separated parts
|
|
47
|
-
match["A-Z"].maybe >> # Optional letter suffix (A, B, etc.)
|
|
48
|
-
(str("-") >> digits).maybe) | # Optional dash-year part
|
|
49
|
-
# Just digits with optional dots and letter suffix: 9899, 802.3-2012, 802.1b-1995
|
|
50
|
-
(digits >>
|
|
51
|
-
(str(".") >> digits >> match["a-z"].maybe).repeat(0, 2) >> # Dots with optional lowercase letter
|
|
52
|
-
(str("-") >> digits).maybe)
|
|
53
|
-
).as(:number_with_part)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Date - year only
|
|
57
|
-
rule(:date) do
|
|
58
|
-
str(":") >> year_digits.as(:date)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Language codes
|
|
62
|
-
rule(:language) do
|
|
63
|
-
str("(") >>
|
|
64
|
-
(match["a-z"].repeat(2) >> str(",").maybe).repeat.as(:languages) >>
|
|
65
|
-
str(")")
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Main identifier for ANSI with copublishers
|
|
69
|
-
# ANSI/ISO 9899:1990, ANSI/IEEE Std 1-1986
|
|
70
|
-
rule(:identifier_with_copublishers) do
|
|
71
|
-
publisher >> copublishers >>
|
|
72
|
-
space >> std_keyword >>
|
|
73
|
-
number_with_part >>
|
|
74
|
-
date.maybe >> language.maybe
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Main identifier for ANSI alone
|
|
78
|
-
# ANSI X3.4-1986, ANSI Std C63.4-1991
|
|
79
|
-
rule(:identifier_sole) do
|
|
80
|
-
publisher >> space >>
|
|
81
|
-
std_keyword >>
|
|
82
|
-
number_with_part >>
|
|
83
|
-
date.maybe >> language.maybe
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
rule(:identifier) do
|
|
87
|
-
identifier_with_copublishers | identifier_sole
|
|
88
|
-
end
|
|
7
|
+
class Parser
|
|
89
8
|
end
|
|
90
9
|
end
|
|
91
10
|
end
|
data/lib/pubid/api/builder.rb
CHANGED
|
@@ -14,8 +14,35 @@ module Pubid
|
|
|
14
14
|
"PUBL" => Identifiers::Publication,
|
|
15
15
|
}.freeze
|
|
16
16
|
|
|
17
|
+
# The bound grammar flattens the combined form's first/second
|
|
18
|
+
# wrappers (the bindings cannot nest): the second identifier's
|
|
19
|
+
# fields capture under second_* names. The tree backend folded
|
|
20
|
+
# first and second into one hash in parse order, so the second
|
|
21
|
+
# side's assignments came last and its number/part/year overwrite
|
|
22
|
+
# the first's — and select_class saw no top-level :type, so a
|
|
23
|
+
# combined form always built the typeless class. Reproduce both.
|
|
24
|
+
SECOND_KEYS = %i[second_number second_part second_year second_type].freeze
|
|
25
|
+
SECOND_OVERWRITES = { number: :second_number,
|
|
26
|
+
part: :second_part,
|
|
27
|
+
year: :second_year }.freeze
|
|
28
|
+
|
|
29
|
+
def build(data)
|
|
30
|
+
super(unflatten_combined(data))
|
|
31
|
+
end
|
|
32
|
+
|
|
17
33
|
private
|
|
18
34
|
|
|
35
|
+
def unflatten_combined(data)
|
|
36
|
+
return data unless SECOND_KEYS.any? { |k| data.key?(k) }
|
|
37
|
+
|
|
38
|
+
data = data.dup
|
|
39
|
+
data.delete(:type)
|
|
40
|
+
SECOND_OVERWRITES.each do |target, source|
|
|
41
|
+
data[target] = data.delete(source) if data.key?(source)
|
|
42
|
+
end
|
|
43
|
+
data
|
|
44
|
+
end
|
|
45
|
+
|
|
19
46
|
def default_identifier_class
|
|
20
47
|
Identifiers::TypelessStandard
|
|
21
48
|
end
|
|
@@ -29,7 +56,11 @@ module Pubid
|
|
|
29
56
|
# `:type` is consumed only by select_class for dispatch; it is not an
|
|
30
57
|
# identifier attribute (the concrete class is pinned by `_type`). Drop it
|
|
31
58
|
# so the raw Parslet::Slice never lands in the inherited :type attribute.
|
|
32
|
-
|
|
59
|
+
# `:second_type` is the combined form's second type token, with
|
|
60
|
+
# the same dispatch-only role (unflatten_combined has already
|
|
61
|
+
# removed the first side's :type so the typeless class wins,
|
|
62
|
+
# exactly as the tree backend's wrapper nesting did).
|
|
63
|
+
when :type, :second_type then nil
|
|
33
64
|
when :reaffirmation
|
|
34
65
|
value.is_a?(Hash) ? (value[:year] || value).to_s : value.to_s
|
|
35
66
|
# Every remaining key is a bare scalar. `:chapter` is a PARSE-TREE key
|
data/lib/pubid/api/identifier.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Pubid
|
|
|
34
34
|
# this was the one public parse in the gem that could return nil, which
|
|
35
35
|
# a caller reading `id.to_s` sees as a NoMethodError far from the cause.
|
|
36
36
|
# Both API fixture loaders already drop `#` lines themselves.
|
|
37
|
-
tree = Pubid::Parg::
|
|
37
|
+
tree = Pubid::Parg::Model.bound(:api, Api::Parser.normalize_input(input))
|
|
38
38
|
Builder.new.build(tree)
|
|
39
39
|
end
|
|
40
40
|
end
|