rdf-n3 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.yardopts +10 -0
- data/AUTHORS +1 -0
- data/History.txt +2 -0
- data/README.rdoc +72 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/example.rb +45 -0
- data/lib/rdf/n3.rb +30 -0
- data/lib/rdf/n3/format.rb +34 -0
- data/lib/rdf/n3/patches/array_hacks.rb +131 -0
- data/lib/rdf/n3/patches/rdf_escape.rb +131 -0
- data/lib/rdf/n3/reader.rb +447 -0
- data/lib/rdf/n3/reader/n3_grammar.rb +0 -0
- data/lib/rdf/n3/reader/n3_grammar.treetop +227 -0
- data/lib/rdf/n3/version.rb +21 -0
- data/lib/rdf/n3/vocabulary.rb +3 -0
- data/lib/rdf/n3/writer.rb +0 -0
- data/rdf-n3.gemspec +638 -0
- data/spec/cwm_spec.rb +32 -0
- data/spec/n3reader_spec.rb +928 -0
- data/spec/rdf_helper.rb +200 -0
- data/spec/rdfcore/Manifest.rdf +5395 -0
- data/spec/rdfcore/amp-in-url/test001.nt +16 -0
- data/spec/rdfcore/amp-in-url/test001.rdf +40 -0
- data/spec/rdfcore/datatypes-intensional/test001.nt +18 -0
- data/spec/rdfcore/datatypes-intensional/test002.nt +18 -0
- data/spec/rdfcore/datatypes/test001.nt +15 -0
- data/spec/rdfcore/datatypes/test001.rdf +29 -0
- data/spec/rdfcore/datatypes/test002.nt +14 -0
- data/spec/rdfcore/datatypes/test002.rdf +27 -0
- data/spec/rdfcore/datatypes/test002b.nt +17 -0
- data/spec/rdfcore/datatypes/test003a.nt +16 -0
- data/spec/rdfcore/datatypes/test003b.nt +16 -0
- data/spec/rdfcore/datatypes/test005a.nt +16 -0
- data/spec/rdfcore/datatypes/test005b.nt +16 -0
- data/spec/rdfcore/datatypes/test006.nt +17 -0
- data/spec/rdfcore/datatypes/test008a.nt +15 -0
- data/spec/rdfcore/datatypes/test008b.nt +15 -0
- data/spec/rdfcore/datatypes/test009a.nt +15 -0
- data/spec/rdfcore/datatypes/test009b.nt +15 -0
- data/spec/rdfcore/datatypes/test010.nt +17 -0
- data/spec/rdfcore/datatypes/test011a.nt +17 -0
- data/spec/rdfcore/datatypes/test011b.nt +17 -0
- data/spec/rdfcore/horst-01/test001.rdf +38 -0
- data/spec/rdfcore/horst-01/test002.rdf +39 -0
- data/spec/rdfcore/horst-01/test003.rdf +40 -0
- data/spec/rdfcore/horst-01/test004.rdf +42 -0
- data/spec/rdfcore/pfps-10/test001a.nt +14 -0
- data/spec/rdfcore/pfps-10/test001b.nt +15 -0
- data/spec/rdfcore/rdf-charmod-literals/test001.nt +15 -0
- data/spec/rdfcore/rdf-charmod-literals/test001.rdf +34 -0
- data/spec/rdfcore/rdf-charmod-uris/test001.nt +14 -0
- data/spec/rdfcore/rdf-charmod-uris/test001.rdf +34 -0
- data/spec/rdfcore/rdf-charmod-uris/test002.nt +15 -0
- data/spec/rdfcore/rdf-charmod-uris/test002.rdf +33 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/error001.rdf +27 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/error002.rdf +34 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test001.nt +17 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test001.rdf +27 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test002.nt +19 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test002.rdf +37 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test003.nt +18 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test003.rdf +29 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test004.nt +29 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test004.rdf +33 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test006.nt +40 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test006.rdf +28 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test007.nt +20 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test007.rdf +32 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test008.nt +15 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test008.rdf +28 -0
- data/spec/rdfcore/rdf-element-not-mandatory/test001.nt +10 -0
- data/spec/rdfcore/rdf-element-not-mandatory/test001.rdf +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0001.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0001.rdf +35 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0003.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0003.rdf +35 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0004.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0004.rdf +34 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0005.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0005.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0006.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0006.rdf +32 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0009.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0009.rdf +32 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0010.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0010.rdf +38 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0011.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0011.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0012.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0012.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0013.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0013.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0014.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0014.rdf +42 -0
- data/spec/rdfcore/rdfms-abouteach/error001.rdf +35 -0
- data/spec/rdfcore/rdfms-abouteach/error002.rdf +35 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/error1.rdf +25 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test1.nt +14 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test1.rdf +22 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test2.nt +14 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test2.rdf +22 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test3.nt +14 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test3.rdf +22 -0
- data/spec/rdfcore/rdfms-duplicate-member-props/test001.nt +17 -0
- data/spec/rdfcore/rdfms-duplicate-member-props/test001.rdf +30 -0
- data/spec/rdfcore/rdfms-empty-property-elements/error001.rdf +33 -0
- data/spec/rdfcore/rdfms-empty-property-elements/error002.rdf +33 -0
- data/spec/rdfcore/rdfms-empty-property-elements/error003.rdf +39 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test001.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test002.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test002.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test003.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test003.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test004.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test004.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test005.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test005.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test006.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test006.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test007.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test007.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test008.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test008.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test009.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test009.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test010.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test010.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test011.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test011.rdf +30 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test012.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test012.rdf +30 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test013.nt +15 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test013.rdf +35 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test014.nt +15 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test014.rdf +34 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test015.nt +15 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test015.rdf +38 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test016.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test016.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test017.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test017.rdf +38 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test001.nt +14 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test002.nt +15 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test002.rdf +33 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test003.nt +14 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test003.rdf +31 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test004.nt +15 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test004.rdf +33 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test005.nt +14 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test005.rdf +31 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test001.nt +19 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test001.rdf +29 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test002.nt +15 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test002.rdf +29 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test004.nt +18 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test004.rdf +29 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test005.nt +19 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test005.rdf +29 -0
- data/spec/rdfcore/rdfms-para196/test001.nt +17 -0
- data/spec/rdfcore/rdfms-para196/test001.rdf +35 -0
- data/spec/rdfcore/rdfms-rdf-id/error001.rdf +26 -0
- data/spec/rdfcore/rdfms-rdf-id/error002.rdf +26 -0
- data/spec/rdfcore/rdfms-rdf-id/error003.rdf +29 -0
- data/spec/rdfcore/rdfms-rdf-id/error004.rdf +27 -0
- data/spec/rdfcore/rdfms-rdf-id/error005.rdf +31 -0
- data/spec/rdfcore/rdfms-rdf-id/error006.rdf +26 -0
- data/spec/rdfcore/rdfms-rdf-id/error007.rdf +29 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-001.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-002.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-003.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-004.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-005.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-006.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-007.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-008.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-009.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-010.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-011.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-012.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-013.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-014.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-015.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-016.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-017.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-018.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-019.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-020.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-001.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-001.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-002.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-002.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-003.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-003.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-004.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-004.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-005.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-005.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-006.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-006.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-007.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-007.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-008.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-008.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-009.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-009.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-010.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-010.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-011.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-011.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-012.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-012.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-013.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-013.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-014.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-014.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-015.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-015.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-016.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-016.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-017.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-017.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-018.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-018.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-019.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-019.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-020.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-020.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-021.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-021.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-022.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-022.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-023.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-023.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-024.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-024.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-025.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-025.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-026.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-026.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-027.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-027.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-028.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-028.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-029.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-029.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-030.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-030.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-031.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-031.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-032.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-032.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-033.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-033.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-034.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-034.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-035.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-035.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-036.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-036.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-037.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-037.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-001.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-001.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-002.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-002.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-003.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-003.rdf +24 -0
- data/spec/rdfcore/rdfms-reification-required/test001.nt +15 -0
- data/spec/rdfcore/rdfms-reification-required/test001.rdf +29 -0
- data/spec/rdfcore/rdfms-seq-representation/empty.nt +13 -0
- data/spec/rdfcore/rdfms-seq-representation/test001.nt +19 -0
- data/spec/rdfcore/rdfms-seq-representation/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-seq-representation/test002.nt +14 -0
- data/spec/rdfcore/rdfms-seq-representation/test003a.nt +14 -0
- data/spec/rdfcore/rdfms-seq-representation/test003b.nt +14 -0
- data/spec/rdfcore/rdfms-seq-representation/test004.nt +14 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error001.rdf +26 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error002.rdf +26 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error003.rdf +29 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error004.rdf +25 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error005.rdf +25 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error006.rdf +28 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test001.nt +14 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test001.rdf +28 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test002.nt +19 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test002.rdf +38 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test003.nt +17 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test003.rdf +28 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test004.nt +21 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test004.rdf +36 -0
- data/spec/rdfcore/rdfms-uri-substructure/error001.nt +18 -0
- data/spec/rdfcore/rdfms-uri-substructure/test001.nt +17 -0
- data/spec/rdfcore/rdfms-uri-substructure/test001.rdf +29 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test001.nt +13 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test002.nt +14 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test002.rdf +47 -0
- data/spec/rdfcore/rdfms-xmllang/test001.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test001.rdf +30 -0
- data/spec/rdfcore/rdfms-xmllang/test002.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test002.rdf +29 -0
- data/spec/rdfcore/rdfms-xmllang/test003.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test003.rdf +28 -0
- data/spec/rdfcore/rdfms-xmllang/test004.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test004.rdf +28 -0
- data/spec/rdfcore/rdfms-xmllang/test005.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test005.rdf +28 -0
- data/spec/rdfcore/rdfms-xmllang/test006.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test006.rdf +29 -0
- data/spec/rdfcore/rdfms-xmllang/test007a.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test007b.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test007c.nt +14 -0
- data/spec/rdfcore/rdfs-container-membership-superProperty/not1C.rdf +13 -0
- data/spec/rdfcore/rdfs-container-membership-superProperty/not1P.rdf +14 -0
- data/spec/rdfcore/rdfs-domain-and-range/nonconclusions005.rdf +28 -0
- data/spec/rdfcore/rdfs-domain-and-range/nonconclusions006.rdf +28 -0
- data/spec/rdfcore/rdfs-domain-and-range/premises005.rdf +32 -0
- data/spec/rdfcore/rdfs-domain-and-range/premises006.rdf +32 -0
- data/spec/rdfcore/rdfs-domain-and-range/test001.nt +16 -0
- data/spec/rdfcore/rdfs-domain-and-range/test001.rdf +29 -0
- data/spec/rdfcore/rdfs-domain-and-range/test002.nt +16 -0
- data/spec/rdfcore/rdfs-domain-and-range/test002.rdf +29 -0
- data/spec/rdfcore/rdfs-entailment/test001.nt +16 -0
- data/spec/rdfcore/rdfs-entailment/test002.nt +15 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subClassOf/test001.nt +18 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subClassOf/test001.rdf +37 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subPropertyOf/test001.nt +18 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subPropertyOf/test001.rdf +40 -0
- data/spec/rdfcore/rdfs-subClassOf-a-Property/test001.nt +15 -0
- data/spec/rdfcore/rdfs-subPropertyOf-semantics/test001.nt +24 -0
- data/spec/rdfcore/rdfs-subPropertyOf-semantics/test002.nt +21 -0
- data/spec/rdfcore/statement-entailment/test001a.nt +12 -0
- data/spec/rdfcore/statement-entailment/test001b.nt +2 -0
- data/spec/rdfcore/statement-entailment/test002a.nt +2 -0
- data/spec/rdfcore/statement-entailment/test002b.nt +5 -0
- data/spec/rdfcore/tex-01/test001.rdf +34 -0
- data/spec/rdfcore/tex-01/test002.rdf +33 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test001.nt +15 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test001.rdf +31 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test002.nt +14 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test002.rdf +32 -0
- data/spec/rdfcore/xml-canon/test001.nt +16 -0
- data/spec/rdfcore/xml-canon/test001.rdf +28 -0
- data/spec/rdfcore/xmlbase/test001.nt +14 -0
- data/spec/rdfcore/xmlbase/test001.rdf +27 -0
- data/spec/rdfcore/xmlbase/test002.nt +14 -0
- data/spec/rdfcore/xmlbase/test002.rdf +28 -0
- data/spec/rdfcore/xmlbase/test003.nt +14 -0
- data/spec/rdfcore/xmlbase/test003.rdf +25 -0
- data/spec/rdfcore/xmlbase/test004.nt +18 -0
- data/spec/rdfcore/xmlbase/test004.rdf +27 -0
- data/spec/rdfcore/xmlbase/test006.nt +15 -0
- data/spec/rdfcore/xmlbase/test006.rdf +26 -0
- data/spec/rdfcore/xmlbase/test007.nt +14 -0
- data/spec/rdfcore/xmlbase/test007.rdf +25 -0
- data/spec/rdfcore/xmlbase/test008.nt +14 -0
- data/spec/rdfcore/xmlbase/test008.rdf +25 -0
- data/spec/rdfcore/xmlbase/test009.nt +14 -0
- data/spec/rdfcore/xmlbase/test009.rdf +26 -0
- data/spec/rdfcore/xmlbase/test010.nt +14 -0
- data/spec/rdfcore/xmlbase/test010.rdf +26 -0
- data/spec/rdfcore/xmlbase/test011.nt +14 -0
- data/spec/rdfcore/xmlbase/test011.rdf +27 -0
- data/spec/rdfcore/xmlbase/test013.nt +15 -0
- data/spec/rdfcore/xmlbase/test013.rdf +28 -0
- data/spec/rdfcore/xmlbase/test014.nt +15 -0
- data/spec/rdfcore/xmlbase/test014.rdf +28 -0
- data/spec/rdfcore/xmlsch-02/test001.rdf +34 -0
- data/spec/rdfcore/xmlsch-02/test002.rdf +34 -0
- data/spec/rdfcore/xmlsch-02/test003.rdf +37 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/swap_helper.rb +136 -0
- data/spec/swap_spec.rb +77 -0
- data/spec/swap_test/.DS_Store +0 -0
- data/spec/swap_test/animal.rdf +17 -0
- data/spec/swap_test/anon-prop.n3 +14 -0
- data/spec/swap_test/anonymous_loop.n3 +2 -0
- data/spec/swap_test/contexts.n3 +16 -0
- data/spec/swap_test/daml-pref.n3 +10 -0
- data/spec/swap_test/i18n/hiragana.n3 +22 -0
- data/spec/swap_test/i18n/n3string.n3 +4 -0
- data/spec/swap_test/list/itemType.rdf +12 -0
- data/spec/swap_test/lists-simple.n3 +40 -0
- data/spec/swap_test/lists.n3 +35 -0
- data/spec/swap_test/n3/.DS_Store +0 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10001.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10002.nt +7 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10003.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10004.nt +119 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10005.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10006.nt +225 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10007.nt +79 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10008.nt +5 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10009.nt +13 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10010.nt +21 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10011.nt +9 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10012.nt +53 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10013.nt +19 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10014.nt +103 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10015.nt +103 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10016.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10017.nt +151 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10018.nt +9 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10019.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10020.nt +13 -0
- data/spec/swap_test/n3parser.tests +160 -0
- data/spec/swap_test/nodeID/classes.n3 +9 -0
- data/spec/swap_test/nodeID/classes.ref.rdf +15 -0
- data/spec/swap_test/nodeID/ex1.rdf +15 -0
- data/spec/swap_test/norm/fix.rdf +33 -0
- data/spec/swap_test/owl-ex.rdf +150 -0
- data/spec/swap_test/ref/animal.n3 +11 -0
- data/spec/swap_test/ref/anon-prop-1.n3 +8 -0
- data/spec/swap_test/ref/anonymous_loop.ref +7 -0
- data/spec/swap_test/ref/bnode.n3 +6 -0
- data/spec/swap_test/ref/bnode.rdf +16 -0
- data/spec/swap_test/ref/colon-in-uri.n3 +15 -0
- data/spec/swap_test/ref/daml-ex.n3 +103 -0
- data/spec/swap_test/ref/daml-ont.n3 +289 -0
- data/spec/swap_test/ref/djb1a-out.n3 +4 -0
- data/spec/swap_test/ref/dot-dash.n3 +8 -0
- data/spec/swap_test/ref/in-xml-t.n3 +4 -0
- data/spec/swap_test/ref/itemType.n3 +9 -0
- data/spec/swap_test/ref/keywords1.n3 +11 -0
- data/spec/swap_test/ref/keywords2.n3 +11 -0
- data/spec/swap_test/ref/lists-simple-1.rdf +108 -0
- data/spec/swap_test/ref/lists.n3 +43 -0
- data/spec/swap_test/ref/lstring-out.n3 +20 -0
- data/spec/swap_test/ref/n3string.n3 +13 -0
- data/spec/swap_test/ref/no-last-nl.n3 +3 -0
- data/spec/swap_test/ref/numbers.n3 +18 -0
- data/spec/swap_test/ref/path1.n3 +8 -0
- data/spec/swap_test/ref/path2.n3 +39 -0
- data/spec/swap_test/ref/prefix1.rdf +31 -0
- data/spec/swap_test/ref/prefix3.rdf +31 -0
- data/spec/swap_test/ref/rdf-redefine.rdf +11 -0
- data/spec/swap_test/ref/reluri-1.rdf +18 -0
- data/spec/swap_test/ref/strquot.n3 +23 -0
- data/spec/swap_test/ref/strquot_a.n3 +23 -0
- data/spec/swap_test/ref/xml-base3.n3 +5 -0
- data/spec/swap_test/ref/xml-redefine.rdf +20 -0
- data/spec/swap_test/ref/xml-redefine2.rdf +23 -0
- data/spec/swap_test/ref/xml-syntax-basic-serialization.rdf +10 -0
- data/spec/swap_test/ref/xmllit.nt +3 -0
- data/spec/swap_test/regression.n3 +231 -0
- data/spec/swap_test/reluri-1.n3 +10 -0
- data/spec/swap_test/strquot.n3 +23 -0
- data/spec/swap_test/syntax/colon-in-uri.rdf +27 -0
- data/spec/swap_test/syntax/djb1a.n3 +3 -0
- data/spec/swap_test/syntax/dot-dash.n3 +15 -0
- data/spec/swap_test/syntax/equals1.n3 +1 -0
- data/spec/swap_test/syntax/equals2.n3 +1 -0
- data/spec/swap_test/syntax/keywords1.n3 +17 -0
- data/spec/swap_test/syntax/keywords2.n3 +18 -0
- data/spec/swap_test/syntax/lstring.n3 +26 -0
- data/spec/swap_test/syntax/neg-formula-predicate.n3 +1 -0
- data/spec/swap_test/syntax/neg-keywords3.n3 +1 -0
- data/spec/swap_test/syntax/neg-literal-predicate.n3 +1 -0
- data/spec/swap_test/syntax/neg-single-quote.n3 +1 -0
- data/spec/swap_test/syntax/neg-thisadoc.n3 +1 -0
- data/spec/swap_test/syntax/no-last-nl.n3 +2 -0
- data/spec/swap_test/syntax/numbers.n3 +26 -0
- data/spec/swap_test/syntax/path1.n3 +23 -0
- data/spec/swap_test/syntax/path2.n3 +31 -0
- data/spec/swap_test/syntax/qvars1.n3 +19 -0
- data/spec/swap_test/syntax/qvars2.n3 +19 -0
- data/spec/swap_test/syntax/this-quantifiers.n3 +164 -0
- data/spec/swap_test/syntax/this-rules.n3 +43 -0
- data/spec/swap_test/syntax/too-nested.n3 +25 -0
- data/spec/swap_test/syntax/trailing-semicolon.n3 +12 -0
- data/spec/swap_test/syntax/zero-objects.n3 +1 -0
- data/spec/swap_test/syntax/zero-predicates.n3 +3 -0
- data/spec/swap_test/tests-work.txt +25 -0
- data/spec/swap_test/xml-syntax/basic-serialization.n3 +8 -0
- data/spec/swap_test/xml-syntax/in-xml.xml +13 -0
- data/spec/swap_test/xml-syntax/non-ascii-pred.rdf +14 -0
- data/spec/swap_test/xml-syntax/rdf_prefix.n3 +2 -0
- data/spec/swap_test/xml-syntax/xml_prefix.n3 +7 -0
- data/spec/swap_test/xml-syntax/xml_prefix2.n3 +9 -0
- data/spec/swap_test/xml-syntax/xmlbase3.rdf +10 -0
- data/spec/swap_test/xml-syntax/xmllit.rdf +33 -0
- data/spec/triple_spec.rb +236 -0
- data/spec/turtle/README.txt +20 -0
- data/spec/turtle/bad-00.ttl +2 -0
- data/spec/turtle/bad-01.ttl +3 -0
- data/spec/turtle/bad-02.ttl +3 -0
- data/spec/turtle/bad-03.ttl +3 -0
- data/spec/turtle/bad-04.ttl +3 -0
- data/spec/turtle/bad-05.ttl +4 -0
- data/spec/turtle/bad-06.ttl +3 -0
- data/spec/turtle/bad-07.ttl +4 -0
- data/spec/turtle/bad-08.ttl +2 -0
- data/spec/turtle/bad-09.ttl +3 -0
- data/spec/turtle/bad-10.ttl +3 -0
- data/spec/turtle/bad-11.ttl +3 -0
- data/spec/turtle/bad-12.ttl +3 -0
- data/spec/turtle/bad-13.ttl +3 -0
- data/spec/turtle/bad-14.ttl +6 -0
- data/spec/turtle/manifest-bad.ttl +88 -0
- data/spec/turtle/manifest.ttl +215 -0
- data/spec/turtle/rdf-schema.out +126 -0
- data/spec/turtle/rdf-schema.ttl +156 -0
- data/spec/turtle/rdfq-results.out +36 -0
- data/spec/turtle/rdfq-results.ttl +39 -0
- data/spec/turtle/rdfs-namespace.out +131 -0
- data/spec/turtle/rdfs-namespace.ttl +160 -0
- data/spec/turtle/test-00.out +1 -0
- data/spec/turtle/test-00.ttl +2 -0
- data/spec/turtle/test-01.out +3 -0
- data/spec/turtle/test-01.ttl +7 -0
- data/spec/turtle/test-02.out +3 -0
- data/spec/turtle/test-02.ttl +5 -0
- data/spec/turtle/test-03.out +3 -0
- data/spec/turtle/test-03.ttl +5 -0
- data/spec/turtle/test-04.out +2 -0
- data/spec/turtle/test-04.ttl +4 -0
- data/spec/turtle/test-05.out +4 -0
- data/spec/turtle/test-05.ttl +4 -0
- data/spec/turtle/test-06.out +1 -0
- data/spec/turtle/test-06.ttl +3 -0
- data/spec/turtle/test-07.out +5 -0
- data/spec/turtle/test-07.ttl +3 -0
- data/spec/turtle/test-08.out +1 -0
- data/spec/turtle/test-08.ttl +3 -0
- data/spec/turtle/test-09.out +4 -0
- data/spec/turtle/test-09.ttl +10 -0
- data/spec/turtle/test-10.out +5 -0
- data/spec/turtle/test-10.ttl +5 -0
- data/spec/turtle/test-11.out +4 -0
- data/spec/turtle/test-11.ttl +10 -0
- data/spec/turtle/test-12.out +4 -0
- data/spec/turtle/test-12.ttl +9 -0
- data/spec/turtle/test-13.out +2 -0
- data/spec/turtle/test-13.ttl +7 -0
- data/spec/turtle/test-14.out +10000 -0
- data/spec/turtle/test-14.ttl +10002 -0
- data/spec/turtle/test-15.out +10000 -0
- data/spec/turtle/test-15.ttl +3 -0
- data/spec/turtle/test-16.out +10000 -0
- data/spec/turtle/test-16.ttl +10002 -0
- data/spec/turtle/test-17.out +1 -0
- data/spec/turtle/test-17.ttl +6 -0
- data/spec/turtle/test-18.out +2 -0
- data/spec/turtle/test-18.ttl +9 -0
- data/spec/turtle/test-19.out +1 -0
- data/spec/turtle/test-19.ttl +4 -0
- data/spec/turtle/test-20.out +2 -0
- data/spec/turtle/test-20.ttl +6 -0
- data/spec/turtle/test-21.out +3 -0
- data/spec/turtle/test-21.ttl +4 -0
- data/spec/turtle/test-22.out +3 -0
- data/spec/turtle/test-22.ttl +4 -0
- data/spec/turtle/test-23.out +1 -0
- data/spec/turtle/test-23.ttl +3 -0
- data/spec/turtle/test-24.out +2 -0
- data/spec/turtle/test-24.ttl +3 -0
- data/spec/turtle/test-25.out +7 -0
- data/spec/turtle/test-25.ttl +14 -0
- data/spec/turtle/test-26.out +1 -0
- data/spec/turtle/test-26.ttl +4 -0
- data/spec/turtle/test-27.out +1 -0
- data/spec/turtle/test-27.ttl +5 -0
- data/spec/turtle/test-28-out.ttl +6 -0
- data/spec/turtle/test-28.out +22 -0
- data/spec/turtle/test-28.ttl +22 -0
- data/spec/turtle/test-29.out +1 -0
- data/spec/turtle/test-29.ttl +1 -0
- data/spec/turtle/test-30.out +5 -0
- data/spec/turtle/test-30.ttl +12 -0
- data/spec/turtle_serializer_spec.rb +226 -0
- data/spec/turtle_spec.rb +64 -0
- metadata +711 -0
@@ -0,0 +1,447 @@
|
|
1
|
+
require 'nokogiri' # FIXME: Implement using different modules as in RDF::TriX
|
2
|
+
|
3
|
+
module RDF::RDFXML
|
4
|
+
##
|
5
|
+
# A Notation-3/Turtle parser in Ruby
|
6
|
+
#
|
7
|
+
# @author [Gregg Kellogg](http://kellogg-assoc.com/)
|
8
|
+
class Reader < RDF::Reader
|
9
|
+
format Format
|
10
|
+
|
11
|
+
N3_KEYWORDS = %w(a is of has keywords prefix base true false forSome forAny)
|
12
|
+
|
13
|
+
NC_REGEXP = Regexp.new(
|
14
|
+
%{^
|
15
|
+
(?!\\\\u0301) # ́ is a non-spacing acute accent.
|
16
|
+
# It is legal within an XML Name, but not as the first character.
|
17
|
+
( [a-zA-Z_]
|
18
|
+
| \\\\u[0-9a-fA-F]
|
19
|
+
)
|
20
|
+
( [0-9a-zA-Z_\.-]
|
21
|
+
| \\\\u([0-9a-fA-F]{4})
|
22
|
+
)*
|
23
|
+
$},
|
24
|
+
Regexp::EXTENDED)
|
25
|
+
|
26
|
+
XML_LITERAL = RDF['XMLLiteral']
|
27
|
+
|
28
|
+
##
|
29
|
+
# Initializes the N3 reader instance.
|
30
|
+
#
|
31
|
+
# @param [IO, File, String]:: input
|
32
|
+
# @param [Hash{Symbol => Object}]:: options
|
33
|
+
# <em>options[:debug]</em>:: Array to place debug messages
|
34
|
+
# <em>options[:strict]</em>:: Raise Error if true, continue with lax parsing, otherwise
|
35
|
+
# <em>options[:base_uri]</em>:: Base URI to use for relative URIs.
|
36
|
+
# @yield [reader]
|
37
|
+
# @yieldparam [Reader] reader
|
38
|
+
# @raise [Error]:: Raises RDF::ReaderError if _strict_
|
39
|
+
def initialize(input = $stdin, options = {}, &block)
|
40
|
+
super do
|
41
|
+
@graph = RDF::Graph.new
|
42
|
+
@debug = options[:debug]
|
43
|
+
@strict = options[:strict]
|
44
|
+
@base_uri = options[:base_uri]
|
45
|
+
@base_uri = RDF::URI.parse(@base_uri) if @base_uri.is_a?(String)
|
46
|
+
@nsbinding = {}
|
47
|
+
|
48
|
+
@doc = stream.respond_to?(:read) ? (stream.rewind; stream.read) : stream
|
49
|
+
@default_ns = @base_uri if @base_uri
|
50
|
+
add_debug("@default_ns", "#{@default_ns.inspect}")
|
51
|
+
|
52
|
+
document = parser.parse(@doc)
|
53
|
+
unless document
|
54
|
+
puts parser.inspect if $DEBUG
|
55
|
+
reason = parser.failure_reason
|
56
|
+
raise RDF::ReaderError.new(reason)
|
57
|
+
end
|
58
|
+
|
59
|
+
process_statements(document)
|
60
|
+
|
61
|
+
block.call(self) if block_given?
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# Keep track of allocated BNodes
|
68
|
+
def bnode(value = nil)
|
69
|
+
if value
|
70
|
+
@bnode_cache ||= {}
|
71
|
+
@bnode_cache[value.to_s] ||= RDF::Node.new(value)
|
72
|
+
else
|
73
|
+
RDF::Node.new
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Add debug event to debug array, if specified
|
78
|
+
#
|
79
|
+
# @param [XML Node, any] node:: XML Node or string for showing context
|
80
|
+
# @param [String] message::
|
81
|
+
def add_debug(node, message)
|
82
|
+
puts "#{node_path(node)}: #{message}" if $DEBUG
|
83
|
+
@debug << "#{node_path(node)}: #{message}" if @debug.is_a?(Array)
|
84
|
+
end
|
85
|
+
|
86
|
+
# add a statement, object can be literal or URI or bnode
|
87
|
+
#
|
88
|
+
# @param [Nokogiri::XML::Node, any] node:: XML Node or string for showing context
|
89
|
+
# @param [URI, Node] subject:: the subject of the statement
|
90
|
+
# @param [URI] predicate:: the predicate of the statement
|
91
|
+
# @param [URI, Node, Literal] object:: the object of the statement
|
92
|
+
# @return [Statement]:: Added statement
|
93
|
+
# @raise [RDF::ReaderError]:: Checks parameter types and raises if they are incorrect if parsing mode is _strict_.
|
94
|
+
def add_triple(node, subject, predicate, object)
|
95
|
+
statement = RDF::Statement.new(subject, predicate, object)
|
96
|
+
add_debug(node, "statement: #{statement}")
|
97
|
+
@graph << statement
|
98
|
+
statement
|
99
|
+
rescue RDF::ReaderError => e
|
100
|
+
add_debug(node, "add_triple raised #{e.class}: #{e.message}")
|
101
|
+
puts e.backtrace if $DEBUG
|
102
|
+
raise if @strict
|
103
|
+
end
|
104
|
+
|
105
|
+
def namespace(uri, prefix)
|
106
|
+
add_debug("namesspace", "'#{prefix}' <#{uri}>")
|
107
|
+
uri = @default_ns if uri == '#'
|
108
|
+
@nsbinding[prefix] = uri
|
109
|
+
add_debug("namesspace", "ns #{prefix}: <#{uri}>")
|
110
|
+
end
|
111
|
+
|
112
|
+
def process_statements(document)
|
113
|
+
document.elements.find_all do |e|
|
114
|
+
s = e.elements.first
|
115
|
+
add_debug(*s.info("process_statements"))
|
116
|
+
|
117
|
+
if s.respond_to?(:subject)
|
118
|
+
subject = process_expression(s.subject)
|
119
|
+
add_debug(*s.info("process_statements(#{subject})"))
|
120
|
+
properties = process_properties(s.property_list)
|
121
|
+
properties.each do |p|
|
122
|
+
predicate = process_verb(p.verb)
|
123
|
+
add_debug(*p.info("process_statements(#{subject}, #{predicate})"))
|
124
|
+
raise RDF::ReaderError, %Q(Illegal statment: "#{predicate}" missing object) unless p.respond_to?(:object_list)
|
125
|
+
objects = process_objects(p.object_list)
|
126
|
+
objects.each do |object|
|
127
|
+
if p.verb.respond_to?(:invert)
|
128
|
+
add_triple("statement", object, predicate, subject)
|
129
|
+
else
|
130
|
+
add_triple("statement", subject, predicate, object)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
elsif s.respond_to?(:anonnode)
|
135
|
+
process_anonnode(s)
|
136
|
+
elsif s.respond_to?(:pathitem)
|
137
|
+
process_path(s)
|
138
|
+
elsif s.respond_to?(:declaration)
|
139
|
+
if s.respond_to?(:nprefix)
|
140
|
+
add_debug(*s.info("process_statements(namespace)"))
|
141
|
+
keyword_check("prefix") if s.text_value.index("prefix") == 0
|
142
|
+
uri = process_uri(s.explicituri.uri, false)
|
143
|
+
namespace(uri, s.nprefix.text_value)
|
144
|
+
elsif s.respond_to?(:base)
|
145
|
+
add_debug(*s.info("process_statements(base)"))
|
146
|
+
keyword_check("base") if s.text_value.index("base") == 0
|
147
|
+
# Base, set or update document URI
|
148
|
+
uri = s.explicituri.uri.text_value
|
149
|
+
@default_ns = process_uri(uri, false) # Don't normalize
|
150
|
+
add_debug("@default_ns", "#{@default_ns.inspect}")
|
151
|
+
@uri = process_uri(uri)
|
152
|
+
add_debug("@base", "#{@uri}")
|
153
|
+
@uri
|
154
|
+
elsif s.respond_to?(:keywords)
|
155
|
+
add_debug(*s.info("process_statements(keywords)"))
|
156
|
+
keyword_check("keywords") if s.text_value.index("keywords") == 0
|
157
|
+
@keywords = process_barename_csl(s.barename_csl) ||[]
|
158
|
+
add_debug("@keywords", @keywords.inspect)
|
159
|
+
if (@keywords & N3_KEYWORDS) != @keywords
|
160
|
+
raise RDF::ReaderError, "undefined keywords used: #{(@keywords - N3_KEYWORDS).to_sentence}" if @strict
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def process_barename_csl(list)
|
168
|
+
#add_debug(*list.info("process_barename_csl(list)"))
|
169
|
+
res = [list.barename.text_value] if list.respond_to?(:barename)
|
170
|
+
rest = process_barename_csl(list.barename_csl_tail) if list.respond_to?(:barename_csl_tail)
|
171
|
+
rest ? res + rest : res
|
172
|
+
end
|
173
|
+
|
174
|
+
def process_anonnode(anonnode)
|
175
|
+
add_debug(*anonnode.info("process_anonnode"))
|
176
|
+
bnode = self.bnode
|
177
|
+
|
178
|
+
if anonnode.respond_to?(:property_list)
|
179
|
+
properties = process_properties(anonnode.property_list)
|
180
|
+
properties.each do |p|
|
181
|
+
predicate = process_verb(p.verb)
|
182
|
+
add_debug(*p.info("anonnode[#{predicate}]"))
|
183
|
+
objects = process_objects(p.object_list)
|
184
|
+
objects.each { |object| add_triple("anonnode", bnode, predicate, object) }
|
185
|
+
end
|
186
|
+
elsif anonnode.respond_to?(:path_list)
|
187
|
+
objects = process_objects(anonnode.path_list)
|
188
|
+
last = objects.pop
|
189
|
+
first_bnode = bnode
|
190
|
+
objects.each do |object|
|
191
|
+
add_triple("anonnode", first_bnode, RDF.first, object)
|
192
|
+
rest_bnode = self.bnode
|
193
|
+
add_triple("anonnode", first_bnode, RDF.rest, rest_bnode)
|
194
|
+
first_bnode = rest_bnode
|
195
|
+
end
|
196
|
+
if last
|
197
|
+
add_triple("anonnode", first_bnode, RDF.first, last)
|
198
|
+
add_triple("anonnode", first_bnode, RDF.rest, RDF.nil)
|
199
|
+
else
|
200
|
+
bnode = RDF.nil
|
201
|
+
end
|
202
|
+
end
|
203
|
+
bnode
|
204
|
+
end
|
205
|
+
|
206
|
+
def process_verb(verb)
|
207
|
+
add_debug(*verb.info("process_verb"))
|
208
|
+
case verb.text_value
|
209
|
+
when "a"
|
210
|
+
# If "a" is a keyword, then it's RDF_TYPE, otherwise it's expanded from the default namespace
|
211
|
+
if @keywords.nil? || @keywords.include?("a")
|
212
|
+
RDF_TYPE
|
213
|
+
else
|
214
|
+
build_uri("a")
|
215
|
+
end
|
216
|
+
when "@a" then RDF::RDF.type
|
217
|
+
when "=" then RDF::OWL.sameAs
|
218
|
+
when "=>" then RDF::OWL.implies
|
219
|
+
when "<=" then RDF::OWL.implies
|
220
|
+
when /^(@?is)\s+.*\s+(@?of)$/
|
221
|
+
keyword_check("is") if $1 == "is"
|
222
|
+
keyword_check("of") if $2 == "of"
|
223
|
+
process_expression(verb.prop)
|
224
|
+
when /^has\s+/
|
225
|
+
keyword_check("has")
|
226
|
+
process_expression(verb.prop)
|
227
|
+
else
|
228
|
+
if verb.respond_to?(:prop)
|
229
|
+
process_expression(verb.prop)
|
230
|
+
else
|
231
|
+
process_expression(verb)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def process_expression(expression)
|
237
|
+
if expression.respond_to?(:pathitem) && expression.respond_to?(:expression)
|
238
|
+
add_debug(*expression.info("process_expression(pathitem && expression)"))
|
239
|
+
process_path(expression) # Returns last object in chain
|
240
|
+
elsif expression.respond_to?(:uri)
|
241
|
+
add_debug(*expression.info("process_expression(uri)"))
|
242
|
+
process_uri(expression.uri)
|
243
|
+
elsif expression.respond_to?(:localname)
|
244
|
+
add_debug(*expression.info("process_expression(localname)"))
|
245
|
+
build_uri(expression)
|
246
|
+
elsif expression.respond_to?(:anonnode)
|
247
|
+
add_debug(*expression.info("process_expression(anonnode)"))
|
248
|
+
process_anonnode(expression)
|
249
|
+
elsif expression.respond_to?(:literal)
|
250
|
+
add_debug(*expression.info("process_expression(literal)"))
|
251
|
+
process_literal(expression)
|
252
|
+
elsif expression.respond_to?(:numericliteral)
|
253
|
+
add_debug(*expression.info("process_expression(numericliteral)"))
|
254
|
+
process_numeric_literal(expression)
|
255
|
+
elsif expression.respond_to?(:boolean)
|
256
|
+
add_debug(*expression.info("process_expression(boolean)"))
|
257
|
+
barename = expression.text_value.to_s
|
258
|
+
if @keywords && !@keywords.include?(barename)
|
259
|
+
build_uri(barename)
|
260
|
+
else
|
261
|
+
RDF::Literal.new(barename.delete("@"), :datatype => XSD.boolean)
|
262
|
+
end
|
263
|
+
elsif expression.respond_to?(:barename)
|
264
|
+
add_debug(*expression.info("process_expression(barename)"))
|
265
|
+
barename = expression.text_value.to_s
|
266
|
+
|
267
|
+
# Should only happen if @keywords is defined, and text_value is not a defined keyword
|
268
|
+
case barename
|
269
|
+
when "true" then RDF::Literal.new("true", :datatype => XSD.boolean)
|
270
|
+
when "false" then RDF::Literal.new("false", :datatype => XSD.boolean)
|
271
|
+
else
|
272
|
+
# create URI using barename, unless it's in defined set, in which case it's an error
|
273
|
+
raise RDF::ReaderError, %Q(Keyword "#{barename}" used as expression) if @keywords && @keywords.include?(barename)
|
274
|
+
build_uri(barename)
|
275
|
+
end
|
276
|
+
else
|
277
|
+
add_debug(*expression.info("process_expression(else)"))
|
278
|
+
build_uri(expression)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
# Process a path, such as:
|
283
|
+
# :a.:b means [is :b of :a]
|
284
|
+
# :a!:b means [is :b of :a]
|
285
|
+
# :a^:b means [:b :a]
|
286
|
+
#
|
287
|
+
# Elements may be strug together, with the last element the verb applied to the previous expression:
|
288
|
+
# :a.:b.:c means [is :c of [ is :b of :a]]
|
289
|
+
# :a!:b^:c meands [:c [ is :b of :a]]
|
290
|
+
def process_path(path)
|
291
|
+
add_debug(*path.info("process_path"))
|
292
|
+
|
293
|
+
object = process_expression(path.pathitem)
|
294
|
+
|
295
|
+
# Create a list of direction/predicate pairs
|
296
|
+
path_list = process_path_list(path.expression, path.respond_to?(:reverse))
|
297
|
+
#puts path_list.inspect
|
298
|
+
# Now we should have the following
|
299
|
+
# [
|
300
|
+
# [:forward, b]
|
301
|
+
# [:forward, c]
|
302
|
+
# ]
|
303
|
+
path_list.each do |p|
|
304
|
+
reverse, pred = p
|
305
|
+
bnode = self.bnode
|
306
|
+
if reverse
|
307
|
+
add_triple("path(#{reverse})", bnode, pred, object)
|
308
|
+
else
|
309
|
+
add_triple("path(#{reverse})", object, pred, bnode)
|
310
|
+
end
|
311
|
+
object = bnode
|
312
|
+
end
|
313
|
+
object
|
314
|
+
end
|
315
|
+
|
316
|
+
# Returns array of [:forward/:reverse, element] pairs
|
317
|
+
def process_path_list(path, reverse)
|
318
|
+
add_debug(*path.info("process_path_list(#{reverse})"))
|
319
|
+
if path.respond_to?(:pathitem)
|
320
|
+
[[reverse, process_expression(path.pathitem)]] + process_path_list(path.expression, path.respond_to?(:reverse))
|
321
|
+
else
|
322
|
+
[[reverse, process_expression(path)]]
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def process_uri(uri, normalize = true)
|
327
|
+
uri = uri.text_value if uri.respond_to?(:text_value)
|
328
|
+
# Use non-normalized URI from @default_ns when constructing URIs
|
329
|
+
if uri.match(/^\#/) && @default_ns
|
330
|
+
@default_ns.join(uri.rdf_escape)
|
331
|
+
else
|
332
|
+
base_uri = @default_ns || @uri
|
333
|
+
base_uri.join(uri).normalize!
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def process_properties(properties)
|
338
|
+
add_debug(*properties.info("process_properties"))
|
339
|
+
result = []
|
340
|
+
result << properties if properties.respond_to?(:verb)
|
341
|
+
result << process_properties(properties.property_list) if properties.respond_to?(:property_list)
|
342
|
+
result.flatten
|
343
|
+
end
|
344
|
+
|
345
|
+
def process_objects(objects)
|
346
|
+
add_debug(*objects.info("process_objects"))
|
347
|
+
result = []
|
348
|
+
if objects.respond_to?(:object)
|
349
|
+
result << process_expression(objects.object)
|
350
|
+
elsif objects.respond_to?(:pathitem)
|
351
|
+
result << process_expression(objects)
|
352
|
+
elsif objects.respond_to?(:expression)
|
353
|
+
result << process_expression(objects.expression)
|
354
|
+
result << process_objects(objects.path_list) if objects.respond_to?(:path_list)
|
355
|
+
elsif !objects.text_value.empty? || objects.respond_to?(:nprefix)
|
356
|
+
result << process_expression(objects)
|
357
|
+
end
|
358
|
+
result << process_objects(objects.object_list) if objects.respond_to?(:object_list)
|
359
|
+
result.flatten
|
360
|
+
end
|
361
|
+
|
362
|
+
def process_literal(object)
|
363
|
+
add_debug(*object.info("process_literal"))
|
364
|
+
encoding, language = nil, nil
|
365
|
+
string, type = object.elements
|
366
|
+
|
367
|
+
unless type.elements.nil?
|
368
|
+
#puts type.elements.inspect
|
369
|
+
if (type.elements[0].text_value=='@')
|
370
|
+
language = type.elements[1].text_value
|
371
|
+
else
|
372
|
+
encoding = process_expression(type.elements[1])
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
# Evaluate text_value to remove redundant escapes
|
377
|
+
#puts string.elements[1].text_value.dump
|
378
|
+
# FIXME: RDF::Literal doesn't work properly with rdf encoding
|
379
|
+
lit = RDF::Literal.new(string.elements[1].text_value.rdf_unescape, :language => language)
|
380
|
+
# FIXME: No lit.valid?
|
381
|
+
#raise RDF::ReaderError, %(Typed literal has an invalid lexical value: #{encoding.to_n3} "#{lit.contents}") if @strict && !lit.valid?
|
382
|
+
lit
|
383
|
+
end
|
384
|
+
|
385
|
+
def process_numeric_literal(object)
|
386
|
+
add_debug(*object.info("process_numeric_literal"))
|
387
|
+
|
388
|
+
RDF::Literal.new(string.elements[1].text_value.rdf_unescape, :datatype => RDF::XSD[object.numericliteral])
|
389
|
+
end
|
390
|
+
|
391
|
+
def build_uri(expression)
|
392
|
+
prefix = expression.respond_to?(:nprefix) ? expression.nprefix.text_value.to_s : ""
|
393
|
+
localname = expression.localname.text_value if expression.respond_to?(:localname)
|
394
|
+
localname ||= (expression.respond_to?(:text_value) ? expression.text_value : expression).to_s.sub(/^:/, "")
|
395
|
+
localname = nil if localname.empty? # In N3/Turtle "_:" is not named
|
396
|
+
|
397
|
+
if expression.respond_to?(:info)
|
398
|
+
add_debug(*expression.info("build_uri(#{prefix.inspect}, #{localname.inspect})"))
|
399
|
+
else
|
400
|
+
add_debug("", "build_uri(#{prefix.inspect}, #{localname.inspect})")
|
401
|
+
end
|
402
|
+
|
403
|
+
uri = if @nsbinding[prefix]
|
404
|
+
RDF::URI.new(@nsbinding[prefix] + localname.to_s.rdf_escape)
|
405
|
+
elsif prefix == '_'
|
406
|
+
self.bnode(localname)
|
407
|
+
elsif prefix == "rdf"
|
408
|
+
# A special case
|
409
|
+
RDF::RDF[localname.to_s.rdf_escape]
|
410
|
+
else
|
411
|
+
@default_ns ||= "#{@uri}#"
|
412
|
+
RDF::URI.new(@default_ns + localname.to_s.rdf_escape)
|
413
|
+
end
|
414
|
+
add_debug(*expression.info("build_uri: #{uri.inspect}")) if expression.respond_to?(:info)
|
415
|
+
uri
|
416
|
+
end
|
417
|
+
|
418
|
+
# Is this an allowable keyword?
|
419
|
+
def keyword_check(kw)
|
420
|
+
unless (@keywords || %w(a is of has)).include?(kw)
|
421
|
+
raise RDF::ReaderError, "unqualified keyword '#{kw}' used without @keyword directive" if @strict
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
module Treetop
|
428
|
+
module Runtime
|
429
|
+
class SyntaxNode
|
430
|
+
# Brief information about a syntax node
|
431
|
+
def info(ctx = "")
|
432
|
+
m = self.singleton_methods(true)
|
433
|
+
if m.empty?
|
434
|
+
["@#{self.interval.first}", "#{ctx}['#{self.text_value}']"]
|
435
|
+
else
|
436
|
+
["@#{self.interval.first}", "#{ctx}[" +
|
437
|
+
self.singleton_methods(true).map do |mm|
|
438
|
+
v = self.send(m)
|
439
|
+
v = v.text_value if v.is_a?(SyntaxNode)
|
440
|
+
"#{mm}='#{v}'"
|
441
|
+
end.join(", ") +
|
442
|
+
"]"]
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
File without changes
|
@@ -0,0 +1,227 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
grammar N3Grammer
|
3
|
+
# Entry point to grammer
|
4
|
+
rule document
|
5
|
+
statements
|
6
|
+
end
|
7
|
+
|
8
|
+
rule alpha
|
9
|
+
[A-Z_a-z\p{Alpha}]
|
10
|
+
end
|
11
|
+
|
12
|
+
rule alphanumeric
|
13
|
+
alpha / [0-9]
|
14
|
+
end
|
15
|
+
|
16
|
+
rule barename_csl
|
17
|
+
space+ barename barename_csl_tail
|
18
|
+
/ ""
|
19
|
+
end
|
20
|
+
|
21
|
+
rule barename_csl_tail
|
22
|
+
space* "," space* barename space* barename_csl_tail
|
23
|
+
/ ""
|
24
|
+
end
|
25
|
+
|
26
|
+
rule boolean
|
27
|
+
"@"* ("true" / "false")
|
28
|
+
end
|
29
|
+
|
30
|
+
rule comment
|
31
|
+
'#' (![\n\r] .)*
|
32
|
+
end
|
33
|
+
|
34
|
+
rule declaration
|
35
|
+
"@"? 'keywords' barename_csl {
|
36
|
+
def declaration; true; end
|
37
|
+
def keywords; true;end
|
38
|
+
}
|
39
|
+
/ "@"? 'base' space+ explicituri:explicituri {
|
40
|
+
def declaration; true; end
|
41
|
+
def base; true; end
|
42
|
+
}
|
43
|
+
/ "@"? 'prefix' space+ nprefix:nprefix? ':' space* explicituri:explicituri {
|
44
|
+
def declaration; true; end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
rule decimal
|
49
|
+
integer '.' [0-9]+
|
50
|
+
end
|
51
|
+
|
52
|
+
rule double
|
53
|
+
decimal [eE] integer
|
54
|
+
end
|
55
|
+
|
56
|
+
rule existential
|
57
|
+
"@"? "forSome" space+ symbol_csl
|
58
|
+
end
|
59
|
+
|
60
|
+
rule explicituri
|
61
|
+
"<" uri:URI_Reference ">"
|
62
|
+
end
|
63
|
+
|
64
|
+
rule expression
|
65
|
+
pathitem space* '.' expression
|
66
|
+
/ pathitem space* "!" space* expression
|
67
|
+
/ pathitem space* "^" space* expression { def reverse; true; end }
|
68
|
+
/ pathitem
|
69
|
+
end
|
70
|
+
|
71
|
+
rule barename
|
72
|
+
alpha (alphanumeric / '-')*
|
73
|
+
end
|
74
|
+
|
75
|
+
rule hexdigit
|
76
|
+
[0-9a-fA-F]
|
77
|
+
end
|
78
|
+
|
79
|
+
rule integer
|
80
|
+
[+-]? [0-9]+
|
81
|
+
end
|
82
|
+
|
83
|
+
rule language
|
84
|
+
[a-z]+ ( "-" [a-z0-9]+ )*
|
85
|
+
end
|
86
|
+
|
87
|
+
rule literal
|
88
|
+
(string_single / string_multi) ("^^" symbol / "@" language )?
|
89
|
+
end
|
90
|
+
|
91
|
+
rule localname
|
92
|
+
alpha (alphanumeric / '-')*
|
93
|
+
end
|
94
|
+
|
95
|
+
rule nprefix
|
96
|
+
alpha (alphanumeric / '-')*
|
97
|
+
end
|
98
|
+
|
99
|
+
rule numericliteral
|
100
|
+
double { def numericliteral; "double"; end}
|
101
|
+
/ decimal { def numericliteral; "decimal"; end}
|
102
|
+
/ integer { def numericliteral; "integer"; end}
|
103
|
+
end
|
104
|
+
|
105
|
+
rule object
|
106
|
+
expression
|
107
|
+
end
|
108
|
+
|
109
|
+
rule object_list
|
110
|
+
object space* "," space* object_list
|
111
|
+
/ object
|
112
|
+
end
|
113
|
+
|
114
|
+
rule pathitem
|
115
|
+
boolean { def boolean; true; end }
|
116
|
+
/ literal { def literal; true; end }
|
117
|
+
/ numericliteral
|
118
|
+
#/ quickvariable
|
119
|
+
/ symbol
|
120
|
+
/ "[" space* "]" { def anonnode; true; end }
|
121
|
+
/ "[" space* property_list space* "]" { def anonnode; true; end }
|
122
|
+
/ "{" space* statements space* "}" { def anonnode; true; end }
|
123
|
+
/ "(" space* path_list space* ")" { def anonnode; true; end }
|
124
|
+
end
|
125
|
+
|
126
|
+
rule path_list
|
127
|
+
expression space* path_list
|
128
|
+
/ ""
|
129
|
+
end
|
130
|
+
|
131
|
+
rule prop
|
132
|
+
expression
|
133
|
+
end
|
134
|
+
|
135
|
+
rule property_list
|
136
|
+
verb space* object_list space* ";"+ space* property_list
|
137
|
+
/ verb space* object_list space* ";"*
|
138
|
+
/ verb space* ";"* {def object_missing; true; end}
|
139
|
+
/ ""
|
140
|
+
end
|
141
|
+
|
142
|
+
rule qname
|
143
|
+
nprefix ":" localname
|
144
|
+
/ nprefix ':' { def text_value; ""; end }
|
145
|
+
/ ':' localname*
|
146
|
+
/ localname { def barename; true; end }
|
147
|
+
end
|
148
|
+
|
149
|
+
rule simpleStatement
|
150
|
+
subject space+ property_list
|
151
|
+
/ subject # For [] and a.b
|
152
|
+
end
|
153
|
+
|
154
|
+
rule space
|
155
|
+
[ \t\n\r]+ / comment
|
156
|
+
end
|
157
|
+
|
158
|
+
rule statement
|
159
|
+
declaration
|
160
|
+
/ existential
|
161
|
+
/ simpleStatement
|
162
|
+
/ universal
|
163
|
+
end
|
164
|
+
|
165
|
+
rule statements
|
166
|
+
(space / statement space* ('.' space*)? )*
|
167
|
+
end
|
168
|
+
|
169
|
+
# " constant-value-with-escaping "
|
170
|
+
rule string_single
|
171
|
+
'""' !["] / '"' string_single_char+ '"'
|
172
|
+
end
|
173
|
+
|
174
|
+
rule string_single_char
|
175
|
+
!["\n\r] (
|
176
|
+
("\\"
|
177
|
+
[\\\"bfnrt]
|
178
|
+
/ ( "u" hexdigit hexdigit hexdigit hexdigit )
|
179
|
+
/ ( "U" "00" hexdigit hexdigit hexdigit hexdigit hexdigit hexdigit)
|
180
|
+
)
|
181
|
+
/ .)
|
182
|
+
end
|
183
|
+
|
184
|
+
# """ constant value with escaping including single or double occurrences of quotes and/or newlines """
|
185
|
+
rule string_multi
|
186
|
+
'"""' string_multi_single_char* '"""'
|
187
|
+
end
|
188
|
+
|
189
|
+
rule string_multi_single_char
|
190
|
+
"\\\""
|
191
|
+
/ !('"""') .
|
192
|
+
end
|
193
|
+
|
194
|
+
rule subject
|
195
|
+
expression
|
196
|
+
end
|
197
|
+
|
198
|
+
rule symbol
|
199
|
+
qname / explicituri
|
200
|
+
end
|
201
|
+
|
202
|
+
rule symbol_csl
|
203
|
+
symbol space* "," space* symbol_csl
|
204
|
+
/ symbol
|
205
|
+
end
|
206
|
+
|
207
|
+
rule verb
|
208
|
+
"@"? "has" space+ prop # has xxx
|
209
|
+
/ "@"? "is" space+ prop space+ "@"? "of" { # is xxx of
|
210
|
+
def invert; true; end
|
211
|
+
}
|
212
|
+
/ "@"? "a" !":" # has rdf:type
|
213
|
+
/ "=>" # has log:implies
|
214
|
+
/ "<=" { def invert; true; end } # is log:implies of
|
215
|
+
/ "=" # has owl:sameAs
|
216
|
+
/ prop # has xxx of -- shorthand
|
217
|
+
end
|
218
|
+
|
219
|
+
rule universal
|
220
|
+
"@"? "forAll" space+ symbol_csl
|
221
|
+
end
|
222
|
+
|
223
|
+
rule URI_Reference
|
224
|
+
[^{}<>]*
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|