From 283c42bf8f402b72e12df0b97ab528c39240314b Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Tue, 16 Aug 2011 14:53:13 +0200 Subject: [PATCH] Initial commit. --- .gitignore | 31 + LICENSE_1_0.txt | 23 + README.html | 450 + README.rst | 129 + autoddoc.cfg | 37 + autoddoc.py | 657 ++ cdc.d | 663 ++ .../articles/spec_differences.doctree | Bin 0 -> 14319 bytes doc/doctrees/environment.pickle | Bin 0 -> 12354 bytes doc/doctrees/index.doctree | Bin 0 -> 4116 bytes doc/doctrees/tutorials/custom_types.doctree | Bin 0 -> 26067 bytes .../tutorials/getting_started.doctree | Bin 0 -> 31780 bytes doc/doctrees/tutorials/yaml_syntax.doctree | Bin 0 -> 29099 bytes doc/html/.buildinfo | 4 + .../_sources/articles/spec_differences.txt | 65 + doc/html/_sources/index.txt | 21 + doc/html/_sources/tutorials/custom_types.txt | 227 + .../_sources/tutorials/getting_started.txt | 168 + doc/html/_sources/tutorials/yaml_syntax.txt | 273 + doc/html/_static/basic.css | 509 + doc/html/_static/default.css | 255 + doc/html/_static/doctools.js | 247 + doc/html/_static/file.png | Bin 0 -> 392 bytes doc/html/_static/jquery.js | 8176 +++++++++++++++++ doc/html/_static/logo210.png | Bin 0 -> 5329 bytes doc/html/_static/minus.png | Bin 0 -> 199 bytes doc/html/_static/plus.png | Bin 0 -> 199 bytes doc/html/_static/pygments.css | 61 + doc/html/_static/searchtools.js | 518 ++ doc/html/_static/sidebar.js | 147 + doc/html/_static/underscore.js | 16 + doc/html/api/css/style.css | 220 + doc/html/api/dyaml.constructor.html | 192 + doc/html/api/dyaml.exception.html | 78 + doc/html/api/dyaml.loader.html | 216 + doc/html/api/dyaml.node.html | 260 + doc/html/api/dyaml.resolver.html | 99 + doc/html/api/images/logo.png | Bin 0 -> 2812 bytes doc/html/api/index.html | 61 + doc/html/articles/spec_differences.html | 150 + doc/html/index.html | 110 + doc/html/objects.inv | Bin 0 -> 202 bytes doc/html/search.html | 94 + doc/html/searchindex.js | 1 + doc/html/tutorials/custom_types.html | 289 + doc/html/tutorials/getting_started.html | 231 + doc/html/tutorials/yaml_syntax.html | 338 + docsrc/Makefile | 139 + docsrc/articles/spec_differences.rst | 65 + docsrc/autoddoc_index.dd | 19 + docsrc/conf.py | 236 + docsrc/index.rst | 21 + docsrc/logo128.png | Bin 0 -> 2812 bytes docsrc/logo210.png | Bin 0 -> 5329 bytes docsrc/tutorials/custom_types.rst | 227 + docsrc/tutorials/getting_started.rst | 168 + docsrc/tutorials/yaml_syntax.rst | 273 + dyaml/composer.d | 324 + dyaml/constructor.d | 683 ++ dyaml/event.d | 153 + dyaml/exception.d | 75 + dyaml/loader.d | 330 + dyaml/node.d | 720 ++ dyaml/parser.d | 842 ++ dyaml/reader.d | 482 + dyaml/resolver.d | 221 + dyaml/scanner.d | 1632 ++++ dyaml/token.d | 139 + dyaml/util.d | 36 + examples/constructor/Makefile | 2 + examples/constructor/input.yaml | 8 + examples/constructor/main.d | 110 + examples/getting_started/Makefile | 2 + examples/getting_started/input.yaml | 4 + examples/getting_started/main.d | 12 + examples/resolver/Makefile | 2 + examples/resolver/input.yaml | 8 + examples/resolver/main.d | 114 + test/data/a-nasty-libyaml-bug.loader-error | 1 + test/data/aliases-cdumper-bug.code | 1 + test/data/aliases.events | 8 + test/data/bool.data | 4 + test/data/bool.detect | 1 + test/data/colon-in-flow-context.loader-error | 1 + test/data/construct-binary.code | 1 + test/data/construct-binary.data | 12 + test/data/construct-bool.code | 1 + test/data/construct-bool.data | 9 + test/data/construct-custom.code | 1 + test/data/construct-custom.data | 9 + test/data/construct-float.code | 1 + test/data/construct-float.data | 6 + test/data/construct-int.code | 1 + test/data/construct-int.data | 6 + test/data/construct-map.code | 1 + test/data/construct-map.data | 6 + test/data/construct-merge.code | 1 + test/data/construct-merge.data | 27 + test/data/construct-null.code | 1 + test/data/construct-null.data | 18 + test/data/construct-omap.code | 1 + test/data/construct-omap.data | 8 + test/data/construct-pairs.code | 1 + test/data/construct-pairs.data | 7 + test/data/construct-seq.code | 1 + test/data/construct-seq.data | 15 + test/data/construct-set.code | 1 + test/data/construct-set.data | 7 + test/data/construct-str-ascii.code | 1 + test/data/construct-str-ascii.data | 1 + test/data/construct-str-utf8.code | 1 + test/data/construct-str-utf8.data | 1 + test/data/construct-str.code | 1 + test/data/construct-str.data | 1 + test/data/construct-timestamp.code | 1 + test/data/construct-timestamp.data | 5 + test/data/construct-value.code | 1 + test/data/construct-value.data | 10 + ...nt-separator-in-quoted-scalar.loader-error | 11 + test/data/documents.events | 11 + test/data/duplicate-anchor-1.loader-error | 3 + test/data/duplicate-anchor-2.loader-error | 1 + test/data/duplicate-merge-key.code | 1 + test/data/duplicate-merge-key.data | 4 + .../data/duplicate-tag-directive.loader-error | 3 + .../duplicate-yaml-directive.loader-error | 3 + ...scalar-in-simple-key-context-bug.canonical | 6 + ...lock-scalar-in-simple-key-context-bug.data | 4 + test/data/empty-anchor.emitter-error | 5 + test/data/empty-document-bug.canonical | 1 + test/data/empty-document-bug.data | 0 test/data/empty-document-bug.empty | 0 test/data/empty-documents.single-loader-error | 2 + test/data/empty-python-module.loader-error | 1 + test/data/empty-python-name.loader-error | 1 + test/data/empty-tag-handle.emitter-error | 5 + test/data/empty-tag-prefix.emitter-error | 5 + test/data/empty-tag.emitter-error | 5 + test/data/expected-document-end.emitter-error | 6 + .../expected-document-start.emitter-error | 4 + test/data/expected-mapping.loader-error | 1 + test/data/expected-node-1.emitter-error | 4 + test/data/expected-node-2.emitter-error | 7 + test/data/expected-nothing.emitter-error | 4 + test/data/expected-scalar.loader-error | 1 + test/data/expected-sequence.loader-error | 1 + test/data/expected-stream-start.emitter-error | 2 + .../explicit-document.single-loader-error | 4 + .../data/fetch-complex-value-bug.loader-error | 2 + test/data/float-representer-2.3-bug.code | 1 + test/data/float-representer-2.3-bug.data | 5 + test/data/float.data | 6 + test/data/float.detect | 1 + test/data/forbidden-entry.loader-error | 2 + test/data/forbidden-key.loader-error | 2 + test/data/forbidden-value.loader-error | 1 + .../implicit-document.single-loader-error | 3 + test/data/int.data | 6 + test/data/int.detect | 1 + test/data/invalid-anchor-1.loader-error | 1 + test/data/invalid-anchor-2.loader-error | 8 + test/data/invalid-anchor.emitter-error | 5 + test/data/invalid-base64-data-2.loader-error | 2 + test/data/invalid-base64-data.loader-error | 2 + ...nvalid-block-scalar-indicator.loader-error | 2 + test/data/invalid-character.loader-error | Bin 0 -> 2209 bytes test/data/invalid-character.stream-error | Bin 0 -> 4193 bytes test/data/invalid-directive-line.loader-error | 2 + .../invalid-directive-name-1.loader-error | 2 + .../invalid-directive-name-2.loader-error | 2 + .../invalid-escape-character.loader-error | 1 + test/data/invalid-escape-numbers.loader-error | 1 + ...valid-indentation-indicator-1.loader-error | 2 + ...valid-indentation-indicator-2.loader-error | 2 + ...d-item-without-trailing-break.loader-error | 2 + test/data/invalid-merge-1.loader-error | 2 + test/data/invalid-merge-2.loader-error | 2 + test/data/invalid-omap-1.loader-error | 3 + test/data/invalid-omap-2.loader-error | 3 + test/data/invalid-omap-3.loader-error | 4 + test/data/invalid-pairs-1.loader-error | 3 + test/data/invalid-pairs-2.loader-error | 3 + test/data/invalid-pairs-3.loader-error | 4 + test/data/invalid-simple-key.loader-error | 3 + test/data/invalid-single-quote-bug.code | 1 + test/data/invalid-single-quote-bug.data | 2 + .../invalid-starting-character.loader-error | 1 + test/data/invalid-tag-1.loader-error | 1 + test/data/invalid-tag-2.loader-error | 1 + .../invalid-tag-directive-handle.loader-error | 2 + .../invalid-tag-directive-prefix.loader-error | 2 + test/data/invalid-tag-handle-1.emitter-error | 5 + test/data/invalid-tag-handle-1.loader-error | 2 + test/data/invalid-tag-handle-2.emitter-error | 5 + test/data/invalid-tag-handle-2.loader-error | 2 + test/data/invalid-uri-escapes-1.loader-error | 1 + test/data/invalid-uri-escapes-2.loader-error | 1 + test/data/invalid-uri-escapes-3.loader-error | 1 + test/data/invalid-uri.loader-error | 1 + test/data/invalid-utf8-byte.loader-error | 66 + test/data/invalid-utf8-byte.stream-error | 66 + ...alid-yaml-directive-version-1.loader-error | 3 + ...alid-yaml-directive-version-2.loader-error | 2 + ...alid-yaml-directive-version-3.loader-error | 2 + ...alid-yaml-directive-version-4.loader-error | 2 + ...alid-yaml-directive-version-5.loader-error | 2 + ...alid-yaml-directive-version-6.loader-error | 2 + test/data/invalid-yaml-version.loader-error | 2 + test/data/latin.unicode | 384 + test/data/mappings.events | 44 + test/data/merge.data | 1 + test/data/merge.detect | 1 + test/data/more-floats.code | 1 + test/data/more-floats.data | 1 + test/data/negative-float-bug.code | 1 + test/data/negative-float-bug.data | 1 + test/data/no-alias-anchor.emitter-error | 8 + test/data/no-alias-anchor.skip-ext | 0 .../data/no-block-collection-end.loader-error | 3 + test/data/no-block-mapping-end-2.loader-error | 3 + test/data/no-block-mapping-end.loader-error | 1 + test/data/no-document-start.loader-error | 3 + test/data/no-flow-mapping-end.loader-error | 1 + test/data/no-flow-sequence-end.loader-error | 1 + test/data/no-node-1.loader-error | 1 + test/data/no-node-2.loader-error | 1 + test/data/no-tag.emitter-error | 5 + test/data/null.data | 3 + test/data/null.detect | 1 + test/data/odd-utf16.stream-error | Bin 0 -> 1311 bytes test/data/recursive.former-dumper-error | 3 + ...emove-possible-simple-key-bug.loader-error | 3 + test/data/resolver.data | 30 + test/data/resolver.path | 30 + test/data/run-parser-crash-bug.data | 8 + test/data/scalars.events | 28 + test/data/scan-document-end-bug.canonical | 3 + test/data/scan-document-end-bug.data | 3 + test/data/scan-line-break-bug.canonical | 3 + test/data/scan-line-break-bug.data | 3 + test/data/sequences.events | 81 + .../serializer-is-already-opened.dumper-error | 3 + test/data/serializer-is-closed-1.dumper-error | 4 + test/data/serializer-is-closed-2.dumper-error | 4 + .../serializer-is-not-opened-1.dumper-error | 2 + .../serializer-is-not-opened-2.dumper-error | 2 + test/data/single-dot-is-not-float-bug.code | 1 + test/data/single-dot-is-not-float-bug.data | 1 + test/data/sloppy-indentation.canonical | 18 + test/data/sloppy-indentation.data | 17 + test/data/spec-02-01.data | 3 + test/data/spec-02-01.structure | 1 + test/data/spec-02-01.tokens | 1 + test/data/spec-02-02.data | 3 + test/data/spec-02-02.structure | 1 + test/data/spec-02-02.tokens | 5 + test/data/spec-02-03.data | 8 + test/data/spec-02-03.structure | 1 + test/data/spec-02-03.tokens | 4 + test/data/spec-02-04.data | 8 + test/data/spec-02-04.structure | 4 + test/data/spec-02-04.tokens | 4 + test/data/spec-02-05.data | 3 + test/data/spec-02-05.structure | 5 + test/data/spec-02-05.tokens | 5 + test/data/spec-02-06.data | 5 + test/data/spec-02-06.structure | 4 + test/data/spec-02-06.tokens | 4 + test/data/spec-02-07.data | 10 + test/data/spec-02-07.structure | 4 + test/data/spec-02-07.tokens | 12 + test/data/spec-02-08.data | 10 + test/data/spec-02-08.structure | 4 + test/data/spec-02-08.tokens | 15 + test/data/spec-02-09.data | 8 + test/data/spec-02-09.structure | 1 + test/data/spec-02-09.tokens | 5 + test/data/spec-02-10.data | 8 + test/data/spec-02-10.structure | 1 + test/data/spec-02-10.tokens | 5 + test/data/spec-02-11.data | 9 + test/data/spec-02-11.structure | 4 + test/data/spec-02-11.tokens | 6 + test/data/spec-02-12.data | 8 + test/data/spec-02-12.structure | 5 + test/data/spec-02-12.tokens | 6 + test/data/spec-02-13.data | 4 + test/data/spec-02-13.structure | 1 + test/data/spec-02-13.tokens | 1 + test/data/spec-02-14.data | 4 + test/data/spec-02-14.structure | 1 + test/data/spec-02-14.tokens | 1 + test/data/spec-02-15.data | 8 + test/data/spec-02-15.structure | 1 + test/data/spec-02-15.tokens | 1 + test/data/spec-02-16.data | 7 + test/data/spec-02-16.structure | 1 + test/data/spec-02-16.tokens | 5 + test/data/spec-02-17.data | 7 + test/data/spec-02-17.structure | 1 + test/data/spec-02-17.tokens | 8 + test/data/spec-02-18.data | 6 + test/data/spec-02-18.structure | 1 + test/data/spec-02-18.tokens | 4 + test/data/spec-02-19.data | 5 + test/data/spec-02-19.structure | 1 + test/data/spec-02-19.tokens | 7 + test/data/spec-02-20.data | 6 + test/data/spec-02-20.structure | 1 + test/data/spec-02-20.tokens | 8 + test/data/spec-02-21.data | 4 + test/data/spec-02-21.structure | 1 + test/data/spec-02-21.tokens | 6 + test/data/spec-02-22.data | 4 + test/data/spec-02-22.structure | 1 + test/data/spec-02-22.tokens | 6 + test/data/spec-02-23.data | 13 + test/data/spec-02-23.structure | 1 + test/data/spec-02-23.tokens | 6 + test/data/spec-02-24.data | 14 + test/data/spec-02-24.structure | 5 + test/data/spec-02-24.tokens | 20 + test/data/spec-02-25.data | 7 + test/data/spec-02-25.structure | 1 + test/data/spec-02-25.tokens | 6 + test/data/spec-02-26.data | 7 + test/data/spec-02-26.structure | 5 + test/data/spec-02-26.tokens | 6 + test/data/spec-02-27.data | 29 + test/data/spec-02-27.structure | 17 + test/data/spec-02-27.tokens | 20 + test/data/spec-02-28.data | 26 + test/data/spec-02-28.structure | 10 + test/data/spec-02-28.tokens | 23 + test/data/spec-05-01-utf16be.data | Bin 0 -> 34 bytes test/data/spec-05-01-utf16be.empty | 2 + test/data/spec-05-01-utf16le.data | Bin 0 -> 34 bytes test/data/spec-05-01-utf16le.empty | 2 + test/data/spec-05-01-utf8.data | 1 + test/data/spec-05-01-utf8.empty | 2 + test/data/spec-05-02-utf16be.data | Bin 0 -> 90 bytes test/data/spec-05-02-utf16be.error | 3 + test/data/spec-05-02-utf16le.data | Bin 0 -> 90 bytes test/data/spec-05-02-utf16le.error | 3 + test/data/spec-05-02-utf8.data | 3 + test/data/spec-05-02-utf8.error | 3 + test/data/spec-05-03.canonical | 14 + test/data/spec-05-03.data | 7 + test/data/spec-05-04.canonical | 13 + test/data/spec-05-04.data | 2 + test/data/spec-05-05.data | 1 + test/data/spec-05-05.empty | 2 + test/data/spec-05-06.canonical | 8 + test/data/spec-05-06.data | 2 + test/data/spec-05-06.test_loader_skip | 0 test/data/spec-05-07.canonical | 8 + test/data/spec-05-07.data | 4 + test/data/spec-05-08.canonical | 8 + test/data/spec-05-08.data | 2 + test/data/spec-05-09.canonical | 3 + test/data/spec-05-09.data | 2 + test/data/spec-05-10.data | 2 + test/data/spec-05-10.error | 3 + test/data/spec-05-11.canonical | 6 + test/data/spec-05-11.data | 3 + test/data/spec-05-12.data | 9 + test/data/spec-05-12.error | 8 + test/data/spec-05-13.canonical | 5 + test/data/spec-05-13.data | 3 + test/data/spec-05-14.canonical | 7 + test/data/spec-05-14.data | 2 + test/data/spec-05-15.data | 3 + test/data/spec-05-15.error | 3 + test/data/spec-06-01.canonical | 15 + test/data/spec-06-01.data | 14 + test/data/spec-06-02.data | 3 + test/data/spec-06-02.empty | 2 + test/data/spec-06-03.canonical | 6 + test/data/spec-06-03.data | 2 + test/data/spec-06-04.canonical | 6 + test/data/spec-06-04.data | 4 + test/data/spec-06-05.canonical | 16 + test/data/spec-06-05.data | 6 + test/data/spec-06-06.canonical | 10 + test/data/spec-06-06.data | 7 + test/data/spec-06-07.canonical | 6 + test/data/spec-06-07.data | 8 + test/data/spec-06-08.canonical | 5 + test/data/spec-06-08.data | 2 + test/data/spec-07-01.canonical | 3 + test/data/spec-07-01.data | 3 + test/data/spec-07-01.skip-ext | 0 test/data/spec-07-02.canonical | 3 + test/data/spec-07-02.data | 4 + test/data/spec-07-02.skip-ext | 0 test/data/spec-07-03.data | 3 + test/data/spec-07-03.error | 3 + test/data/spec-07-04.canonical | 3 + test/data/spec-07-04.data | 3 + test/data/spec-07-05.data | 3 + test/data/spec-07-05.error | 4 + test/data/spec-07-06.canonical | 6 + test/data/spec-07-06.data | 5 + test/data/spec-07-06.test_loader_skip | 0 test/data/spec-07-07a.canonical | 3 + test/data/spec-07-07a.data | 2 + test/data/spec-07-07a.test_loader_skip | 0 test/data/spec-07-07b.canonical | 3 + test/data/spec-07-07b.data | 4 + test/data/spec-07-07b.test_loader_skip | 0 test/data/spec-07-08.canonical | 7 + test/data/spec-07-08.data | 9 + test/data/spec-07-08.test_loader_skip | 0 test/data/spec-07-09.canonical | 9 + test/data/spec-07-09.data | 11 + test/data/spec-07-10.canonical | 15 + test/data/spec-07-10.data | 11 + test/data/spec-07-11.data | 2 + test/data/spec-07-11.empty | 2 + test/data/spec-07-12a.canonical | 6 + test/data/spec-07-12a.data | 3 + test/data/spec-07-12b.canonical | 3 + test/data/spec-07-12b.data | 4 + test/data/spec-07-13.canonical | 9 + test/data/spec-07-13.data | 9 + test/data/spec-07-13.test_loader_skip | 0 test/data/spec-08-01.canonical | 8 + test/data/spec-08-01.data | 2 + test/data/spec-08-02.canonical | 8 + test/data/spec-08-02.data | 2 + test/data/spec-08-03.canonical | 6 + test/data/spec-08-03.data | 2 + test/data/spec-08-03.test_loader_skip | 0 test/data/spec-08-04.data | 2 + test/data/spec-08-04.error | 6 + test/data/spec-08-05.canonical | 7 + test/data/spec-08-05.data | 5 + test/data/spec-08-05.test_loader_skip | 0 test/data/spec-08-06.data | 5 + test/data/spec-08-06.error | 4 + test/data/spec-08-07.canonical | 8 + test/data/spec-08-07.data | 4 + test/data/spec-08-08.canonical | 15 + test/data/spec-08-08.data | 13 + test/data/spec-08-09.canonical | 21 + test/data/spec-08-09.data | 11 + test/data/spec-08-10.canonical | 23 + test/data/spec-08-10.data | 15 + test/data/spec-08-11.canonical | 8 + test/data/spec-08-11.data | 2 + test/data/spec-08-12.canonical | 10 + test/data/spec-08-12.data | 8 + test/data/spec-08-13.canonical | 10 + test/data/spec-08-13.data | 4 + test/data/spec-08-13.skip-ext | 0 test/data/spec-08-14.canonical | 10 + test/data/spec-08-14.data | 5 + test/data/spec-08-15.canonical | 11 + test/data/spec-08-15.data | 5 + test/data/spec-09-01.canonical | 11 + test/data/spec-09-01.data | 6 + test/data/spec-09-02.canonical | 7 + test/data/spec-09-02.data | 6 + test/data/spec-09-03.canonical | 7 + test/data/spec-09-03.data | 6 + test/data/spec-09-04.canonical | 6 + test/data/spec-09-04.data | 4 + test/data/spec-09-05.canonical | 7 + test/data/spec-09-05.data | 8 + test/data/spec-09-06.canonical | 3 + test/data/spec-09-06.data | 1 + test/data/spec-09-07.canonical | 11 + test/data/spec-09-07.data | 6 + test/data/spec-09-08.canonical | 6 + test/data/spec-09-08.data | 1 + test/data/spec-09-09.canonical | 7 + test/data/spec-09-09.data | 6 + test/data/spec-09-10.canonical | 5 + test/data/spec-09-10.data | 3 + test/data/spec-09-11.canonical | 6 + test/data/spec-09-11.data | 5 + test/data/spec-09-12.canonical | 12 + test/data/spec-09-12.data | 8 + test/data/spec-09-13.canonical | 11 + test/data/spec-09-13.data | 6 + test/data/spec-09-14.data | 14 + test/data/spec-09-14.error | 6 + test/data/spec-09-15.canonical | 18 + test/data/spec-09-15.data | 13 + test/data/spec-09-16.canonical | 6 + test/data/spec-09-16.data | 3 + test/data/spec-09-17.canonical | 4 + test/data/spec-09-17.data | 3 + test/data/spec-09-18.canonical | 8 + test/data/spec-09-18.data | 9 + test/data/spec-09-19.canonical | 6 + test/data/spec-09-19.data | 4 + test/data/spec-09-20.canonical | 8 + test/data/spec-09-20.data | 11 + test/data/spec-09-20.skip-ext | 0 test/data/spec-09-21.data | 8 + test/data/spec-09-21.error | 7 + test/data/spec-09-22.canonical | 10 + test/data/spec-09-22.data | 4 + test/data/spec-09-23.canonical | 10 + test/data/spec-09-23.data | 11 + test/data/spec-09-24.canonical | 10 + test/data/spec-09-24.data | 6 + test/data/spec-09-25.canonical | 4 + test/data/spec-09-25.data | 3 + test/data/spec-09-26.canonical | 3 + test/data/spec-09-26.data | 8 + test/data/spec-09-27.canonical | 3 + test/data/spec-09-27.data | 8 + test/data/spec-09-28.canonical | 3 + test/data/spec-09-28.data | 8 + test/data/spec-09-29.canonical | 4 + test/data/spec-09-29.data | 4 + test/data/spec-09-30.canonical | 7 + test/data/spec-09-30.data | 14 + test/data/spec-09-31.canonical | 7 + test/data/spec-09-31.data | 14 + test/data/spec-09-32.canonical | 7 + test/data/spec-09-32.data | 14 + test/data/spec-09-33.canonical | 7 + test/data/spec-09-33.data | 14 + test/data/spec-10-01.canonical | 12 + test/data/spec-10-01.data | 2 + test/data/spec-10-02.canonical | 14 + test/data/spec-10-02.data | 8 + test/data/spec-10-03.canonical | 12 + test/data/spec-10-03.data | 4 + test/data/spec-10-04.canonical | 11 + test/data/spec-10-04.data | 4 + test/data/spec-10-05.canonical | 14 + test/data/spec-10-05.data | 7 + test/data/spec-10-06.canonical | 16 + test/data/spec-10-06.data | 2 + test/data/spec-10-07.canonical | 16 + test/data/spec-10-07.data | 7 + test/data/spec-10-08.data | 5 + test/data/spec-10-08.error | 5 + test/data/spec-10-09.canonical | 8 + test/data/spec-10-09.data | 4 + test/data/spec-10-10.canonical | 16 + test/data/spec-10-10.data | 8 + test/data/spec-10-11.canonical | 24 + test/data/spec-10-11.data | 7 + test/data/spec-10-12.canonical | 9 + test/data/spec-10-12.data | 3 + test/data/spec-10-13.canonical | 11 + test/data/spec-10-13.data | 5 + test/data/spec-10-14.canonical | 11 + test/data/spec-10-14.data | 4 + test/data/spec-10-15.canonical | 18 + test/data/spec-10-15.data | 3 + test/data/str.data | 1 + test/data/str.detect | 1 + test/data/tags.events | 12 + test/data/test_mark.marks | 38 + test/data/timestamp-bugs.code | 1 + test/data/timestamp-bugs.data | 6 + test/data/timestamp.data | 5 + test/data/timestamp.detect | 1 + test/data/unclosed-bracket.loader-error | 6 + test/data/unclosed-quoted-scalar.loader-error | 2 + test/data/undefined-anchor.loader-error | 3 + test/data/undefined-constructor.loader-error | 1 + test/data/undefined-tag-handle.loader-error | 1 + test/data/unknown.dumper-error | 1 + test/data/unsupported-version.emitter-error | 5 + test/data/utf16be.code | 1 + test/data/utf16be.data | Bin 0 -> 30 bytes test/data/utf16le.code | 1 + test/data/utf16le.data | Bin 0 -> 30 bytes test/data/utf8-implicit.code | 1 + test/data/utf8-implicit.data | 1 + test/data/utf8.code | 1 + test/data/utf8.data | 1 + test/data/value.data | 1 + test/data/value.detect | 1 + test/data/yaml.data | 3 + test/data/yaml.detect | 1 + test/src/common.d | 202 + test/src/compare.d | 61 + test/src/constructor.d | 408 + test/src/errors.d | 103 + test/src/inputoutput.d | 101 + test/src/reader.d | 53 + test/src/tokens.d | 91 + unittest.d | 16 + yaml.d | 13 + 592 files changed, 26392 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE_1_0.txt create mode 100644 README.html create mode 100644 README.rst create mode 100644 autoddoc.cfg create mode 100755 autoddoc.py create mode 100755 cdc.d create mode 100644 doc/doctrees/articles/spec_differences.doctree create mode 100644 doc/doctrees/environment.pickle create mode 100644 doc/doctrees/index.doctree create mode 100644 doc/doctrees/tutorials/custom_types.doctree create mode 100644 doc/doctrees/tutorials/getting_started.doctree create mode 100644 doc/doctrees/tutorials/yaml_syntax.doctree create mode 100644 doc/html/.buildinfo create mode 100644 doc/html/_sources/articles/spec_differences.txt create mode 100644 doc/html/_sources/index.txt create mode 100644 doc/html/_sources/tutorials/custom_types.txt create mode 100644 doc/html/_sources/tutorials/getting_started.txt create mode 100644 doc/html/_sources/tutorials/yaml_syntax.txt create mode 100644 doc/html/_static/basic.css create mode 100644 doc/html/_static/default.css create mode 100644 doc/html/_static/doctools.js create mode 100644 doc/html/_static/file.png create mode 100644 doc/html/_static/jquery.js create mode 100644 doc/html/_static/logo210.png create mode 100644 doc/html/_static/minus.png create mode 100644 doc/html/_static/plus.png create mode 100644 doc/html/_static/pygments.css create mode 100644 doc/html/_static/searchtools.js create mode 100644 doc/html/_static/sidebar.js create mode 100644 doc/html/_static/underscore.js create mode 100644 doc/html/api/css/style.css create mode 100644 doc/html/api/dyaml.constructor.html create mode 100644 doc/html/api/dyaml.exception.html create mode 100644 doc/html/api/dyaml.loader.html create mode 100644 doc/html/api/dyaml.node.html create mode 100644 doc/html/api/dyaml.resolver.html create mode 100644 doc/html/api/images/logo.png create mode 100644 doc/html/api/index.html create mode 100644 doc/html/articles/spec_differences.html create mode 100644 doc/html/index.html create mode 100644 doc/html/objects.inv create mode 100644 doc/html/search.html create mode 100644 doc/html/searchindex.js create mode 100644 doc/html/tutorials/custom_types.html create mode 100644 doc/html/tutorials/getting_started.html create mode 100644 doc/html/tutorials/yaml_syntax.html create mode 100644 docsrc/Makefile create mode 100644 docsrc/articles/spec_differences.rst create mode 100644 docsrc/autoddoc_index.dd create mode 100644 docsrc/conf.py create mode 100644 docsrc/index.rst create mode 100644 docsrc/logo128.png create mode 100644 docsrc/logo210.png create mode 100644 docsrc/tutorials/custom_types.rst create mode 100644 docsrc/tutorials/getting_started.rst create mode 100644 docsrc/tutorials/yaml_syntax.rst create mode 100644 dyaml/composer.d create mode 100644 dyaml/constructor.d create mode 100644 dyaml/event.d create mode 100644 dyaml/exception.d create mode 100644 dyaml/loader.d create mode 100644 dyaml/node.d create mode 100644 dyaml/parser.d create mode 100644 dyaml/reader.d create mode 100644 dyaml/resolver.d create mode 100644 dyaml/scanner.d create mode 100644 dyaml/token.d create mode 100644 dyaml/util.d create mode 100644 examples/constructor/Makefile create mode 100644 examples/constructor/input.yaml create mode 100644 examples/constructor/main.d create mode 100644 examples/getting_started/Makefile create mode 100644 examples/getting_started/input.yaml create mode 100644 examples/getting_started/main.d create mode 100644 examples/resolver/Makefile create mode 100644 examples/resolver/input.yaml create mode 100644 examples/resolver/main.d create mode 100644 test/data/a-nasty-libyaml-bug.loader-error create mode 100644 test/data/aliases-cdumper-bug.code create mode 100644 test/data/aliases.events create mode 100644 test/data/bool.data create mode 100644 test/data/bool.detect create mode 100644 test/data/colon-in-flow-context.loader-error create mode 100644 test/data/construct-binary.code create mode 100644 test/data/construct-binary.data create mode 100644 test/data/construct-bool.code create mode 100644 test/data/construct-bool.data create mode 100644 test/data/construct-custom.code create mode 100644 test/data/construct-custom.data create mode 100644 test/data/construct-float.code create mode 100644 test/data/construct-float.data create mode 100644 test/data/construct-int.code create mode 100644 test/data/construct-int.data create mode 100644 test/data/construct-map.code create mode 100644 test/data/construct-map.data create mode 100644 test/data/construct-merge.code create mode 100644 test/data/construct-merge.data create mode 100644 test/data/construct-null.code create mode 100644 test/data/construct-null.data create mode 100644 test/data/construct-omap.code create mode 100644 test/data/construct-omap.data create mode 100644 test/data/construct-pairs.code create mode 100644 test/data/construct-pairs.data create mode 100644 test/data/construct-seq.code create mode 100644 test/data/construct-seq.data create mode 100644 test/data/construct-set.code create mode 100644 test/data/construct-set.data create mode 100644 test/data/construct-str-ascii.code create mode 100644 test/data/construct-str-ascii.data create mode 100644 test/data/construct-str-utf8.code create mode 100644 test/data/construct-str-utf8.data create mode 100644 test/data/construct-str.code create mode 100644 test/data/construct-str.data create mode 100644 test/data/construct-timestamp.code create mode 100644 test/data/construct-timestamp.data create mode 100644 test/data/construct-value.code create mode 100644 test/data/construct-value.data create mode 100644 test/data/document-separator-in-quoted-scalar.loader-error create mode 100644 test/data/documents.events create mode 100644 test/data/duplicate-anchor-1.loader-error create mode 100644 test/data/duplicate-anchor-2.loader-error create mode 100644 test/data/duplicate-merge-key.code create mode 100644 test/data/duplicate-merge-key.data create mode 100644 test/data/duplicate-tag-directive.loader-error create mode 100644 test/data/duplicate-yaml-directive.loader-error create mode 100644 test/data/emit-block-scalar-in-simple-key-context-bug.canonical create mode 100644 test/data/emit-block-scalar-in-simple-key-context-bug.data create mode 100644 test/data/empty-anchor.emitter-error create mode 100644 test/data/empty-document-bug.canonical create mode 100644 test/data/empty-document-bug.data create mode 100644 test/data/empty-document-bug.empty create mode 100644 test/data/empty-documents.single-loader-error create mode 100644 test/data/empty-python-module.loader-error create mode 100644 test/data/empty-python-name.loader-error create mode 100644 test/data/empty-tag-handle.emitter-error create mode 100644 test/data/empty-tag-prefix.emitter-error create mode 100644 test/data/empty-tag.emitter-error create mode 100644 test/data/expected-document-end.emitter-error create mode 100644 test/data/expected-document-start.emitter-error create mode 100644 test/data/expected-mapping.loader-error create mode 100644 test/data/expected-node-1.emitter-error create mode 100644 test/data/expected-node-2.emitter-error create mode 100644 test/data/expected-nothing.emitter-error create mode 100644 test/data/expected-scalar.loader-error create mode 100644 test/data/expected-sequence.loader-error create mode 100644 test/data/expected-stream-start.emitter-error create mode 100644 test/data/explicit-document.single-loader-error create mode 100644 test/data/fetch-complex-value-bug.loader-error create mode 100644 test/data/float-representer-2.3-bug.code create mode 100644 test/data/float-representer-2.3-bug.data create mode 100644 test/data/float.data create mode 100644 test/data/float.detect create mode 100644 test/data/forbidden-entry.loader-error create mode 100644 test/data/forbidden-key.loader-error create mode 100644 test/data/forbidden-value.loader-error create mode 100644 test/data/implicit-document.single-loader-error create mode 100644 test/data/int.data create mode 100644 test/data/int.detect create mode 100644 test/data/invalid-anchor-1.loader-error create mode 100644 test/data/invalid-anchor-2.loader-error create mode 100644 test/data/invalid-anchor.emitter-error create mode 100644 test/data/invalid-base64-data-2.loader-error create mode 100644 test/data/invalid-base64-data.loader-error create mode 100644 test/data/invalid-block-scalar-indicator.loader-error create mode 100644 test/data/invalid-character.loader-error create mode 100644 test/data/invalid-character.stream-error create mode 100644 test/data/invalid-directive-line.loader-error create mode 100644 test/data/invalid-directive-name-1.loader-error create mode 100644 test/data/invalid-directive-name-2.loader-error create mode 100644 test/data/invalid-escape-character.loader-error create mode 100644 test/data/invalid-escape-numbers.loader-error create mode 100644 test/data/invalid-indentation-indicator-1.loader-error create mode 100644 test/data/invalid-indentation-indicator-2.loader-error create mode 100644 test/data/invalid-item-without-trailing-break.loader-error create mode 100644 test/data/invalid-merge-1.loader-error create mode 100644 test/data/invalid-merge-2.loader-error create mode 100644 test/data/invalid-omap-1.loader-error create mode 100644 test/data/invalid-omap-2.loader-error create mode 100644 test/data/invalid-omap-3.loader-error create mode 100644 test/data/invalid-pairs-1.loader-error create mode 100644 test/data/invalid-pairs-2.loader-error create mode 100644 test/data/invalid-pairs-3.loader-error create mode 100644 test/data/invalid-simple-key.loader-error create mode 100644 test/data/invalid-single-quote-bug.code create mode 100644 test/data/invalid-single-quote-bug.data create mode 100644 test/data/invalid-starting-character.loader-error create mode 100644 test/data/invalid-tag-1.loader-error create mode 100644 test/data/invalid-tag-2.loader-error create mode 100644 test/data/invalid-tag-directive-handle.loader-error create mode 100644 test/data/invalid-tag-directive-prefix.loader-error create mode 100644 test/data/invalid-tag-handle-1.emitter-error create mode 100644 test/data/invalid-tag-handle-1.loader-error create mode 100644 test/data/invalid-tag-handle-2.emitter-error create mode 100644 test/data/invalid-tag-handle-2.loader-error create mode 100644 test/data/invalid-uri-escapes-1.loader-error create mode 100644 test/data/invalid-uri-escapes-2.loader-error create mode 100644 test/data/invalid-uri-escapes-3.loader-error create mode 100644 test/data/invalid-uri.loader-error create mode 100644 test/data/invalid-utf8-byte.loader-error create mode 100644 test/data/invalid-utf8-byte.stream-error create mode 100644 test/data/invalid-yaml-directive-version-1.loader-error create mode 100644 test/data/invalid-yaml-directive-version-2.loader-error create mode 100644 test/data/invalid-yaml-directive-version-3.loader-error create mode 100644 test/data/invalid-yaml-directive-version-4.loader-error create mode 100644 test/data/invalid-yaml-directive-version-5.loader-error create mode 100644 test/data/invalid-yaml-directive-version-6.loader-error create mode 100644 test/data/invalid-yaml-version.loader-error create mode 100644 test/data/latin.unicode create mode 100644 test/data/mappings.events create mode 100644 test/data/merge.data create mode 100644 test/data/merge.detect create mode 100644 test/data/more-floats.code create mode 100644 test/data/more-floats.data create mode 100644 test/data/negative-float-bug.code create mode 100644 test/data/negative-float-bug.data create mode 100644 test/data/no-alias-anchor.emitter-error create mode 100644 test/data/no-alias-anchor.skip-ext create mode 100644 test/data/no-block-collection-end.loader-error create mode 100644 test/data/no-block-mapping-end-2.loader-error create mode 100644 test/data/no-block-mapping-end.loader-error create mode 100644 test/data/no-document-start.loader-error create mode 100644 test/data/no-flow-mapping-end.loader-error create mode 100644 test/data/no-flow-sequence-end.loader-error create mode 100644 test/data/no-node-1.loader-error create mode 100644 test/data/no-node-2.loader-error create mode 100644 test/data/no-tag.emitter-error create mode 100644 test/data/null.data create mode 100644 test/data/null.detect create mode 100644 test/data/odd-utf16.stream-error create mode 100644 test/data/recursive.former-dumper-error create mode 100644 test/data/remove-possible-simple-key-bug.loader-error create mode 100644 test/data/resolver.data create mode 100644 test/data/resolver.path create mode 100644 test/data/run-parser-crash-bug.data create mode 100644 test/data/scalars.events create mode 100644 test/data/scan-document-end-bug.canonical create mode 100644 test/data/scan-document-end-bug.data create mode 100644 test/data/scan-line-break-bug.canonical create mode 100644 test/data/scan-line-break-bug.data create mode 100644 test/data/sequences.events create mode 100644 test/data/serializer-is-already-opened.dumper-error create mode 100644 test/data/serializer-is-closed-1.dumper-error create mode 100644 test/data/serializer-is-closed-2.dumper-error create mode 100644 test/data/serializer-is-not-opened-1.dumper-error create mode 100644 test/data/serializer-is-not-opened-2.dumper-error create mode 100644 test/data/single-dot-is-not-float-bug.code create mode 100644 test/data/single-dot-is-not-float-bug.data create mode 100644 test/data/sloppy-indentation.canonical create mode 100644 test/data/sloppy-indentation.data create mode 100644 test/data/spec-02-01.data create mode 100644 test/data/spec-02-01.structure create mode 100644 test/data/spec-02-01.tokens create mode 100644 test/data/spec-02-02.data create mode 100644 test/data/spec-02-02.structure create mode 100644 test/data/spec-02-02.tokens create mode 100644 test/data/spec-02-03.data create mode 100644 test/data/spec-02-03.structure create mode 100644 test/data/spec-02-03.tokens create mode 100644 test/data/spec-02-04.data create mode 100644 test/data/spec-02-04.structure create mode 100644 test/data/spec-02-04.tokens create mode 100644 test/data/spec-02-05.data create mode 100644 test/data/spec-02-05.structure create mode 100644 test/data/spec-02-05.tokens create mode 100644 test/data/spec-02-06.data create mode 100644 test/data/spec-02-06.structure create mode 100644 test/data/spec-02-06.tokens create mode 100644 test/data/spec-02-07.data create mode 100644 test/data/spec-02-07.structure create mode 100644 test/data/spec-02-07.tokens create mode 100644 test/data/spec-02-08.data create mode 100644 test/data/spec-02-08.structure create mode 100644 test/data/spec-02-08.tokens create mode 100644 test/data/spec-02-09.data create mode 100644 test/data/spec-02-09.structure create mode 100644 test/data/spec-02-09.tokens create mode 100644 test/data/spec-02-10.data create mode 100644 test/data/spec-02-10.structure create mode 100644 test/data/spec-02-10.tokens create mode 100644 test/data/spec-02-11.data create mode 100644 test/data/spec-02-11.structure create mode 100644 test/data/spec-02-11.tokens create mode 100644 test/data/spec-02-12.data create mode 100644 test/data/spec-02-12.structure create mode 100644 test/data/spec-02-12.tokens create mode 100644 test/data/spec-02-13.data create mode 100644 test/data/spec-02-13.structure create mode 100644 test/data/spec-02-13.tokens create mode 100644 test/data/spec-02-14.data create mode 100644 test/data/spec-02-14.structure create mode 100644 test/data/spec-02-14.tokens create mode 100644 test/data/spec-02-15.data create mode 100644 test/data/spec-02-15.structure create mode 100644 test/data/spec-02-15.tokens create mode 100644 test/data/spec-02-16.data create mode 100644 test/data/spec-02-16.structure create mode 100644 test/data/spec-02-16.tokens create mode 100644 test/data/spec-02-17.data create mode 100644 test/data/spec-02-17.structure create mode 100644 test/data/spec-02-17.tokens create mode 100644 test/data/spec-02-18.data create mode 100644 test/data/spec-02-18.structure create mode 100644 test/data/spec-02-18.tokens create mode 100644 test/data/spec-02-19.data create mode 100644 test/data/spec-02-19.structure create mode 100644 test/data/spec-02-19.tokens create mode 100644 test/data/spec-02-20.data create mode 100644 test/data/spec-02-20.structure create mode 100644 test/data/spec-02-20.tokens create mode 100644 test/data/spec-02-21.data create mode 100644 test/data/spec-02-21.structure create mode 100644 test/data/spec-02-21.tokens create mode 100644 test/data/spec-02-22.data create mode 100644 test/data/spec-02-22.structure create mode 100644 test/data/spec-02-22.tokens create mode 100644 test/data/spec-02-23.data create mode 100644 test/data/spec-02-23.structure create mode 100644 test/data/spec-02-23.tokens create mode 100644 test/data/spec-02-24.data create mode 100644 test/data/spec-02-24.structure create mode 100644 test/data/spec-02-24.tokens create mode 100644 test/data/spec-02-25.data create mode 100644 test/data/spec-02-25.structure create mode 100644 test/data/spec-02-25.tokens create mode 100644 test/data/spec-02-26.data create mode 100644 test/data/spec-02-26.structure create mode 100644 test/data/spec-02-26.tokens create mode 100644 test/data/spec-02-27.data create mode 100644 test/data/spec-02-27.structure create mode 100644 test/data/spec-02-27.tokens create mode 100644 test/data/spec-02-28.data create mode 100644 test/data/spec-02-28.structure create mode 100644 test/data/spec-02-28.tokens create mode 100644 test/data/spec-05-01-utf16be.data create mode 100644 test/data/spec-05-01-utf16be.empty create mode 100644 test/data/spec-05-01-utf16le.data create mode 100644 test/data/spec-05-01-utf16le.empty create mode 100644 test/data/spec-05-01-utf8.data create mode 100644 test/data/spec-05-01-utf8.empty create mode 100644 test/data/spec-05-02-utf16be.data create mode 100644 test/data/spec-05-02-utf16be.error create mode 100644 test/data/spec-05-02-utf16le.data create mode 100644 test/data/spec-05-02-utf16le.error create mode 100644 test/data/spec-05-02-utf8.data create mode 100644 test/data/spec-05-02-utf8.error create mode 100644 test/data/spec-05-03.canonical create mode 100644 test/data/spec-05-03.data create mode 100644 test/data/spec-05-04.canonical create mode 100644 test/data/spec-05-04.data create mode 100644 test/data/spec-05-05.data create mode 100644 test/data/spec-05-05.empty create mode 100644 test/data/spec-05-06.canonical create mode 100644 test/data/spec-05-06.data create mode 100644 test/data/spec-05-06.test_loader_skip create mode 100644 test/data/spec-05-07.canonical create mode 100644 test/data/spec-05-07.data create mode 100644 test/data/spec-05-08.canonical create mode 100644 test/data/spec-05-08.data create mode 100644 test/data/spec-05-09.canonical create mode 100644 test/data/spec-05-09.data create mode 100644 test/data/spec-05-10.data create mode 100644 test/data/spec-05-10.error create mode 100644 test/data/spec-05-11.canonical create mode 100644 test/data/spec-05-11.data create mode 100644 test/data/spec-05-12.data create mode 100644 test/data/spec-05-12.error create mode 100644 test/data/spec-05-13.canonical create mode 100644 test/data/spec-05-13.data create mode 100644 test/data/spec-05-14.canonical create mode 100644 test/data/spec-05-14.data create mode 100644 test/data/spec-05-15.data create mode 100644 test/data/spec-05-15.error create mode 100644 test/data/spec-06-01.canonical create mode 100644 test/data/spec-06-01.data create mode 100644 test/data/spec-06-02.data create mode 100644 test/data/spec-06-02.empty create mode 100644 test/data/spec-06-03.canonical create mode 100644 test/data/spec-06-03.data create mode 100644 test/data/spec-06-04.canonical create mode 100644 test/data/spec-06-04.data create mode 100644 test/data/spec-06-05.canonical create mode 100644 test/data/spec-06-05.data create mode 100644 test/data/spec-06-06.canonical create mode 100644 test/data/spec-06-06.data create mode 100644 test/data/spec-06-07.canonical create mode 100644 test/data/spec-06-07.data create mode 100644 test/data/spec-06-08.canonical create mode 100644 test/data/spec-06-08.data create mode 100644 test/data/spec-07-01.canonical create mode 100644 test/data/spec-07-01.data create mode 100644 test/data/spec-07-01.skip-ext create mode 100644 test/data/spec-07-02.canonical create mode 100644 test/data/spec-07-02.data create mode 100644 test/data/spec-07-02.skip-ext create mode 100644 test/data/spec-07-03.data create mode 100644 test/data/spec-07-03.error create mode 100644 test/data/spec-07-04.canonical create mode 100644 test/data/spec-07-04.data create mode 100644 test/data/spec-07-05.data create mode 100644 test/data/spec-07-05.error create mode 100644 test/data/spec-07-06.canonical create mode 100644 test/data/spec-07-06.data create mode 100644 test/data/spec-07-06.test_loader_skip create mode 100644 test/data/spec-07-07a.canonical create mode 100644 test/data/spec-07-07a.data create mode 100644 test/data/spec-07-07a.test_loader_skip create mode 100644 test/data/spec-07-07b.canonical create mode 100644 test/data/spec-07-07b.data create mode 100644 test/data/spec-07-07b.test_loader_skip create mode 100644 test/data/spec-07-08.canonical create mode 100644 test/data/spec-07-08.data create mode 100644 test/data/spec-07-08.test_loader_skip create mode 100644 test/data/spec-07-09.canonical create mode 100644 test/data/spec-07-09.data create mode 100644 test/data/spec-07-10.canonical create mode 100644 test/data/spec-07-10.data create mode 100644 test/data/spec-07-11.data create mode 100644 test/data/spec-07-11.empty create mode 100644 test/data/spec-07-12a.canonical create mode 100644 test/data/spec-07-12a.data create mode 100644 test/data/spec-07-12b.canonical create mode 100644 test/data/spec-07-12b.data create mode 100644 test/data/spec-07-13.canonical create mode 100644 test/data/spec-07-13.data create mode 100644 test/data/spec-07-13.test_loader_skip create mode 100644 test/data/spec-08-01.canonical create mode 100644 test/data/spec-08-01.data create mode 100644 test/data/spec-08-02.canonical create mode 100644 test/data/spec-08-02.data create mode 100644 test/data/spec-08-03.canonical create mode 100644 test/data/spec-08-03.data create mode 100644 test/data/spec-08-03.test_loader_skip create mode 100644 test/data/spec-08-04.data create mode 100644 test/data/spec-08-04.error create mode 100644 test/data/spec-08-05.canonical create mode 100644 test/data/spec-08-05.data create mode 100644 test/data/spec-08-05.test_loader_skip create mode 100644 test/data/spec-08-06.data create mode 100644 test/data/spec-08-06.error create mode 100644 test/data/spec-08-07.canonical create mode 100644 test/data/spec-08-07.data create mode 100644 test/data/spec-08-08.canonical create mode 100644 test/data/spec-08-08.data create mode 100644 test/data/spec-08-09.canonical create mode 100644 test/data/spec-08-09.data create mode 100644 test/data/spec-08-10.canonical create mode 100644 test/data/spec-08-10.data create mode 100644 test/data/spec-08-11.canonical create mode 100644 test/data/spec-08-11.data create mode 100644 test/data/spec-08-12.canonical create mode 100644 test/data/spec-08-12.data create mode 100644 test/data/spec-08-13.canonical create mode 100644 test/data/spec-08-13.data create mode 100644 test/data/spec-08-13.skip-ext create mode 100644 test/data/spec-08-14.canonical create mode 100644 test/data/spec-08-14.data create mode 100644 test/data/spec-08-15.canonical create mode 100644 test/data/spec-08-15.data create mode 100644 test/data/spec-09-01.canonical create mode 100644 test/data/spec-09-01.data create mode 100644 test/data/spec-09-02.canonical create mode 100644 test/data/spec-09-02.data create mode 100644 test/data/spec-09-03.canonical create mode 100644 test/data/spec-09-03.data create mode 100644 test/data/spec-09-04.canonical create mode 100644 test/data/spec-09-04.data create mode 100644 test/data/spec-09-05.canonical create mode 100644 test/data/spec-09-05.data create mode 100644 test/data/spec-09-06.canonical create mode 100644 test/data/spec-09-06.data create mode 100644 test/data/spec-09-07.canonical create mode 100644 test/data/spec-09-07.data create mode 100644 test/data/spec-09-08.canonical create mode 100644 test/data/spec-09-08.data create mode 100644 test/data/spec-09-09.canonical create mode 100644 test/data/spec-09-09.data create mode 100644 test/data/spec-09-10.canonical create mode 100644 test/data/spec-09-10.data create mode 100644 test/data/spec-09-11.canonical create mode 100644 test/data/spec-09-11.data create mode 100644 test/data/spec-09-12.canonical create mode 100644 test/data/spec-09-12.data create mode 100644 test/data/spec-09-13.canonical create mode 100644 test/data/spec-09-13.data create mode 100644 test/data/spec-09-14.data create mode 100644 test/data/spec-09-14.error create mode 100644 test/data/spec-09-15.canonical create mode 100644 test/data/spec-09-15.data create mode 100644 test/data/spec-09-16.canonical create mode 100644 test/data/spec-09-16.data create mode 100644 test/data/spec-09-17.canonical create mode 100644 test/data/spec-09-17.data create mode 100644 test/data/spec-09-18.canonical create mode 100644 test/data/spec-09-18.data create mode 100644 test/data/spec-09-19.canonical create mode 100644 test/data/spec-09-19.data create mode 100644 test/data/spec-09-20.canonical create mode 100644 test/data/spec-09-20.data create mode 100644 test/data/spec-09-20.skip-ext create mode 100644 test/data/spec-09-21.data create mode 100644 test/data/spec-09-21.error create mode 100644 test/data/spec-09-22.canonical create mode 100644 test/data/spec-09-22.data create mode 100644 test/data/spec-09-23.canonical create mode 100644 test/data/spec-09-23.data create mode 100644 test/data/spec-09-24.canonical create mode 100644 test/data/spec-09-24.data create mode 100644 test/data/spec-09-25.canonical create mode 100644 test/data/spec-09-25.data create mode 100644 test/data/spec-09-26.canonical create mode 100644 test/data/spec-09-26.data create mode 100644 test/data/spec-09-27.canonical create mode 100644 test/data/spec-09-27.data create mode 100644 test/data/spec-09-28.canonical create mode 100644 test/data/spec-09-28.data create mode 100644 test/data/spec-09-29.canonical create mode 100644 test/data/spec-09-29.data create mode 100644 test/data/spec-09-30.canonical create mode 100644 test/data/spec-09-30.data create mode 100644 test/data/spec-09-31.canonical create mode 100644 test/data/spec-09-31.data create mode 100644 test/data/spec-09-32.canonical create mode 100644 test/data/spec-09-32.data create mode 100644 test/data/spec-09-33.canonical create mode 100644 test/data/spec-09-33.data create mode 100644 test/data/spec-10-01.canonical create mode 100644 test/data/spec-10-01.data create mode 100644 test/data/spec-10-02.canonical create mode 100644 test/data/spec-10-02.data create mode 100644 test/data/spec-10-03.canonical create mode 100644 test/data/spec-10-03.data create mode 100644 test/data/spec-10-04.canonical create mode 100644 test/data/spec-10-04.data create mode 100644 test/data/spec-10-05.canonical create mode 100644 test/data/spec-10-05.data create mode 100644 test/data/spec-10-06.canonical create mode 100644 test/data/spec-10-06.data create mode 100644 test/data/spec-10-07.canonical create mode 100644 test/data/spec-10-07.data create mode 100644 test/data/spec-10-08.data create mode 100644 test/data/spec-10-08.error create mode 100644 test/data/spec-10-09.canonical create mode 100644 test/data/spec-10-09.data create mode 100644 test/data/spec-10-10.canonical create mode 100644 test/data/spec-10-10.data create mode 100644 test/data/spec-10-11.canonical create mode 100644 test/data/spec-10-11.data create mode 100644 test/data/spec-10-12.canonical create mode 100644 test/data/spec-10-12.data create mode 100644 test/data/spec-10-13.canonical create mode 100644 test/data/spec-10-13.data create mode 100644 test/data/spec-10-14.canonical create mode 100644 test/data/spec-10-14.data create mode 100644 test/data/spec-10-15.canonical create mode 100644 test/data/spec-10-15.data create mode 100644 test/data/str.data create mode 100644 test/data/str.detect create mode 100644 test/data/tags.events create mode 100644 test/data/test_mark.marks create mode 100644 test/data/timestamp-bugs.code create mode 100644 test/data/timestamp-bugs.data create mode 100644 test/data/timestamp.data create mode 100644 test/data/timestamp.detect create mode 100644 test/data/unclosed-bracket.loader-error create mode 100644 test/data/unclosed-quoted-scalar.loader-error create mode 100644 test/data/undefined-anchor.loader-error create mode 100644 test/data/undefined-constructor.loader-error create mode 100644 test/data/undefined-tag-handle.loader-error create mode 100644 test/data/unknown.dumper-error create mode 100644 test/data/unsupported-version.emitter-error create mode 100644 test/data/utf16be.code create mode 100644 test/data/utf16be.data create mode 100644 test/data/utf16le.code create mode 100644 test/data/utf16le.data create mode 100644 test/data/utf8-implicit.code create mode 100644 test/data/utf8-implicit.data create mode 100644 test/data/utf8.code create mode 100644 test/data/utf8.data create mode 100644 test/data/value.data create mode 100644 test/data/value.detect create mode 100644 test/data/yaml.data create mode 100644 test/data/yaml.detect create mode 100644 test/src/common.d create mode 100644 test/src/compare.d create mode 100644 test/src/constructor.d create mode 100644 test/src/errors.d create mode 100644 test/src/inputoutput.d create mode 100644 test/src/reader.d create mode 100644 test/src/tokens.d create mode 100644 unittest.d create mode 100644 yaml.d diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8039ea0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Backups # +########### +*~ +*.sw* + +# Compiled source # +################### +unittest +cdc +main +*.a +*.lib +*.o +*.exe + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.tar +*.tar.xz +*.tar.gz +*.zip + +# OS generated files # +###################### +.DS_Store? +ehthumbs.db +Icon? +Thumbs.db +.directory diff --git a/LICENSE_1_0.txt b/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.html b/README.html new file mode 100644 index 0000000..2b8f531 --- /dev/null +++ b/README.html @@ -0,0 +1,450 @@ + + + + + + +D:YAML 0.1 + + + +
+

D:YAML 0.1

+ +
+

Introduction

+

D:YAML is an open source YAML parser library for the D programming language. +It is (almost) compliant to the +YAML 1.1 specification. Much of D:YAML code is based on +PyYAML created by Kirill Simonov. D:YAML has no +external dependencies, all it needs is a D compiler and Phobos (standard +library). It is written in D2 and there are no plans for D1 or Tango support.

+

At the moment, D:YAML can only read, not write YAML files. This will change in +the following releases. D:YAML is designed to be as easy to use as possible while +supporting the full feature set of YAML. To start using it in your project, +you can see the Getting Started +tutorial.

+

D:YAML is still a work in progress. Its API is still not stable and there might +be compatibility breaking changes. For instance, currently some D:YAML API +functions depend on the std.stream module in Phobos. This module is expected +to be rewritten in future and D:YAML will change accordingly.

+
+
+

Features

+
    +
  • Easy to use, high-level API and detailed debugging messages.
  • +
  • Detailed API documentation and tutorials.
  • +
  • No external dependencies.
  • +
  • Supports all YAML 1.1 constructs. All examples from the YAML 1.1 specification +are parsed correctly.
  • +
  • Read from YAML files as well as from memory or user defined streams.
  • +
  • UTF-8, UTF-16 and UTF-32 encodings are supported, both big and little endian +(plain ASCII also works as it is a subset of UTF-8).
  • +
  • Support for both block (Python-like, based on indentation) and flow +(JSON-like, based on bracing) constructs.
  • +
  • Support for YAML anchors and aliases.
  • +
  • Support for default values in mappings.
  • +
  • Support for custom tags (data types), and implicit tag resolution for custom +tags.
  • +
  • All tags (data types) described at http://yaml.org/type/ are supported, with +the exception of tag:yaml.org,2002:yaml, which is used to represent YAML +code in YAML.
  • +
  • Cannot write YAML at the moment. This will change in the future.
  • +
  • There is no support for recursive data structures (supported by some YAML +parsers). There are no plans to implement this at the moment.
  • +
+
+
+

Directory structure

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + +
DirectoryContents
./This README file, utility scripts, D:YAML sources outside any packages.
./docDocumentation.
./docsrcDocumentation sources.
./dyamlD:YAML source code.
./examples/Example D:YAML code.
./testUnittest code and inputs.
+
+
+

Installing and tutorial

+

See the Getting started tutorial +and other tutorials that can be found in the doc/html/tutorials/ directory.

+
+
+

License

+

D:YAML is released under the terms of the +Boost Software License 1.0. +This license allows you to use the source code in your own projects, open source +or proprietary, and to modify it to suit your needs. However, in source +distributions, you have to preserve the license headers in the source code and +the accompanying license file.

+

Full text of the license can be found in file LICENSE_1_0.txt and is also +displayed here:

+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+
+
+

Credits

+

D:YAML was created by Ferdinand Majerech aka Kiith-Sa kiithsacmp[AT]gmail.com .

+

Parts of code based on PyYAML created by Kirill Simonov.

+

D:YAML uses a modified version of the +CDC build script.

+

D:YAML was created using Vim and DMD on Debian and Ubuntu Linux as a YAML parsing +library for the D programming language.

+
+
+ + + diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..3ac0e7b --- /dev/null +++ b/README.rst @@ -0,0 +1,129 @@ +========== +D:YAML 0.1 +========== + +------------ +Introduction +------------ + +D:YAML is an open source YAML parser library for the D programming language. +It is (`almost <./doc/html/articles/spec_differences.html>`_) compliant to the +YAML 1.1 specification. Much of D:YAML code is based on +`PyYAML `_ created by Kirill Simonov. D:YAML has no +external dependencies, all it needs is a D compiler and Phobos (standard +library). It is written in D2 and there are no plans for D1 or Tango support. + +At the moment, D:YAML can only read, not write YAML files. This will change in +the following releases. D:YAML is designed to be as easy to use as possible while +supporting the full feature set of YAML. To start using it in your project, +you can see the `Getting Started <./doc/html/tutorials/getting_started.html>`_ +tutorial. + +D:YAML is still a work in progress. Its API is still not stable and there might +be compatibility breaking changes. For instance, currently some D:YAML API +functions depend on the ``std.stream`` module in Phobos. This module is expected +to be rewritten in future and D:YAML will change accordingly. + + +-------- +Features +-------- + +* Easy to use, high-level API and detailed debugging messages. +* Detailed API documentation and tutorials. +* No external dependencies. +* Supports all YAML 1.1 constructs. All examples from the YAML 1.1 specification + are parsed correctly. +* Read from YAML files as well as from memory or user defined streams. +* UTF-8, UTF-16 and UTF-32 encodings are supported, both big and little endian + (plain ASCII also works as it is a subset of UTF-8). +* Support for both block (Python-like, based on indentation) and flow + (JSON-like, based on bracing) constructs. +* Support for YAML anchors and aliases. +* Support for default values in mappings. +* Support for custom tags (data types), and implicit tag resolution for custom + tags. +* All tags (data types) described at http://yaml.org/type/ are supported, with + the exception of ``tag:yaml.org,2002:yaml``, which is used to represent YAML + code in YAML. +* Cannot write YAML at the moment. This will change in the future. +* There is no support for recursive data structures. + There are no plans to implement this at the moment. + + +------------------- +Directory structure +------------------- + +=============== ====================================================================== +Directory Contents +=============== ====================================================================== +``./`` This README file, utility scripts, D:YAML sources outside any packages. +``./doc`` Documentation. +``./docsrc`` Documentation sources. +``./dyaml`` D:YAML source code. +``./examples/`` Example D:YAML code. +``./test`` Unittest code and inputs. +=============== ====================================================================== + + +----------------------- +Installing and tutorial +----------------------- + +See the `Getting started <./doc/html/tutorials/getting_started.html>`_ tutorial +and other tutorials that can be found in the ``doc/html/tutorials/`` directory. + + +------- +License +------- + +D:YAML is released under the terms of the +`Boost Software License 1.0 `_. +This license allows you to use the source code in your own projects, open source +or proprietary, and to modify it to suit your needs. However, in source +distributions, you have to preserve the license headers in the source code and +the accompanying license file. + +Full text of the license can be found in file ``LICENSE_1_0.txt`` and is also +displayed here:: + + Boost Software License - Version 1.0 - August 17th, 2003 + + Permission is hereby granted, free of charge, to any person or organization + obtaining a copy of the software and accompanying documentation covered by + this license (the "Software") to use, reproduce, display, distribute, + execute, and transmit the Software, and to prepare derivative works of the + Software, and to permit third-parties to whom the Software is furnished to + do so, all subject to the following: + + The copyright notices in the Software and this entire statement, including + the above license grant, this restriction and the following disclaimer, + must be included in all copies of the Software, in whole or in part, and + all derivative works of the Software, unless such copies or derivative + works are solely in the form of machine-executable object code generated by + a source language processor. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + +------- +Credits +------- + +D:YAML was created by Ferdinand Majerech aka Kiith-Sa kiithsacmp[AT]gmail.com . + +Parts of code based on `PyYAML `_ created by Kirill Simonov. + +D:YAML uses a modified version of the +`CDC build script `_. + +D:YAML was created using Vim and DMD on Debian and Ubuntu Linux as a YAML parsing +library for the `D programming language `_. diff --git a/autoddoc.cfg b/autoddoc.cfg new file mode 100644 index 0000000..080db8e --- /dev/null +++ b/autoddoc.cfg @@ -0,0 +1,37 @@ +[PROJECT] +# Name of the project. E.g. "AutoDDoc Documentation Generator". +name = D:YAML +# Project version string. E.g. "0.1 alpha". +version = 0.1 +# Copyright without the "Copyright (c)" part. E.g. "Joe Coder 2001-2042". +copyright = Ferdinand Majerech 2011. Based on PyYAML by Kirill Simonov. +# File name of the logo of the project, if any. +# Should be a PNG image. E.g. "logo.png". +logo = docsrc/logo128.png + +[OUTPUT] +# Directory to write the documentation to. +# If none specified, "autoddoc" is used. +directory = doc/html/api +# CSS style to use. If empty, default will be generated. +# You can create a custom style by generating default style +# with "autoddoc.py -s" and modyfing it. +style = +# Documentation index file to use. If empty, default will be generated. +# You can create a custom index by generating default index +# with "autoddoc.py -i" and modyfing it. +index = docsrc/autoddoc_index.dd +# Any extra links to add to the sidebar of the documentation. +# Should be in the format "LINK DESCRIPTION", separated by commas. +# E.g; To add links to Google and the D language site, you would use: +# "http://www.google.com Google, http://d-p-l.org DLang" +links = ../index.html Documentation home +# Source files or patterns to ignore. Supports regexp syntax. +# E.g; To ignore main.d and all source files in the test/ directory, +# you would use: "main.d test/*" +ignore = test/*, examples/*, docsrc/*, autoddoc/*, yaml.d, unittest.d, cdc.d, dyaml/composer.d, dyaml/event.d, dyaml/parser.d, dyaml/reader.d, dyaml/scanner.d, dyaml/token.d, dyaml/util.d + +[DDOC] +# Command to use to generate the documentation. +# Can be modified e.g. to use GDC or LDC. +ddoc_command = dmd -d -c -o- diff --git a/autoddoc.py b/autoddoc.py new file mode 100755 index 0000000..fcc7d0b --- /dev/null +++ b/autoddoc.py @@ -0,0 +1,657 @@ +#!/usr/bin/python3 + +# License: Boost 1.0 +# +# Copyright (c) 2011 Ferdinand Majerech +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +import argparse +import configparser +import os +import os.path +import re +import shutil +import subprocess + + +template_macros =\ +("PBR =
$0
\n" + "BR =
\n" + "DDOC_DITTO = $(BR)$0\n" + "DDOC_SUMMARY = $(P $0)\n" + "DDOC_DESCRIPTION = $(P $0)\n" + "DDOC_AUTHORS = $(B Authors:)$(PBR $0)\n" + "DDOC_BUGS = $(RED BUGS:)$(PBR $0)\n" + "DDOC_COPYRIGHT = $(B Copyright:)$(PBR $0)\n" + "DDOC_DATE = $(B Date:)$(PBR $0)\n" + "DDOC_DEPRECATED = $(RED Deprecated:)$(PBR $0)\n" + "DDOC_EXAMPLES = $(B Examples:)$(PBR $0)\n" + "DDOC_HISTORY = $(B History:)$(PBR $0)\n" + "DDOC_LICENSE = $(B License:)$(PBR $0)\n" + "DDOC_RETURNS = $(B Returns:)$(PBR $0)\n" + "DDOC_SEE_ALSO = $(B See Also:)$(PBR $0)\n" + "DDOC_STANDARDS = $(B Standards:)$(PBR $0)\n" + "DDOC_THROWS = $(B Throws:)$(PBR $0)\n" + "DDOC_VERSION = $(B Version:)$(PBR $0)\n" + "DDOC_SECTION_H = $(B $0)$(BR)\n" + "DDOC_SECTION = $(P $0)\n" + "DDOC_PARAMS = $(B Parameters:)$(PBR $0
)\n" + "DDOC_PARAM = $(B $0)\n" + "DDOC_BLANKLINE = $(BR)\n" + + "RED = $0\n" + "GREEN = $0\n" + "BLUE = $0\n" + "YELLOW = $0\n" + "BLACK = $0\n" + "WHITE = $0\n" + + "D_COMMENT = $0\n" + "D_STRING = $0\n" + "D_KEYWORD = $0\n" + "D_PSYMBOL = $0\n" + "D_PARAM = $0\n" + + "RPAREN = )\n" + "LPAREN = (\n" + "LESS = <\n" + "GREATER = >\n" + "D = $0\n" + "D = $0\n" + + "DDOC_PSYMBOL = $0\n" + "DDOC_DECL =
$0
\n" + "LREF = $(D $1)\n" + "XREF = $0\n" + + "TABLE = $2
$1
\n" + "TD = $0\n" + "SUB = $0\n") + +template_header =\ +("\n\n" + "\n" + "\n" + "$(TITLE) - $(PROJECT_NAME) $(PROJECT_VERSION) API documentation\n" + "\n" + "\n\n") + +template_footer =\ +("\n
\n" + "$(COPYRIGHT) |\n" + "Page generated by Autodoc and $(LINK2 http://www.digitalmars.com/d/2.0/ddoc.html, Ddoc).\n" + "
\n\n") + +default_css =\ +("body\n" + "{\n" + " margin: 0;\n" + " padding: 0;\n" + " border: 0;\n" + " color: black;\n" + " background-color: #1f252b;\n" + " font-size: 100%;\n" + " font-family: Verdana, \"Deja Vu\", \"Bitstream Vera Sans\", sans-serif;\n" + "}\n" + "\n" + "h1, h2, h3, h4, h5, h6\n" + "{\n" + " font-family: Georgia, \"Times New Roman\", Times, serif;\n" + " font-weight: normal;\n" + " color: #633;\n" + " line-height: normal;\n" + " text-align: left;\n" + "}\n" + "\n" + "h1\n" + "{\n" + " margin-top: 0;\n" + " font-size: 2.5em;\n" + "}\n" + "\n" + "h2{font-size: 1.7em;}\n" + "\n" + "h3{font-size: 1.35em;}\n" + "\n" + "h4\n" + "{\n" + " font-size: 1.15em;\n" + " font-style: italic;\n" + " margin-bottom: 0;\n" + "}\n" + "\n" + "pre\n" + "{\n" + " background: #eef;\n" + " padding: 1ex;\n" + " margin: 1em 0 1em 3em;\n" + " font-family: monospace;\n" + " font-size: 1.2em;\n" + " line-height: normal;\n" + " border: 1px solid #ccc;\n" + " width: auto;\n" + "}\n" + "\n" + "dd\n" + "{\n" + " padding: 1ex;\n" + " margin-left: 3em;\n" + " margin-bottom: 1em;\n" + "}\n" + "\n" + "td{text-align: justify;}\n" + "\n" + "hr{margin: 2em 0;}\n" + "\n" + "a{color: #006;}\n" + "\n" + "a:visited{color: #606;}\n" + "\n" + "/* These are different kinds of
 sections */\n"
+ ".console /* command line console */\n"
+ "{\n"
+ "    background-color: #f7f7f7;\n"
+ "    color: #181818;\n"
+ "}\n"
+ "\n"
+ ".moddeffile /* module definition file */\n"
+ "{\n"
+ "    background-color: #efeffe;\n"
+ "    color: #010199;\n"
+ "}\n"
+ "\n"
+ ".d_code /* D code */\n"
+ "{\n"
+ "    background-color: #fcfcfc;\n"
+ "    color: #000066;\n"
+ "}\n"
+ "\n"
+ ".d_code2 /* D code */\n"
+ "{\n"
+ "    background-color: #fcfcfc;\n"
+ "    color: #000066;\n"
+ "}\n"
+ "\n"
+ "td .d_code2\n"
+ "{\n"
+ "    min-width: 20em;\n"
+ "    margin: 1em 0em;\n"
+ "}\n"
+ "\n"
+ ".d_inlinecode\n"
+ "{\n"
+ "    font-family: monospace;\n"
+ "    font-weight: bold;\n"
+ "}\n"
+ "\n"
+ "/* Elements of D source code text */\n"
+ ".d_comment{color: green;}\n"
+ ".d_string {color: red;}\n"
+ ".d_keyword{color: blue;}\n"
+ ".d_psymbol{text-decoration: underline;}\n"
+ ".d_param  {font-style: italic;}\n"
+ "\n"
+ "/* Focal symbol that is being documented */\n"
+ ".ddoc_psymbol{color: #336600;}\n"
+ "\n"
+ "div#top{max-width: 85em;}\n"
+ "\n"
+ "div#header{padding: 0.2em 1em 0.2em 1em;}\n"
+ "div.pbr\n"
+ "{\n"
+ "    margin: 4px 0px 8px 10px"
+ "}\n"
+ "\n"
+ "img#logo{vertical-align: bottom;}\n"
+ "\n"
+ "#main-heading\n"
+ "{\n"
+ "    margin-left: 1em;\n"
+ "    color: white;\n"
+ "    font-size: 1.4em;\n"
+ "    font-family: Arial, Verdana, sans-serif;\n"
+ "    font-variant: small-caps;\n"
+ "    text-decoration: none;\n"
+ "}\n"
+ "\n"
+ "div#navigation\n"
+ "{\n"
+ "    font-size: 0.875em;\n"
+ "    float: left;\n"
+ "    width: 12.0em;\n"
+ "    padding: 0 1.5em;\n"
+ "}\n"
+ "\n"
+ "div.navblock\n"
+ "{\n"
+ "    margin-top: 0;\n"
+ "    margin-bottom: 1em;\n"
+ "}\n"
+ "\n"
+ "div#navigation .navblock h2\n"
+ "{\n"
+ "    font-family: Verdana, \"Deja Vu\", \"Bitstream Vera Sans\", sans-serif;\n"
+ "    font-size: 1.35em;\n"
+ "    color: #ccc;\n"
+ "    margin: 0;\n"
+ "}\n"
+ "\n"
+ "div#navigation .navblock ul\n"
+ "{\n"
+ "    list-style-type: none;\n"
+ "    margin: 0;\n"
+ "    padding: 0;\n"
+ "}\n"
+ "\n"
+ "div#navigation .navblock li\n"
+ "{\n"
+ "    margin: 0 0 0 0.8em;\n"
+ "    padding: 0;\n"
+ "}\n"
+ "\n"
+ "#navigation .navblock a\n"
+ "{\n"
+ "    display: block;\n"
+ "    color: #ddd;\n"
+ "    text-decoration: none;\n"
+ "    padding: 0.1em 0;\n"
+ "    border-bottom: 1px dashed #444;\n"
+ "}\n"
+ "\n"
+ "#navigation .navblock a:hover{color: white;}\n"
+ "\n"
+ "#navigation .navblock a.active\n"
+ "{\n"
+ "    color: white;\n"
+ "    border-color: white;\n"
+ "}\n"
+ "\n"
+ "div#content\n"
+ "{\n"
+ "    min-height: 440px;\n"
+ "    margin-left: 15em;\n"
+ "    margin-right: 1.6em;\n"
+ "    padding: 1.6em;\n"
+ "    padding-top: 1.3em;\n"
+ "    border: 0.6em solid #cccccc;\n"
+ "    background-color: #f6f6f6;\n"
+ "    font-size: 0.875em;\n"
+ "    line-height: 1.4em;\n"
+ "}\n"
+ "\n"
+ "div#content li{padding-bottom: .7ex;}\n"
+ "\n"
+ "div#copyright\n"
+ "{\n"
+ "    padding: 1em 2em;\n"
+ "    background-color: #303333;\n"
+ "    color: #ccc;\n"
+ "    font-size: 0.75em;\n"
+ "    text-align: center;\n"
+ "}\n"
+ "\n"
+ "div#copyright a{color: #ccc;}\n"
+ "\n"
+ ".d_inlinecode\n"
+ "{\n"
+ "    font-family: Consolas, \"Bitstream Vera Sans Mono\", \"Andale Mono\", \"DejaVu Sans Mono\", \"Lucida Console\", monospace;\n"
+ "}\n"
+ "\n"
+ ".d_decl\n"
+ "{\n"
+ "    font-weight: bold;\n"
+ "    background-color: #E4E9EF;\n"
+ "    border-bottom: solid 2px #336600;\n"
+ "    padding: 2px 0px 2px 2px;\n"
+ "}\n")
+
+default_cfg =\
+ ("[PROJECT]\n"
+  "# Name of the project. E.g. \"AutoDDoc Documentation Generator\".\n"
+  "name =\n"
+  "# Project version string. E.g. \"0.1 alpha\".\n"
+  "version =\n"
+  "# Copyright without the \"Copyright (c)\" part. E.g. \"Joe Coder 2001-2042\".\n"
+  "copyright =\n"
+  "# File name of the logo of the project, if any. \n"
+  "# Should be a PNG image. E.g. \"logo.png\".\n"
+  "logo =\n"
+  "\n"
+  "[OUTPUT]\n"
+  "# Directory to write the documentation to.\n"
+  "# If none specified, \"autoddoc\" is used.\n"
+  "directory = autoddoc\n"
+  "# CSS style to use. If empty, default will be generated.\n"
+  "# You can create a custom style by generating default style\n"
+  "# with \"autoddoc.py -s\" and modyfing it.\n"
+  "style =\n"
+  "# Documentation index file to use. If empty, default will be generated.\n"
+  "# You can create a custom index by generating default index\n"
+  "# with \"autoddoc.py -i\" and modyfing it.\n"
+  "index =\n"
+  "# Any extra links to add to the sidebar of the documentation.\n"
+  "# Should be in the format \"LINK DESCRIPTION\", separated by commas.\n"
+  "# E.g; To add links to Google and the D language site, you would use:\n"
+  "# \"http://www.google.com Google, http://d-p-l.org DLang\"\n"
+  "links =\n"
+  "# Source files or patterns to ignore. Supports regexp syntax.\n"
+  "# E.g; To ignore main.d and all source files in the test/ directory,\n"
+  "# you would use: \"main.d, test/*\"\n"
+  "ignore =\n"
+  "\n"
+  "[DDOC]\n"
+  "# Command to use to generate the documentation. \n"
+  "# Can be modified e.g. to use GDC or LDC.\n"
+  "ddoc_command = dmd -d -c -o-\n")
+
+class ProjectInfo:
+    """Holds project-specific data"""
+    def __init__(self, name, version, copyright, logo_file):
+        self.name      = name
+        self.version   = version
+        self.copyright = copyright
+        self.logo_file = logo_file
+
+def run_cmd(cmd):
+    """Run a command and return its resolt"""
+    print (cmd)
+    return subprocess.call(cmd, shell=True)
+
+def module_name(source_name):
+    """Get module name of a source file (currently this only depends on its path)"""
+    return os.path.splitext(source_name)[0].replace("/", ".")
+
+def scan_sources(source_dir, ignore):
+    """Get a list of relative paths all source files in specified directory."""
+    sources = []
+    for root, dirs, files in os.walk(source_dir):
+        for filename in files:
+            def add_source():
+                if os.path.splitext(filename)[1] not in [".d", ".dd", ".ddoc"]:
+                    return
+                source = os.path.join(root, filename)
+                if source.startswith("./"):
+                    source = source[2:]
+                for exp in ignore:
+                    try:
+                        if(re.compile(exp.strip()).match(source)):
+                            return
+                    except re.error as error:
+                        print("Ignore expression is not a valid regexp: ", exp,
+                              "error:", error)
+                        raise error
+                sources.append(source);
+            add_source()
+    return sorted(sources, key=str.lower)
+
+def add_template(template_path, sources, links, project):
+    """Generate DDoc template file at template_path,
+    connecting to sources and links, using specified project data."""
+    with open(template_path, mode="w", encoding="utf-8") as a_file:
+        a_file.write(template_macros)
+
+        #Project info.
+        a_file.write("PROJECT_NAME= " + project.name + "\n")
+        a_file.write("PROJECT_VERSION= " + project.version + "\n")
+        a_file.write("COPYRIGHT= ")
+        if project.copyright is not None and project.copyright != "":
+            a_file.write("Copyright © " + project.copyright)
+        a_file.write("\n")
+         
+
+        #DDOC macro - this is the template itself, using other macros.
+        a_file.write("DDOC = \n")
+        a_file.write(template_header)
+        a_file.write("")
+
+        #Heading and the logo, if any.
+        top = ("\n\n")
+        a_file.write(top)
+
+        #Menu - user specified links.
+        navigation = ("
\n" + "
\n" + "
\n" + "$(UL\n") + for link, name in links: + navigation += "$(LI $(LINK2 " + link + ", " + name + "))\n" + navigation += ")\n
\n
\n" + + #Menu -links to the modules. + navigation += "
\n$(UL\n" + navigation += "$(LI $(LINK2 index.html, Main page))\n" + for source in sources: + module = module_name(source) + link = "$(LI $(LINK2 " + module + ".html," + module + "))\n" + navigation += link + navigation += ")\n
\n
\n\n" + + a_file.write(navigation) + + #Main content. + content = "
\n

$(TITLE)

\n$(BODY)\n
\n" + a_file.write(content) + + a_file.write(template_footer) + a_file.write("\n\n") + +def add_logo(project, output_dir): + """Copy the logo, if any, to images/logo.png .""" + if(project.logo_file is None or project.logo_file == ""): + return + images_path = os.path.join(output_dir, "images") + os.makedirs(images_path, exist_ok=True) + shutil.copy(project.logo_file, os.path.join(images_path, "logo.png")) + +def generate_style(filename): + """Write default css to a file""" + with open(filename, mode="w", encoding="utf-8") as a_file: + a_file.write(default_css) + +def add_css(css, output_dir): + """Copy the CSS if specified, write default CSS otherwise.""" + css_path = os.path.join(output_dir, "css") + os.makedirs(css_path, exist_ok=True) + css_path = os.path.join(css_path, "style.css") + if css is None or css == "": + generate_style(css_path) + return + shutil.copy(css, css_path) + +def generate_index(filename): + """Write default index to a file""" + with open(filename, mode="w", encoding="utf-8") as a_file: + a_file.write("Ddoc\n\n") + a_file.write("Macros:\n") + a_file.write(" TITLE=$(PROJECT_NAME) $(PROJECT_VERSION) API documentation\n\n") + +def add_index(index, output_dir): + """Copy the index if specified, write default index otherwise.""" + index_path = os.path.join(output_dir, "index.dd") + if index is None or index == "": + generate_index(index_path) + return + shutil.copy(index, index_path) + +def generate_ddoc(sources, output_dir, ddoc_template, ddoc_command): + """Generate documentation from sources, writing it to output_dir.""" + + #Generate index html with ddoc. + index_ddoc = os.path.join(output_dir, "index.dd") + index_html = os.path.join(output_dir, "index.html") + run_cmd(ddoc_command + " -Df" + index_html + " " + index_ddoc) + os.remove(index_ddoc) + + #Now generate html for the sources. + for source in sources: + out_path = os.path.join(output_dir, module_name(source)) + ".html" + run_cmd(ddoc_command + " -Df" + out_path + " " + source) + +def generate_config(filename): + """Generate default AutoDDoc config file.""" + with open(filename, mode="w", encoding="utf-8") as a_file: + a_file.write(default_cfg) + +def init_parser(): + """Initialize and return the command line parser.""" + autoddoc_description =\ + ("AutoDDoc 0.1\n" + "Documentation generator script for D using DDoc.\n" + "Copyright Ferdinand Majerech 2011.\n\n" + "AutoDDoc scans subdirectories of the current directory for D or DDoc\n" + "sources (.d, .dd or .ddoc) and generates documentation using settings\n" + "from a configuration file.\n" + "NOTE: AutoDDoc will only work if package/module hierarchy matches the\n" + "directory hierarchy, so e.g. module 'pkg.util' would be in file './pkg/util.d' .") + + autoddoc_epilog =\ + ("\nTutorial:\n" + "1. Copy the script to your project directory and move into that directory.\n" + " Relative to this directory, module names must match their filenames,\n" + " so e.g. module 'pkg.util' would be in file './pkg/util.d' .\n" + "2. Generate AutoDDoc configuation file. To do this, type\n" + " './autoddoc.py -g'. This will generate file 'autoddoc.cfg' .\n" + "3. Edit the configuation file. Set project name, version, output\n" + " directory and other parameters.\n" + "4. Generate the documentation by typing './autoddoc.py' .\n") + + parser = argparse.ArgumentParser(description= autoddoc_description, + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog = autoddoc_epilog, add_help=True) + + parser.add_argument("config_file", nargs="?", default="autoddoc.cfg", + help="Configuration file to use to generate documentation. " + "Can not be used with any optional arguments. " + "If not specified, 'autoddoc.cfg' is assumed. " + "Examples: 'autoddoc.py config.cfg' " + "will generate documentation using file 'config.cfg' . " + "'autoddoc.py' will generate documentation " + "using file 'autoddoc.cfg' if it exists.", + metavar="config_file") + parser.add_argument("-g", "--gen-config", nargs="?", const="autoddoc.cfg", + help="Generate default AutoDDoc configuation file. " + "config_file is the filename to use. If not specified, " + "autoddoc.cfg is used.", + metavar="config_file") + parser.add_argument("-s", "--gen-style", nargs="?", const="autoddoc_style.css", + help="Generate default AutoDDoc style sheet. " + "css_file is the filename to use. If not specified, " + "autoddoc_style.css is used.", + metavar="css_file") + parser.add_argument("-i", "--gen-index", nargs="?", const="autoddoc_index.dd", + help="Generate default AutoDDoc documentation index. " + "index_file is the filename to use. If not specified, " + "autoddoc_index.dd is used.", + metavar="index_file") + + return parser + + +def main(): + parser = init_parser() + args = parser.parse_args() + + #Generate config/style/index if requested. + done = False; + try: + if args.gen_config is not None: + generate_config(args.gen_config) + done = True + if args.gen_style is not None: + generate_style(args.gen_style) + done = True + if args.gen_index is not None: + generate_index(args.gen_index) + done = True + except IOError as error: + print("\nERROR: Unable to generate:", error) + return + + if done or args.config_file is None: + return + + if not os.path.isfile(args.config_file): + print("\nERROR: Can't find configuration file", args.config_file, "\n") + parser.print_help() + return + + #Load documentation config. + config = configparser.ConfigParser() + try: + config.read(args.config_file) + + project = config["PROJECT"] + project = ProjectInfo(project["name"], + project["version"], + project["copyright"], + project["logo"]) + + output = config["OUTPUT"] + output_dir = output["directory"] + if output_dir == "": + output_dir = "autoddoc" + css = output["style"] + index = output["index"] + links = [] + if output["links"] != "": + for link in output["links"].split(","): + parts = link.split(" ", 1) + links.append((parts[0].strip(), parts[1].strip())) + ignore = output["ignore"].split(",") + if ignore == [""]: + ignore = [] + + ddoc_line = config["DDOC"]["ddoc_command"] + except configparser.Error as error: + print("Unable to parse configuration file", args.config_file, ":", error) + return + except IOError as error: + print("Unable to read configuration file", args.config_file, ":", error) + return + + #Do the actual generation work. + try: + #Find all .d, .dd, .ddoc files. + sources = scan_sources(".", ignore) + ddoc_template = os.path.join(output_dir, "AUTODDOC_TEMPLATE.ddoc") + os.makedirs(output_dir, exist_ok=True) + + add_template(ddoc_template, sources, links, project) + add_logo(project, output_dir) + add_css(css, output_dir) + add_index(index, output_dir) + + generate_ddoc(sources, output_dir, ddoc_template, ddoc_line + " " + ddoc_template); + os.remove(ddoc_template) + except Exception as error: + print("Error during documentation generation:", error) + + +if __name__ == '__main__': + main() diff --git a/cdc.d b/cdc.d new file mode 100755 index 0000000..6fb36f9 --- /dev/null +++ b/cdc.d @@ -0,0 +1,663 @@ +#!/usr/bin/rdmd + +/** + * License: Boost 1.0 + * + * Copyright (c) 2009-2010 Eric Poggel, Changes 2011 Ferdinand Majerech + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Description: + * + * This is a D programming language build script (and library) that can be used + * to compile D (version 1) source code. Unlike Bud, DSSS/Rebuild, Jake, and + * similar tools, CDC is contained within a single file that can easily be + * distributed with projects. This simplifies the build process since no other + * tools are required. The main() function can be utilized to turn + * CDC into a custom build script for your project. + * + * CDC's only requirement is a D compiler. It is/will be supported on any + * operating system supported by the language. It works with dmd, ldc (soon), + * and gdc. + * + * CDC can be used just like dmd, except for the following improvements. + *
    + *
  • CDC can accept paths as as well as individual source files for compilation. + * Each path is recursively searched for source, library, object, and ddoc files.
  • + *
  • CDC automatically creates a modules.ddoc file for use with CandyDoc and + * similar documentation utilities.
  • + *
  • CDC defaults to use the compiler that was used to build itself. Compiler + * flags are passed straight through to that compiler.
  • + *
  • The -op flag is always used, to prevent name conflicts in object and doc files.
  • + *
  • Documentation files are all placed in the same folder with their full package + * names. This makes relative links between documents easier.
  • + *
+ + * These DMD/LDC options are automatically translated to the correct GDC + * options, or handled manually: + *
+ *
-c
do not link
+ *
-D
generate documentation
+ *
-Dddocdir
write fully-qualified documentation files to docdir directory
+ *
-Dfdocfile
write fully-qualified documentation files to docfile file
+ *
-lib
Generate library rather than object files
+ *
-Ipath
where to look for imports
+ *
-o-
do not write object file.
+ *
-offilename
name output file to filename
+ *
-odobjdir
write object & library files to directory objdir
+ *
+ * + * In addition, these optional flags have been added. + *
+ *
--dmd
Use dmd to compile
+ *
--gdc
Use gdc to compile
+ *
--ldc
Use ldc to compile
+ *
+ * + * Bugs: + *
    + *
  • Doesn't yet work with LDC. See dsource.org/projects/ldc/ticket/323
  • + *
  • Dmd writes out object files as foo/bar.o, while gdc writes foo.bar.o
  • + *
  • Dmd fails to write object files when -od is an absolute path.
  • + *
+ * + * TODO: + *
    + *
  • Add support for a --script argument to accept another .d file that calls cdc's functions.
  • + *
  • -Df option
  • + *
  • GDC - Remove dependancy on "ar" on windows?
  • + *
  • LDC - Scanning a folder for files is broken.
  • + *
  • Unittests
  • + *
  • More testing on paths with spaces.
  • + *
+ * + * API: + * Use any of these functions in your own build script. + */ + + +import std.algorithm; +import std.array; +import std.exception; +import std.conv; +import std.file; +import std.path; +import std.process; +import std.range; +import std.string; +import std.stdio : writeln; + + +///Name of the default compiler, which is the compiler used to build cdc. +version(DigitalMars){string compiler = "dmd";} +version(GNU){string compiler = "gdmd";} +version(LDC){string compiler = "ldmd";} + +version(Windows) +{ + ///Valid object file extensions. + const string[] obj_ext = ["obj", "o"]; + ///Library extension. + const string lib_ext = "lib"; + ///Binary executable extension. + const string bin_ext = "exe"; + ///Path separator character. + char file_separator ='\\'; +} +else +{ + ///Valid object file extensions. + const string[] obj_ext = ["o"]; + ///Library extension. + const string lib_ext = "a"; + ///Binary executable extension. + const string bin_ext = ""; + ///Path separator character. + char file_separator ='/'; +} + +void main(string[] args) +{ + string target = "release"; + + scope(failure){help(); core.stdc.stdlib.exit(-1);} + + string[] extra_args = ["-w", "-wi"]; + + args = args[1 .. $]; + foreach(arg; args) + { + if(arg[0] == '-') + { + switch(arg) + { + case "--help", "-h": help(); return; + case "--dmd": compiler = "dmd"; break; + case "--gdc": compiler = "gdmd"; break; + case "--ldc": compiler = "ldmd"; break; + default: extra_args ~= arg; + } + } + } + if(args.length > 0 && args[$ - 1][0] != '-'){target = args[$ - 1];} + + string[] dbg = ["-gc", "-debug"]; + string[] optimize = ["-O", "-inline", "-release"]; + string[] lib_src = ["dyaml/", "yaml.d"]; + + void compile_(string[] args, string[] files){compile(files, args ~ extra_args);} + + void build_unittest() + { + writeln("building unittests"); + compile_(dbg ~ ["-unittest", "-ofunittest"], lib_src ~ "unittest.d" ~ "test/src"); + } + + void build_debug() + { + writeln("building debug target"); + compile_(dbg ~ ["-oflibdyaml-debug", "-lib"], lib_src); + } + + void build_release() + { + writeln("building release target"); + compile_(optimize ~ ["-oflibdyaml", "-lib"], lib_src); + } + + void build_tar_gz() + { + if(system("tar cf dyaml.tar * && gzip -9v dyaml.tar ") != 0) + { + writeln("Error creating a tar.gz package."); + } + } + + void build_tar_xz() + { + if(system("tar cf dyaml.tar * && xz -9ev dyaml.tar ") != 0) + { + writeln("Error creating a tar.xz package."); + } + } + + void build(string[] targets ...) + { + foreach(target; targets) + { + switch(target) + { + //case "examples": build_examples(); break; + case "debug": build_debug(); break; + case "release": build_release(); break; + case "unittest": build_unittest(); break; + case "tar.gz": build_tar_gz(); break; + case "tar.xz": build_tar_xz(); break; + case "all": build("debug", "release", "unittest"); break; + default: + writeln("unknown build target: ", target); + writeln("available targets: 'debug', 'release', 'all'"); + } + } + } + + try{build(target);} + catch(CompileException e){writeln("Could not compile: " ~ e.msg);} + catch(ProcessException e){writeln("Compilation failed: " ~ e.msg);} +} + +///Print help information. +void help() +{ + string help = + "D:YAML build script\n" + "Changes Copyright (C) 2011 Ferdinand Majerech\n" + "Based on CDC script Copyright (C) 2009-2010 Eric Poggel\n" + "Usage: cdc [OPTION ...] [EXTRA COMPILER OPTION ...] [TARGET]\n" + "By default, cdc uses the compiler it was built with to compile the project.\n" + "\n" + "Any options starting with '-' not parsed by the script will be\n" + "passed to the compiler used.\n" + "\n" + "Optionally, build target can be specified, 'debug' is default.\n" + "Available build targets:\n" + " unittest Build unit tests.\n" + " debug Debug information, unittests, contracts built in.\n" + " No optimizations. Target binary name: 'pong-debug'\n" + " release Debug information, no unittests, contracts.\n" + " Optimizations, inlining enabled.\n" + " Target binary name: 'pong-release'\n" + " all All of the above.\n" + " tar.gz Unix/Linux only: Create a tar.gz package\n" + " (this just archives the directory at the moment)\n" + " tar.xz Unix/Linux only: Create a tar.xz package\n" + " (this just archives the directory at the moment)\n" + "\n" + "Available options:\n" + " -h --help Show this help information.\n" + " --gdc Use GDC for compilation.\n" + " --dmd Use DMD for compilation.\n" + " --ldc Use LDC for compilation. (not tested)\n" + ; + writeln(help); +} + +/** + * Compile D code using the current compiler. + * + * Params: paths = Source and library files/directories. Directories are recursively searched. + * options = Compiler options. + * + * Example: + * -------- + * //Compile all source files in src/core along with src/main.d, + * //link with all library files in the libs folder + * //and generate documentation in the docs folder. + * compile(["src/core", "src/main.d", "libs"], ["-D", "-Dddocs"]); + * -------- + * + * TODO Add a dry run option to just return an array of commands to execute. + */ +static void compile(string[] paths, string[] options = null) +{ + //Convert src and lib paths to files + string[] sources, libs, ddocs; + foreach(src; paths) + { + enforceEx!CompileException(exists(src), + "Source file/folder \"" ~ src ~ "\" does not exist."); + //Directory of source or lib files + if(isdir(src)) + { + sources ~= scan(src, ".d"); + ddocs ~= scan(src, ".ddoc"); + libs ~= scan(src, lib_ext); + } + //File + else if(isfile(src)) + { + string ext = "." ~ src.getExt(); + if(ext == ".d"){sources ~= src;} + else if(ext == lib_ext){libs ~= src;} + } + } + + //Add dl.a for dynamic linking on linux + version(linux){libs ~= ["-L-ldl"];} + + //Combine all options, sources, ddocs, and libs + CompileOptions co = CompileOptions(options, sources); + options = co.get_options(compiler); + + if(compiler == "gdc") + { + foreach(ref d; ddocs){d = "-fdoc-inc=" ~ d;} + //or should this only be version(Windows) ? + //TODO: Check in dmd and gdc + foreach(ref l; libs){l = "-L" ~ l;} + } + + //Create modules.ddoc and add it to array of ddocs + if(co.generate_doc) + { + string modules = "MODULES = \r\n"; + sources.sort; + foreach(src; sources) + { + //get filename + src = split(src, "\\.")[0]; + src = replace(replace(src, "/", "."), "\\", "."); + modules ~= "\t$(MODULE " ~ src ~ ")\r\n"; + } + scope(failure){remove("modules.ddoc");} + write("modules.ddoc", modules); + ddocs ~= "modules.ddoc"; + } + + string[] arguments = options ~ sources ~ ddocs ~ libs; + + //Compile + if(compiler == "gdc") + { + //Add support for building libraries to gdc. + //GDC must build incrementally if creating documentation or a lib. + if(co.generate_lib || co.generate_doc || co.no_linking) + { + //Remove options we don't want to pass to gdc when building incrementally. + string[] incremental_options; + foreach(option; options) + { + if(option != "-lib" && !startsWith(option, "-o")) + { + incremental_options ~= option; + } + } + + //Compile files individually, outputting full path names + string[] obj_files; + foreach(source; sources) + { + string obj = replace(source, "/", ".")[0 .. $ - 2] ~ ".o"; + string ddoc = obj[0 .. $ - 2]; + if(co.obj_directory !is null) + { + obj = co.obj_directory ~ file_separator ~ obj; + } + obj_files ~= obj; + string[] exec = incremental_options ~ ["-o" ~ obj, "-c"] ~ [source]; + //ensure doc files are always fully qualified. + if(co.generate_doc){exec ~= ddocs ~ ["-fdoc-file=" ~ ddoc ~ ".html"];} + //throws ProcessException on compile failure + execute(compiler, exec); + } + + //use ar to join the .o files into a lib and cleanup obj files + //TODO: how to join on GDC windows? + if(co.generate_lib) + { + //since ar refuses to overwrite it. + remove(co.out_file); + execute("ar", "cq " ~ co.out_file ~ obj_files); + } + + //Remove obj files if -c or -od not were supplied. + if(!co.obj_directory && !co.no_linking) + { + foreach (o; obj_files){remove(o);} + } + } + + if (!co.generate_lib && !co.no_linking) + { + //Remove documentation arguments since they were handled above + string[] nondoc_args; + foreach(arg; arguments) + { + if(!startsWith(arg, "-fdoc", "-od")){nondoc_args ~= arg;} + } + + execute_compiler(compiler, nondoc_args); + } + } + //Compilers other than gdc + else + { + execute_compiler(compiler, arguments); + //Move all html files in doc_path to the doc output folder + //and rename them with the "package.module" naming convention. + if(co.generate_doc) + { + foreach(src; sources) + { + if(src.getExt != "d"){continue;} + + string html = src[0 .. $ - 2] ~ ".html"; + string dest = replace(replace(html, "/", "."), "\\", "."); + if(co.doc_directory.length > 0) + { + dest = co.doc_directory ~ file_separator ~ dest; + html = co.doc_directory ~ file_separator ~ html; + } + //TODO: Delete remaining folders where source files were placed. + if(html != dest) + { + copy(html, dest); + remove(html); + } + } + } + } + + //Remove extra files + string basename = split(co.out_file, "/")[$ - 1]; + + if(co.generate_doc){remove("modules.ddoc");} + if(co.out_file && !(co.no_linking || co.obj_directory)) + { + foreach(ext; obj_ext) + { + //Delete object files with same name as output file that dmd sometimes leaves. + try{remove(addExt(co.out_file, ext));} + catch(FileException e){continue;} + } + } +} + +/** + * Stores compiler options and translates them between compilers. + * + * Also enables -of and -op for easier handling. + */ +struct CompileOptions +{ + public: + ///Do not link. + bool no_linking; + ///Generate documentation. + bool generate_doc; + ///Write documentation to this directory. + string doc_directory; + ///Write documentation to this file. + string doc_file; + ///Generate library rather than object files. + bool generate_lib; + ///Do not write object files. + bool no_objects; + ///write object, library files to this directory. + string obj_directory; + ///Name of output file. + string out_file; + + private: + ///Compiler options. + string[] options_; + + public: + /** + * Construct CompileOptions from command line options. + * + * Params: options = Compiler command line options. + * sources = Source files to compile. + */ + this(string[] options, in string[] sources) + { + foreach (i, option; options) + { + if(option == "-c"){no_linking = true;} + else if(option == "-D" || option == "-fdoc"){generate_doc = true;} + else if(startsWith(option, "-Dd")){doc_directory = option[3..$];} + else if(startsWith(option, "-fdoc-dir=")){doc_directory = option[10..$];} + else if(startsWith(option, "-Df")){doc_file = option[3..$];} + else if(startsWith(option, "-fdoc-file=")){doc_file = option[11..$];} + else if(option == "-lib"){generate_lib = true;} + else if(option == "-o-" || option=="-fsyntax-only"){no_objects = true;} + else if(startsWith(option, "-of")){out_file = option[3..$];} + else if(startsWith(option, "-od")){obj_directory = option[3..$];} + else if(startsWith(option, "-o") && option != "-op"){out_file = option[2..$];} + options_ ~= option; + } + + //Set the -o (output filename) flag to the first source file if not already set. + //This matches the default behavior of dmd. + string ext = generate_lib ? lib_ext : bin_ext; + if(out_file.length == 0 && !no_linking && !no_objects && sources.length > 0) + { + out_file = split(split(sources[0], "/")[$ - 1], "\\.")[0] ~ ext; + options_ ~= ("-of" ~ out_file); + } + version (Windows) + { + //TODO needs testing + //{ if (find(this.out_file, ".") <= rfind(this.out_file, "/")) + if(find(out_file, '.') <= retro(find(retro(out_file), '/'))) + { + out_file ~= bin_ext; + } + } + } + + /** + * Translate DMD compiler options to options of the target compiler. + * + * This function is incomplete. (what about -L? ) + * + * Params: compiler = Compiler to translate to. + * + * Returns: Translated options. + */ + string[] get_options(in string compiler) + { + string[] result = options_.dup; + + if(compiler != "gdc") + { + version(Windows) + { + foreach(ref option; result) + { + option = startsWith(option, "-of") ? replace(option, "/", "\\") : option; + } + } + + //ensure ddocs don't overwrite one another. + return canFind(result, "-op") ? result : result ~ "-op"; + } + + //is gdc + string[string] translate; + translate["-Dd"] = "-fdoc-dir="; + translate["-Df"] = "-fdoc-file="; + translate["-debug="] = "-fdebug="; + translate["-debug"] = "-fdebug"; // will this still get selected? + translate["-inline"] = "-finline-functions"; + translate["-L"] = "-Wl"; + translate["-lib"] = ""; + translate["-O"] = "-O3"; + translate["-o-"] = "-fsyntax-only"; + translate["-of"] = "-o "; + translate["-unittest"] = "-funittest"; + translate["-version"] = "-fversion="; + translate["-version="] = "-fversion="; + translate["-wi"] = "-Wextra"; + translate["-w"] = "-Wall"; + translate["-gc"] = "-g"; + + //Perform option translation + foreach(ref option; result) + { + //remove unsupported -od + if(startsWith(option, "-od")){option = "";} + if(option =="-D"){option = "-fdoc";} + else + { + //Options with a direct translation + foreach(before, after; translate) + { + if(startsWith(option, before)) + { + option = after ~ option[before.length..$]; + break; + } + } + } + } + return result; + } + unittest + { + auto sources = ["foo.d"]; + auto options = ["-D", "-inline", "-offoo"]; + auto result = CompileOptions(options, sources).get_options("gdc"); + assert(result[0 .. 3] == ["-fdoc", "-finline-functions", "-o foo"]); + } +} + +///Thrown at errors in execution of other processes (e.g. compiler commands). +class CompileException : Exception {this(in string message){super(message);}}; + +/** + * Wrapper around execute to write compile options to a file to get around max arg lenghts on Windows. + * + * Params: compiler = Compiler to execute. + * arguments = Compiler arguments. + */ +void execute_compiler(in string compiler, string[] arguments) +{ + try + { + version(Windows) + { + write("compile", join(arguments, " ")); + scope(exit){remove("compile");} + execute(compiler ~ " ", ["@compile"]); + } + else{execute(compiler, arguments);} + } + catch(ProcessException e) + { + writeln("Compiler failed: " ~ e.msg); + } +} + +///Thrown at errors in execution of other processes (e.g. compiler commands). +class ProcessException : Exception {this(in string message){super(message);}}; + +/** + * Execute a command-line program and print its output. + * + * Params: command = The command to execute, e.g. "dmd". + * args = Arguments to pass to the command. + * + * Throws: ProcessException on failure or status code 1. + */ +void execute(string command, string[] args) +{ + version(Windows) + { + if(startsWith(command, "./")){command = command[2 .. $];} + } + + string full = command ~ " " ~ join(args, " "); + writeln("CDC: " ~ full); + if(int status = system(full) != 0) + { + throw new ProcessException("Process " ~ command ~ " exited with status " ~ + to!string(status)); + } +} + +/** + * Recursively get all files with specified extensions in directory and subdirectories. + * + * Params: directory = Absolute or relative path to the current directory. + * extensions = Extensions to match. + * + * Returns: An array of paths (including filename) relative to directory. + * + * Bugs: LDC fails to return any results. + */ +string[] scan(in string directory, string extensions ...) +{ + string[] result; + foreach(string name; dirEntries(directory, SpanMode.depth)) + { + if(isfile(name) && endsWith(name, extensions)){result ~= name;} + } + return result; +} diff --git a/doc/doctrees/articles/spec_differences.doctree b/doc/doctrees/articles/spec_differences.doctree new file mode 100644 index 0000000000000000000000000000000000000000..5599e061853ec021104943bc775b18f8ba38e24a GIT binary patch literal 14319 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 Ee+0Lj3IG5A literal 0 HcmV?d00001 diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle new file mode 100644 index 0000000000000000000000000000000000000000..b13884a2a8a2712853d2877a39d2e9e231f6ab62 GIT binary patch literal 12354 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 literal 0 HcmV?d00001 diff --git a/doc/doctrees/tutorials/custom_types.doctree b/doc/doctrees/tutorials/custom_types.doctree new file mode 100644 index 0000000000000000000000000000000000000000..763ad8235c0f397a5f456de9b942bca11e40491c GIT binary patch literal 26067 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

bI+_*j^`w$Ov2UpR!>L`r>Wm>@L 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 izvTRI;PB*Q0g9at_?w(d=9ly2n)`rxDh literal 0 HcmV?d00001 diff --git a/doc/doctrees/tutorials/getting_started.doctree b/doc/doctrees/tutorials/getting_started.doctree new file mode 100644 index 0000000000000000000000000000000000000000..2de0884a38a2423e01413f9c84b7dde0036dd782 GIT binary patch literal 31780 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 literal 0 HcmV?d00001 diff --git a/doc/doctrees/tutorials/yaml_syntax.doctree b/doc/doctrees/tutorials/yaml_syntax.doctree new file mode 100644 index 0000000000000000000000000000000000000000..bca51480bc7b04a32cf3f780741072746f90812c GIT binary patch literal 29099 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 ftLjs5E)}5tB8k8J)g*i`PNeV`_ + +Tutorials: + +.. toctree:: + :maxdepth: 2 + + tutorials/getting_started + tutorials/custom_types + tutorials/yaml_syntax + +Articles: + +.. toctree:: + :maxdepth: 2 + + articles/spec_differences diff --git a/doc/html/_sources/tutorials/custom_types.txt b/doc/html/_sources/tutorials/custom_types.txt new file mode 100644 index 0000000..ff6f3c8 --- /dev/null +++ b/doc/html/_sources/tutorials/custom_types.txt @@ -0,0 +1,227 @@ +====================== +Custom YAML data types +====================== + +Often you will want to serialize complex data types such as classes. You can use +functions to process nodes; e.g. a mapping containing class data members indexed +by name. Alternatively, YAML supports custom data types using identifiers called +*tags*. That is the topic of this tutorial. + +Each YAML node has a tag specifying its type. For instance: strings use the tag +``tag:yaml.org,2002:str``. Tags of most default types are *implicitly resolved* +during parsing, so you don't need to specify tag for each float, integer, etc. +It is also possible to implicitly resolve custom tags, as we will show later. + + +----------- +Constructor +----------- + +D:YAML uses the *Constructor* class to process each node to hold data type +corresponding to its tag. *Constructor* stores a function for each supported +tag to process it. These functions can be supplied by the user using the +*addConstructor()* method. *Constructor* is then passed to *Loader*, which will +parse YAML input. + +We will implement support for an RGB color type. It is implemented as the +following struct: + +.. code-block:: d + + struct Color + { + ubyte red; + ubyte green; + ubyte blue; + } + +First, we need a function to construct our data type. It must take two *Mark* +structs, which store position of the node in the file, and either a *string*, an +array of *Node* or of *Node.Pair*, depending on whether we're constructing our +value from a scalar, sequence, or mapping, respectively. In this tutorial, we +have functions to construct a color from a scalar, using HTML-like format, +RRGGBB, or from a mapping, where we use the following format: +{r:RRR, g:GGG, b:BBB} . Code of these functions: + +.. code-block:: d + + Color constructColorScalar(Mark start, Mark end, string value) + { + if(value.length != 6) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + //We don't need to check for uppercase chars this way. + value = value.toLower(); + + //Get value of a hex digit. + uint hex(char c) + { + if(!std.ascii.isHexDigit(c)) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + + if(std.ascii.isDigit(c)) + { + return c - '0'; + } + return c - 'a' + 10; + } + + Color result; + result.red = cast(ubyte)(16 * hex(value[0]) + hex(value[1])); + result.green = cast(ubyte)(16 * hex(value[2]) + hex(value[3])); + result.blue = cast(ubyte)(16 * hex(value[4]) + hex(value[5])); + + return result; + } + + Color constructColorMapping(Mark start, Mark end, Node.Pair[] pairs) + { + int r, g, b; + r = g = b = -1; + bool error = pairs.length != 3; + + foreach(ref pair; pairs) + { + //Key might not be a string, and value might not be an int, + //so we need to check for that + try + { + switch(pair.key.get!string) + { + case "r": r = pair.value.get!int; break; + case "g": g = pair.value.get!int; break; + case "b": b = pair.value.get!int; break; + default: error = true; + } + } + catch(NodeException e) + { + error = true; + } + } + + if(error || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) + { + throw new ConstructorException("Invalid color", start, end); + } + + return Color(cast(ubyte)r, cast(ubyte)g, cast(ubyte)b); + } + +Next, we need some YAML code using our new tag. Create a file called input.yaml +with the following contents: + +.. code-block:: yaml + + scalar-red: !color FF0000 + scalar-orange: !color FFFF00 + mapping-red: !color-mapping {r: 255, g: 0, b: 0} + mapping-orange: + !color-mapping + r: 255 + g: 255 + b: 0 + +You can see that we're using tag ``!color`` for scalar colors, and +``!color-mapping`` for colors expressed as mappings. + +Finally, the code to put it all together: + +.. code-block:: d + + void main() + { + auto red = Color(255, 0, 0); + auto orange = Color(255, 255, 0); + + try + { + auto constructor = new Constructor; + //both functions handle the same tag, but one handles scalar, one mapping. + constructor.addConstructor("!color", &constructColorScalar); + constructor.addConstructor("!color-mapping", &constructColorMapping); + + auto loader = new Loader("input.yaml", constructor, new Resolver); + + auto root = loader.loadSingleDocument(); + + if(root["scalar-red"].get!Color == red && + root["mapping-red"].get!Color == red && + root["scalar-orange"].get!Color == orange && + root["mapping-orange"].get!Color == orange) + { + writeln("SUCCESS"); + return; + } + } + catch(YAMLException e) + { + writeln(e.msg); + } + + writeln("FAILURE"); + } + +First, we create a *Constructor* and pass functions to handle the ``!color`` +and ``!color-mapping`` tag. We construct a *Loader* using the *Constructor*. +We also need a *Resolver*, but for now we just default-construct it. We then +load the YAML document, and finally, read the colors using *get()* method to +test if they were loaded as expected. + +You can find the source code for what we've done so far in the +``examples/constructor`` directory in the D:YAML package. + + +-------- +Resolver +-------- + +Specifying tag for every color value can be tedious. D:YAML can implicitly +resolve tag of a scalar using a regular expression. This is how default types, +e.g. int, are resolved. We will use the *Resolver* class to add implicit tag +resolution for the Color data type (in its scalar form). + +We use the *addImplicitResolver* method of *Resolver*, passing the tag, regular +expression the value must match to resolve to this tag, and a string of possible +starting characters of the value. Then we pass the *Resolver* to the constructor +of *Loader*. + +Note that resolvers added first override ones added later. If no resolver +matches a scalar, YAML string tag is used. Therefore our custom values must not +be resolvable as any non-string YAML data type. + +Add this to your code to add implicit resolution of ``!color``. + +.. code-block:: d + + //code from the previous example... + + auto resolver = new Resolver; + resolver.addImplicitResolver("!color", std.regex.regex("[0-9a-fA-F]{6}", + "0123456789abcdefABCDEF")); + + auto loader = new Loader("input.yaml", constructor, resolver); + + //code from the previous example... + +Now, change contents of input.dyaml to this: + +.. code-block:: yaml + + scalar-red: FF0000 + scalar-orange: FFFF00 + mapping-red: !color-mapping {r: 255, g: 0, b: 0} + mapping-orange: + !color-mapping + r: 255 + g: 255 + b: 0 + +We no longer need to specify the tag for scalar color values. Compile and test +the example. If everything went as expected, it should report success. + +You can find the complete code in the ``examples/resolver`` directory in the +D:YAML package. diff --git a/doc/html/_sources/tutorials/getting_started.txt b/doc/html/_sources/tutorials/getting_started.txt new file mode 100644 index 0000000..1cf6cff --- /dev/null +++ b/doc/html/_sources/tutorials/getting_started.txt @@ -0,0 +1,168 @@ +=============== +Getting started +=============== + +Welcome to D:YAML! D:YAML is a `YAML `_ parser +library for the `D programming language `_. This tutorial will +explain how to set D:YAML up and use it in your projects. + +This is meant to be the **simplest possible** introduction to D:YAML. Some of the +information present might already be known to you. Only basic usage is covered. +More advanced usage is described in other tutorials. + + +---------- +Setting up +---------- + +^^^^^^^^^^^^^^^^^^^^^^^^ +Install the DMD compiler +^^^^^^^^^^^^^^^^^^^^^^^^ + +Digital Mars D compiler, or DMD, is the most commonly used D compiler. You can +find its newest version `here `_. +Download the version of DMD for your operating system and install it. + +.. note:: + Other D compilers exist, such as + `GDC `_ and + `LDC `_. + Setting up with either one of them should be similar to DMD, + however, at the moment they are not as up to date as DMD. + + +^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Download and compile D:YAML +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The newest version of D:YAML can be found `here `_. Download a source +archive, extract it, and move to the extracted directory. + +D:YAML uses a modified version of the `CDC `_ +script for compilation. To compile D:YAML, you first need to build CDC. +Do this by typing the following command into the console:: + + dmd cdc.d + +Now you can use CDC to compile D:YAML. +To do this on Unix/Linux, use the following command:: + + ./cdc + +On Windows:: + + cdc.exe + +This will compile the library to a file called ``libdyaml.a`` on Unix/Linux or +``libdyaml.lib`` on Windows. + + +------------------------- +Your first D:YAML project +------------------------- + +Create a directory for your project and in that directory, create a file called +``input.yaml`` with the following contents: + +.. code-block:: yaml + + Hello World : + - Hello + - World + Answer: 42 + +This will serve as input for our example. + +Now we need to parse it. Create a file called "main.d". Paste following code +into the file: + +.. code-block:: d + + import std.stdio; + import yaml; + + void main() + { + yaml.Node root = yaml.load("input.yaml"); + foreach(string word; root["Hello World"]) + { + writeln(word); + } + writeln("The answer is ", root["Answer"].get!int); + } + + +^^^^^^^^^^^^^^^^^^^^^^^ +Explanation of the code +^^^^^^^^^^^^^^^^^^^^^^^ + +First, we import the *yaml* module. This is the only module you need to import +to use D:YAML - it automatically imports all needed modules. + +Next we load the file using the *yaml.load()* function - this loads the file as +**one** YAML document and throws *YAMLException*, D:YAML exception type, if the +file could not be parsed or does not contain exactly one document. Note that we +don't do any error checking here in order to keep the example as simple as +possible. + +*yaml.Node* represents a node in a YAML document. It can be a sequence (array), +mapping (associative array) or a scalar (value). Here the root node is a +mapping, and we use the index operator to get subnodes with keys "Hello World" +and "Answer". We iterate over the first, as it is a sequence, and use the +*yaml.Node.get()* method on the second to get its value as an integer. + +You can iterate over a mapping or sequence as if it was an associative or normal +array. If you try to iterate over a scalar, it will throw a *YAMLException*. + +You can iterate over subnodes using yaml.Node as the iterated type, or specify +the type subnodes are expected to have. D:YAML will automatically convert +iterated subnodes to that type if possible. Here we specify the *string* type, +so we iterate over the "Hello World" sequence as an array of strings. If it is +not possible to convert to iterated type, a *YAMLException* is thrown. For +instance, if we specified *int* here, we would get an error, as "Hello" +cannot be converted to an integer. + +The *yaml.Node.get()* method is used to get value of a scalar node as specified +type. D:YAML will try to return the scalar as specified type, converting if +needed, throwing *YAMLException* if not possible. + + +^^^^^^^^^ +Compiling +^^^^^^^^^ + +To compile your project, you must give DMD the directories containing import +modules and the library. You also need to tell it to link with D:YAML. The import +directory should be the D:YAML package directory. You can specify it using the +``-I`` option of DMD. The library directory should point to where you put the +compiled D:YAML library. On Unix/Linux you can specify it using the ``-L-L`` +option, and link with D:YAML using the ``-L-l`` option. On Windows, the import +directory is used as the library directory. To link with the library on Windows, +just add the path to it relative to the current directory. + +For example, if you extracted D:YAML to ``/home/xxx/dyaml`` and compiled it in +that directory, your project is in ``/home/xxx/dyaml-project``, and you are +currently in that directory, you can compile the project with the following +command on Unix/Linux:: + + dmd -I../dyaml -L-L../dyaml -L-ldyaml main.d + +And the following on Windows:: + + dmd -I../dyaml ../dyaml/libdyaml.lib main.d + +This will produce an executable called ``main`` or ``main.exe`` in your +directory. When you run it, it should produce the following output:: + + Hello + World + The answer is 42 + + +^^^^^^^^^^ +Conclusion +^^^^^^^^^^ + +You should now have a basic idea about how to use D:YAML. To learn more, look at +the `API documentation <../api/index.html>`_ and other tutorials. You can find code for this +example in the ``example/getting_started`` directory in the package. diff --git a/doc/html/_sources/tutorials/yaml_syntax.txt b/doc/html/_sources/tutorials/yaml_syntax.txt new file mode 100644 index 0000000..09fe3af --- /dev/null +++ b/doc/html/_sources/tutorials/yaml_syntax.txt @@ -0,0 +1,273 @@ +=========== +YAML syntax +=========== + +This is an introduction to the most common YAML constructs. For more detailed +information, see `PyYAML documentation `_, +which this article is based on, +`Chapter 2 of the YAML specification `_ +or the `Wikipedia page `_. + +YAML is a data serialization format designed to be as human readable as +possible. YAML is a recursive acronym for "YAML Ain't Markup Language". + +YAML is similar to JSON, and in fact, JSON is a subset of YAML 1.2; but YAML has +some more advanced features and is easier to read. However, YAML is also more +difficult to parse (and probably somewhat slower). Data is stored in mappings +(associative arrays), sequences (lists) and scalars (single values). Data +structure hierarchy either depends on indentation (block context, similar to +Python code), or nesting of brackets and braces (flow context, similar to JSON). +YAML comments begin with ``#`` and continue until the end of line. + + +--------- +Documents +--------- + +A YAML stream consists of one or more documents starting with ``---`` and +optionally ending with ``...`` . If there is only one document, ``---`` can be +left out. + +Single document with no explicit start or end: + +.. code-block:: yaml + + - Red + - Green + - Blue + +Same document with explicit start and end: + +.. code-block:: yaml + + --- + - Red + - Green + - Blue + ... + +A stream containing multiple documents: + +.. code-block:: yaml + + --- + - Red + - Green + - Blue + --- + - Linux + - BSD + --- + answer : 42 + + +--------- +Sequences +--------- + +Sequences are arrays of nodes of any type, similar e.g. to Python lists. +In block context, each item begins with hyphen+space "- ". In flow context, +sequences have syntax similar to D arrays. + +.. code-block:: yaml + + #Block context + - Red + - Green + - Blue + +.. code-block:: yaml + + #Flow context + [Red, Green, Blue] + +.. code-block:: yaml + + #Nested + - + - Red + - Green + - Blue + - + - Linux + - BSD + +.. code-block:: yaml + + #Nested flow + [[Red, Green, Blue], [Linux, BSD]] + +.. code-block:: yaml + + #Nested in a mapping + Colors: + - Red + - Green + - Blue + Operating systems: + - Linux + - BSD + + +-------- +Mappings +-------- + +Mappings are associative arrays where each key and value can be of any type, +similar e.g. to Python dictionaries. In block context, keys and values are +separated by colon+space ": ". In flow context, mappings have syntax similar +to D associative arrays, but with braces instead of brackets: + +.. code-block:: yaml + + #Block context + CPU: Athlon + GPU: Radeon + OS: Linux + +.. code-block:: yaml + + #Flow context + {CPU: Athlon, GPU: Radeon, OS: Linux} + +.. code-block:: yaml + + #Nested + PC: + CPU: Athlon + GPU: Radeon + OS: Debian + Phone: + CPU: Cortex + GPU: PowerVR + OS: Android + +.. code-block:: yaml + + #Nested flow + {PC: {CPU: Athlon, GPU: Radeon, OS: Debian}, + Phone: {CPU: Cortex, GPU: PowerVR, OS: Android}} + +.. code-block:: yaml + + #Nested in a sequence + - CPU: Athlon + GPU: Radeon + OS: Debian + - CPU: Cortex + GPU: PowerVR + OS: Android + +Complex keys start with question mark+space "? ". + +.. code-block:: yaml + + #Nested in a sequence + ? [CPU, GPU]: [Athlon, Radeon] + OS: Debian + + +------- +Scalars +------- + +Scalars are simple values such as integers, strings, timestamps and so on. +There are multiple scalar styles. + +Plain scalars use no quotes, start with the first non-space and end with the +last non-space character: + +.. code-block:: yaml + + scalar: Plain scalar + +Single quoted scalars start and end with single quotes. A single quote is +represented by a pair of single quotes ''. + +.. code-block:: yaml + + scalar: 'Single quoted scalar ending with some spaces ' + +Double quoted scalars support C-style escape sequences. + +.. code-block:: yaml + + scalar: "Double quoted scalar \n with some \\ escape sequences" + +Block scalars are convenient for multi-line values. They start either with +``|`` or with ``>``. With ``|``, the newlines in the scalar are preserved. +With ``>``, the newlines between two non-empty lines are removed. + +.. code-block:: yaml + + scalar: | + Newlines are preserved + First line + Second line + +.. code-block:: yaml + + scalar: > + Newlines are folded + This is still the first paragraph + + This is the second + paragraph + + +------------------- +Anchors and aliases +------------------- + +Anchors and aliases can reduce size of YAML code by allowing you to define a +value once, assign an anchor to it and use alias referring to that anchor +anywhere else you need that value. It is possible to use this to create +recursive data structures and some parsers support this; however, D:YAML does +not (this might change in the future, but it is unlikely). + +.. code-block:: yaml + + Person: &AD + gender: male + name: Arthur Dent + Clone: *AD + + +---- +Tags +---- + +Tags are identifiers that specify data types of YAML nodes. Most default YAML +tags are resolved implicitly, so there is no need to specify them. D:YAML also +supports implicit resolution for custom, user specified tags. + +Explicitly specified tags: + +.. code-block:: yaml + + answer: !!int "42" + name: !!str "Arthur Dent" + +Implicit tags: + +.. code-block:: yaml + + answer: 42 #int + name: Arthur Dent #string + +This table shows D types stored in *yaml.Node* default YAML tags are converted to. +Some of these might change in the future (especially !!map and !!set). + +====================== ================ +YAML tag D type +====================== ================ +!!null yaml.YAMLNull +!!bool bool +!!int long +!!float real +!!binary ubyte[] +!!timestamp datetime.SysTime +!!map, !!omap, !!pairs Node.Pair[] +!!seq, !!set Node[] +!!str string +====================== ================ diff --git a/doc/html/_static/basic.css b/doc/html/_static/basic.css new file mode 100644 index 0000000..69f30d4 --- /dev/null +++ b/doc/html/_static/basic.css @@ -0,0 +1,509 @@ +/* + * basic.css + * ~~~~~~~~~ + * + * Sphinx stylesheet -- basic theme. + * + * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +/* -- main layout ----------------------------------------------------------- */ + +div.clearer { + clear: both; +} + +/* -- relbar ---------------------------------------------------------------- */ + +div.related { + width: 100%; + font-size: 90%; +} + +div.related h3 { + display: none; +} + +div.related ul { + margin: 0; + padding: 0 0 0 10px; + list-style: none; +} + +div.related li { + display: inline; +} + +div.related li.right { + float: right; + margin-right: 5px; +} + +/* -- sidebar --------------------------------------------------------------- */ + +div.sphinxsidebarwrapper { + padding: 10px 5px 0 10px; +} + +div.sphinxsidebar { + float: left; + width: 230px; + margin-left: -100%; + font-size: 90%; +} + +div.sphinxsidebar ul { + list-style: none; +} + +div.sphinxsidebar ul ul, +div.sphinxsidebar ul.want-points { + margin-left: 20px; + list-style: square; +} + +div.sphinxsidebar ul ul { + margin-top: 0; + margin-bottom: 0; +} + +div.sphinxsidebar form { + margin-top: 10px; +} + +div.sphinxsidebar input { + border: 1px solid #98dbcc; + font-family: sans-serif; + font-size: 1em; +} + +img { + border: 0; +} + +/* -- search page ----------------------------------------------------------- */ + +ul.search { + margin: 10px 0 0 20px; + padding: 0; +} + +ul.search li { + padding: 5px 0 5px 20px; + background-image: url(file.png); + background-repeat: no-repeat; + background-position: 0 7px; +} + +ul.search li a { + font-weight: bold; +} + +ul.search li div.context { + color: #888; + margin: 2px 0 0 30px; + text-align: left; +} + +ul.keywordmatches li.goodmatch a { + font-weight: bold; +} + +/* -- index page ------------------------------------------------------------ */ + +table.contentstable { + width: 90%; +} + +table.contentstable p.biglink { + line-height: 150%; +} + +a.biglink { + font-size: 1.3em; +} + +span.linkdescr { + font-style: italic; + padding-top: 5px; + font-size: 90%; +} + +/* -- general index --------------------------------------------------------- */ + +table.indextable { + width: 100%; +} + +table.indextable td { + text-align: left; + vertical-align: top; +} + +table.indextable dl, table.indextable dd { + margin-top: 0; + margin-bottom: 0; +} + +table.indextable tr.pcap { + height: 10px; +} + +table.indextable tr.cap { + margin-top: 10px; + background-color: #f2f2f2; +} + +img.toggler { + margin-right: 3px; + margin-top: 3px; + cursor: pointer; +} + +div.modindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +div.genindex-jumpbox { + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 1em 0 1em 0; + padding: 0.4em; +} + +/* -- general body styles --------------------------------------------------- */ + +a.headerlink { + visibility: hidden; +} + +h1:hover > a.headerlink, +h2:hover > a.headerlink, +h3:hover > a.headerlink, +h4:hover > a.headerlink, +h5:hover > a.headerlink, +h6:hover > a.headerlink, +dt:hover > a.headerlink { + visibility: visible; +} + +div.body p.caption { + text-align: inherit; +} + +div.body td { + text-align: left; +} + +.field-list ul { + padding-left: 1em; +} + +.first { + margin-top: 0 !important; +} + +p.rubric { + margin-top: 30px; + font-weight: bold; +} + +.align-left { + text-align: left; +} + +.align-center { + clear: both; + text-align: center; +} + +.align-right { + text-align: right; +} + +/* -- sidebars -------------------------------------------------------------- */ + +div.sidebar { + margin: 0 0 0.5em 1em; + border: 1px solid #ddb; + padding: 7px 7px 0 7px; + background-color: #ffe; + width: 40%; + float: right; +} + +p.sidebar-title { + font-weight: bold; +} + +/* -- topics ---------------------------------------------------------------- */ + +div.topic { + border: 1px solid #ccc; + padding: 7px 7px 0 7px; + margin: 10px 0 10px 0; +} + +p.topic-title { + font-size: 1.1em; + font-weight: bold; + margin-top: 10px; +} + +/* -- admonitions ----------------------------------------------------------- */ + +div.admonition { + margin-top: 10px; + margin-bottom: 10px; + padding: 7px; +} + +div.admonition dt { + font-weight: bold; +} + +div.admonition dl { + margin-bottom: 0; +} + +p.admonition-title { + margin: 0px 10px 5px 0px; + font-weight: bold; +} + +div.body p.centered { + text-align: center; + margin-top: 25px; +} + +/* -- tables ---------------------------------------------------------------- */ + +table.docutils { + border: 0; + border-collapse: collapse; +} + +table.docutils td, table.docutils th { + padding: 1px 8px 1px 5px; + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #aaa; +} + +table.field-list td, table.field-list th { + border: 0 !important; +} + +table.footnote td, table.footnote th { + border: 0 !important; +} + +th { + text-align: left; + padding-right: 5px; +} + +table.citation { + border-left: solid 1px gray; + margin-left: 1px; +} + +table.citation td { + border-bottom: none; +} + +/* -- other body styles ----------------------------------------------------- */ + +ol.arabic { + list-style: decimal; +} + +ol.loweralpha { + list-style: lower-alpha; +} + +ol.upperalpha { + list-style: upper-alpha; +} + +ol.lowerroman { + list-style: lower-roman; +} + +ol.upperroman { + list-style: upper-roman; +} + +dl { + margin-bottom: 15px; +} + +dd p { + margin-top: 0px; +} + +dd ul, dd table { + margin-bottom: 10px; +} + +dd { + margin-top: 3px; + margin-bottom: 10px; + margin-left: 30px; +} + +dt:target, .highlighted { + background-color: #fbe54e; +} + +dl.glossary dt { + font-weight: bold; + font-size: 1.1em; +} + +.field-list ul { + margin: 0; + padding-left: 1em; +} + +.field-list p { + margin: 0; +} + +.refcount { + color: #060; +} + +.optional { + font-size: 1.3em; +} + +.versionmodified { + font-style: italic; +} + +.system-message { + background-color: #fda; + padding: 5px; + border: 3px solid red; +} + +.footnote:target { + background-color: #ffa +} + +.line-block { + display: block; + margin-top: 1em; + margin-bottom: 1em; +} + +.line-block .line-block { + margin-top: 0; + margin-bottom: 0; + margin-left: 1.5em; +} + +.guilabel, .menuselection { + font-family: sans-serif; +} + +.accelerator { + text-decoration: underline; +} + +.classifier { + font-style: oblique; +} + +/* -- code displays --------------------------------------------------------- */ + +pre { + overflow: auto; +} + +td.linenos pre { + padding: 5px 0px; + border: 0; + background-color: transparent; + color: #aaa; +} + +table.highlighttable { + margin-left: 0.5em; +} + +table.highlighttable td { + padding: 0 0.5em 0 0.5em; +} + +tt.descname { + background-color: transparent; + font-weight: bold; + font-size: 1.2em; +} + +tt.descclassname { + background-color: transparent; +} + +tt.xref, a tt { + background-color: transparent; + font-weight: bold; +} + +h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { + background-color: transparent; +} + +.viewcode-link { + float: right; +} + +.viewcode-back { + float: right; + font-family: sans-serif; +} + +div.viewcode-block:target { + margin: -1px -10px; + padding: 0 10px; +} + +/* -- math display ---------------------------------------------------------- */ + +img.math { + vertical-align: middle; +} + +div.body div.math p { + text-align: center; +} + +span.eqno { + float: right; +} + +/* -- printout stylesheet --------------------------------------------------- */ + +@media print { + div.document, + div.documentwrapper, + div.bodywrapper { + margin: 0 !important; + width: 100%; + } + + div.sphinxsidebar, + div.related, + div.footer, + #top-link { + display: none; + } +} diff --git a/doc/html/_static/default.css b/doc/html/_static/default.css new file mode 100644 index 0000000..61edbc0 --- /dev/null +++ b/doc/html/_static/default.css @@ -0,0 +1,255 @@ +/* + * default.css_t + * ~~~~~~~~~~~~~ + * + * Sphinx stylesheet -- default theme. + * + * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +@import url("basic.css"); + +/* -- page layout ----------------------------------------------------------- */ + +body { + font-family: Verdana, "Deja Vu", "Bitstream Vera Sans", sans-serif; + font-size: 100%; + background-color: #1f252b; + color: #000; + margin: 0; + padding: 0; +} + +div.document { + background-color: #1f252b; +} + +div.documentwrapper { + float: left; + width: 100%; +} + +div.bodywrapper { + margin: 0 0 0 230px; +} + +div.body { + background-color: #f6f6f6; + color: black; + padding: 0 20px 30px 20px; +} + +div.footer { + color: #ccc; + width: 100%; + padding: 9px 0 9px 0; + text-align: center; + font-size: 75%; +} + +div.footer a { + color: #ccc; + text-decoration: underline; +} + +div.related { + background-color: #303333; + line-height: 30px; + color: #ccc; +} + +div.related a { + color: #ffffff; +} + +div.sphinxsidebar { +} + +div.sphinxsidebar h3 { + font-family: Georgia, "Times New Roman", Times, serif; + color: #ffffff; + font-size: 1.4em; + font-weight: normal; + margin: 0; + padding: 0; +} + +div.sphinxsidebar h3 a { + color: #ffffff; +} + +div.sphinxsidebar h4 { + font-family: Georgia, "Times New Roman", Times, serif; + color: #ffffff; + font-size: 1.3em; + font-weight: normal; + margin: 5px 0 0 0; + padding: 0; +} + +div.sphinxsidebar p { + color: #ffffff; +} + +div.sphinxsidebar p.topless { + margin: 5px 10px 10px 10px; +} + +div.sphinxsidebar ul { + margin: 10px; + padding: 0; + color: #ffffff; +} + +div.sphinxsidebar a { + color: #ddd; +} + +div.sphinxsidebar input { + border: 1px solid #ddd; + font-family: sans-serif; + font-size: 1em; +} + + +/* -- hyperlink styles ------------------------------------------------------ */ + +a { + color: #006; + text-decoration: none; +} + +a:visited { + color: #606; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + + + +/* -- body styles ----------------------------------------------------------- */ + +div.body h1, +div.body h2, +div.body h3, +div.body h4, +div.body h5, +div.body h6 { + font-family: Georgia, "Times New Roman", Times, serif; + background-color: #f6f6f6; + font-weight: normal; + color: #633; + border-bottom: 1px solid #ccc; + margin: 20px -20px 10px -20px; + padding: 3px 0 3px 10px; +} + +div.body h1 { margin-top: 0; font-size: 200%; } +div.body h2 { font-size: 160%; } +div.body h3 { font-size: 140%; } +div.body h4 { font-size: 120%; } +div.body h5 { font-size: 110%; } +div.body h6 { font-size: 100%; } + +a.headerlink { + color: #006; + font-size: 0.8em; + padding: 0 4px 0 4px; + text-decoration: none; +} + +a.headerlink:hover { + background-color: #006; + color: white; +} + +div.body p, div.body dd, div.body li { + text-align: justify; + line-height: 130%; +} + +div.admonition p.admonition-title + p { + display: inline; +} + +div.admonition p { + margin-bottom: 5px; +} + +div.admonition pre { + margin-bottom: 5px; +} + +div.admonition ul, div.admonition ol { + margin-bottom: 5px; +} + +div.note { + background-color: #eee; + border: 1px solid #ccc; +} + +div.seealso { + background-color: #ffc; + border: 1px solid #ff6; +} + +div.topic { + background-color: #eee; +} + +div.warning { + background-color: #ffe4e4; + border: 1px solid #f66; +} + +p.admonition-title { + display: inline; +} + +p.admonition-title:after { + content: ":"; +} + +pre { + padding: 5px; + background-color: fcfcfc; + color: 000066; + line-height: 120%; + border: 1px solid #ac9; + border-left: none; + border-right: none; +} + +tt { + background-color: #ecf0f3; + padding: 0 1px 0 1px; + font-size: 0.95em; +} + +th { + background-color: #ede; +} + +.warning tt { + background: #efc2c2; +} + +.note tt { + background: #d6d6d6; +} + +.viewcode-back { + font-family: Verdana, "Deja Vu", "Bitstream Vera Sans", sans-serif; +} + +div.viewcode-block:target { + background-color: #f4debf; + border-top: 1px solid #ac9; + border-bottom: 1px solid #ac9; +} \ No newline at end of file diff --git a/doc/html/_static/doctools.js b/doc/html/_static/doctools.js new file mode 100644 index 0000000..eeea95e --- /dev/null +++ b/doc/html/_static/doctools.js @@ -0,0 +1,247 @@ +/* + * doctools.js + * ~~~~~~~~~~~ + * + * Sphinx JavaScript utilties for all documentation. + * + * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +/** + * select a different prefix for underscore + */ +$u = _.noConflict(); + +/** + * make the code below compatible with browsers without + * an installed firebug like debugger +if (!window.console || !console.firebug) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", + "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", + "profile", "profileEnd"]; + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +} + */ + +/** + * small helper function to urldecode strings + */ +jQuery.urldecode = function(x) { + return decodeURIComponent(x).replace(/\+/g, ' '); +} + +/** + * small helper function to urlencode strings + */ +jQuery.urlencode = encodeURIComponent; + +/** + * This function returns the parsed url parameters of the + * current request. Multiple values per key are supported, + * it will always return arrays of strings for the value parts. + */ +jQuery.getQueryParameters = function(s) { + if (typeof s == 'undefined') + s = document.location.search; + var parts = s.substr(s.indexOf('?') + 1).split('&'); + var result = {}; + for (var i = 0; i < parts.length; i++) { + var tmp = parts[i].split('=', 2); + var key = jQuery.urldecode(tmp[0]); + var value = jQuery.urldecode(tmp[1]); + if (key in result) + result[key].push(value); + else + result[key] = [value]; + } + return result; +}; + +/** + * small function to check if an array contains + * a given item. + */ +jQuery.contains = function(arr, item) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == item) + return true; + } + return false; +}; + +/** + * highlight a given string on a jquery object by wrapping it in + * span elements with the given class name. + */ +jQuery.fn.highlightText = function(text, className) { + function highlight(node) { + if (node.nodeType == 3) { + var val = node.nodeValue; + var pos = val.toLowerCase().indexOf(text); + if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { + var span = document.createElement("span"); + span.className = className; + span.appendChild(document.createTextNode(val.substr(pos, text.length))); + node.parentNode.insertBefore(span, node.parentNode.insertBefore( + document.createTextNode(val.substr(pos + text.length)), + node.nextSibling)); + node.nodeValue = val.substr(0, pos); + } + } + else if (!jQuery(node).is("button, select, textarea")) { + jQuery.each(node.childNodes, function() { + highlight(this); + }); + } + } + return this.each(function() { + highlight(this); + }); +}; + +/** + * Small JavaScript module for the documentation. + */ +var Documentation = { + + init : function() { + this.fixFirefoxAnchorBug(); + this.highlightSearchWords(); + this.initIndexTable(); + }, + + /** + * i18n support + */ + TRANSLATIONS : {}, + PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, + LOCALE : 'unknown', + + // gettext and ngettext don't access this so that the functions + // can safely bound to a different name (_ = Documentation.gettext) + gettext : function(string) { + var translated = Documentation.TRANSLATIONS[string]; + if (typeof translated == 'undefined') + return string; + return (typeof translated == 'string') ? translated : translated[0]; + }, + + ngettext : function(singular, plural, n) { + var translated = Documentation.TRANSLATIONS[singular]; + if (typeof translated == 'undefined') + return (n == 1) ? singular : plural; + return translated[Documentation.PLURALEXPR(n)]; + }, + + addTranslations : function(catalog) { + for (var key in catalog.messages) + this.TRANSLATIONS[key] = catalog.messages[key]; + this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); + this.LOCALE = catalog.locale; + }, + + /** + * add context elements like header anchor links + */ + addContextElements : function() { + $('div[id] > :header:first').each(function() { + $('\u00B6'). + attr('href', '#' + this.id). + attr('title', _('Permalink to this headline')). + appendTo(this); + }); + $('dt[id]').each(function() { + $('\u00B6'). + attr('href', '#' + this.id). + attr('title', _('Permalink to this definition')). + appendTo(this); + }); + }, + + /** + * workaround a firefox stupidity + */ + fixFirefoxAnchorBug : function() { + if (document.location.hash && $.browser.mozilla) + window.setTimeout(function() { + document.location.href += ''; + }, 10); + }, + + /** + * highlight the search words provided in the url in the text + */ + highlightSearchWords : function() { + var params = $.getQueryParameters(); + var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; + if (terms.length) { + var body = $('div.body'); + window.setTimeout(function() { + $.each(terms, function() { + body.highlightText(this.toLowerCase(), 'highlighted'); + }); + }, 10); + $('

') + .appendTo($('.sidebar .this-page-menu')); + } + }, + + /** + * init the domain index toggle buttons + */ + initIndexTable : function() { + var togglers = $('img.toggler').click(function() { + var src = $(this).attr('src'); + var idnum = $(this).attr('id').substr(7); + $('tr.cg-' + idnum).toggle(); + if (src.substr(-9) == 'minus.png') + $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); + else + $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); + }).css('display', ''); + if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { + togglers.click(); + } + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords : function() { + $('.sidebar .this-page-menu li.highlight-link').fadeOut(300); + $('span.highlighted').removeClass('highlighted'); + }, + + /** + * make the url absolute + */ + makeURL : function(relativeURL) { + return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; + }, + + /** + * get the current relative url + */ + getCurrentURL : function() { + var path = document.location.pathname; + var parts = path.split(/\//); + $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { + if (this == '..') + parts.pop(); + }); + var url = parts.join('/'); + return path.substring(url.lastIndexOf('/') + 1, path.length - 1); + } +}; + +// quick alias for translations +_ = Documentation.gettext; + +$(document).ready(function() { + Documentation.init(); +}); diff --git a/doc/html/_static/file.png b/doc/html/_static/file.png new file mode 100644 index 0000000000000000000000000000000000000000..d18082e397e7e54f20721af768c4c2983258f1b4 GIT binary patch literal 392 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP$HyOL$D9)yc9|lc|nKf<9@eUiWd>3GuTC!a5vdfWYEazjncPj5ZQX%+1 zt8B*4=d)!cdDz4wr^#OMYfqGz$1LDFF>|#>*O?AGil(WEs?wLLy{Gj2J_@opDm%`dlax3yA*@*N$G&*ukFv>P8+2CBWO(qz zD0k1@kN>hhb1_6`&wrCswzINE(evt-5C1B^STi2@PmdKI;Vst0PQB6!2kdN literal 0 HcmV?d00001 diff --git a/doc/html/_static/jquery.js b/doc/html/_static/jquery.js new file mode 100644 index 0000000..5c99a8d --- /dev/null +++ b/doc/html/_static/jquery.js @@ -0,0 +1,8176 @@ +/*! + * jQuery JavaScript Library v1.5 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Jan 31 08:31:29 2011 -0500 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // (both of which we optimize for) + quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Check for digits + rdigit = /\d/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // Has the ready events already been bound? + readyBound = false, + + // The deferred used on DOM ready + readyList, + + // Promise methods + promiseMethods = "then done fail isResolved isRejected promise".split( " " ), + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = "body"; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + match = quickExpr.exec( selector ); + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = (context ? context.ownerDocument || context : document); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return (context || rootjQuery).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if (selector.selector !== undefined) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.5", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + (this.selector ? " " : "") + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.done( fn ); + + return this; + }, + + eq: function( i ) { + return i === -1 ? + this.slice( i ) : + this.slice( i, +i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + window.$ = _$; + + if ( deep ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Handle when the DOM is ready + ready: function( wait ) { + // A third-party is pushing the ready event forwards + if ( wait === true ) { + jQuery.readyWait--; + } + + // Make sure that the DOM is not already loaded + if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyBound ) { + return; + } + + readyBound = true; + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent("onreadystatechange", DOMContentLoaded); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNaN: function( obj ) { + return obj == null || !rdigit.test( obj ) || isNaN( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw msg; + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test(data.replace(rvalidescape, "@") + .replace(rvalidtokens, "]") + .replace(rvalidbraces, "")) ) { + + // Try to use the native JSON parser first + return window.JSON && window.JSON.parse ? + window.JSON.parse( data ) : + (new Function("return " + data))(); + + } else { + jQuery.error( "Invalid JSON: " + data ); + } + }, + + // Cross-browser xml parsing + // (xml & tmp used internally) + parseXML: function( data , xml , tmp ) { + + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + + tmp = xml.documentElement; + + if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { + jQuery.error( "Invalid XML: " + data ); + } + + return xml; + }, + + noop: function() {}, + + // Evalulates a script in a global context + globalEval: function( data ) { + if ( data && rnotwhite.test(data) ) { + // Inspired by code by Andrea Giammarchi + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html + var head = document.getElementsByTagName("head")[0] || document.documentElement, + script = document.createElement("script"); + + script.type = "text/javascript"; + + if ( jQuery.support.scriptEval() ) { + script.appendChild( document.createTextNode( data ) ); + } else { + script.text = data; + } + + // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // This arises when a base node is used (#2709). + head.insertBefore( script, head.firstChild ); + head.removeChild( script ); + } + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction(object); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( var value = object[0]; + i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // The extra typeof function check is to prevent crashes + // in Safari 2 (See: #3039) + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type(array); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array ) { + if ( array.indexOf ) { + return array.indexOf( elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var ret = [], value; + + // Go through the array, translating each of the items to their + // new value (or values). + for ( var i = 0, length = elems.length; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + proxy: function( fn, proxy, thisObject ) { + if ( arguments.length === 2 ) { + if ( typeof proxy === "string" ) { + thisObject = fn; + fn = thisObject[ proxy ]; + proxy = undefined; + + } else if ( proxy && !jQuery.isFunction( proxy ) ) { + thisObject = proxy; + proxy = undefined; + } + } + + if ( !proxy && fn ) { + proxy = function() { + return fn.apply( thisObject || this, arguments ); + }; + } + + // Set the guid of unique handler to the same of original handler, so it can be removed + if ( fn ) { + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + } + + // So proxy can be declared as an argument + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can be optionally by executed if its a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return (new Date()).getTime(); + }, + + // Create a simple deferred (one callbacks list) + _Deferred: function() { + var // callbacks list + callbacks = [], + // stored [ context , args ] + fired, + // to avoid firing when already doing so + firing, + // flag to know if the deferred has been cancelled + cancelled, + // the deferred itself + deferred = { + + // done( f1, f2, ...) + done: function() { + if ( !cancelled ) { + var args = arguments, + i, + length, + elem, + type, + _fired; + if ( fired ) { + _fired = fired; + fired = 0; + } + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + deferred.done.apply( deferred, elem ); + } else if ( type === "function" ) { + callbacks.push( elem ); + } + } + if ( _fired ) { + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); + } + } + return this; + }, + + // resolve with given context and args + resolveWith: function( context, args ) { + if ( !cancelled && !fired && !firing ) { + firing = 1; + try { + while( callbacks[ 0 ] ) { + callbacks.shift().apply( context, args ); + } + } + finally { + fired = [ context, args ]; + firing = 0; + } + } + return this; + }, + + // resolve with this as context and given arguments + resolve: function() { + deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments ); + return this; + }, + + // Has this deferred been resolved? + isResolved: function() { + return !!( firing || fired ); + }, + + // Cancel + cancel: function() { + cancelled = 1; + callbacks = []; + return this; + } + }; + + return deferred; + }, + + // Full fledged deferred (two callbacks list) + Deferred: function( func ) { + var deferred = jQuery._Deferred(), + failDeferred = jQuery._Deferred(), + promise; + // Add errorDeferred methods, then and promise + jQuery.extend( deferred, { + then: function( doneCallbacks, failCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ); + return this; + }, + fail: failDeferred.done, + rejectWith: failDeferred.resolveWith, + reject: failDeferred.resolve, + isRejected: failDeferred.isResolved, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj , i /* internal */ ) { + if ( obj == null ) { + if ( promise ) { + return promise; + } + promise = obj = {}; + } + i = promiseMethods.length; + while( i-- ) { + obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ]; + } + return obj; + } + } ); + // Make sure only one callback list will be used + deferred.then( failDeferred.cancel, deferred.cancel ); + // Unexpose cancel + delete deferred.cancel; + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + return deferred; + }, + + // Deferred helper + when: function( object ) { + var args = arguments, + length = args.length, + deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ? + object : + jQuery.Deferred(), + promise = deferred.promise(), + resolveArray; + + if ( length > 1 ) { + resolveArray = new Array( length ); + jQuery.each( args, function( index, element ) { + jQuery.when( element ).then( function( value ) { + resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value; + if( ! --length ) { + deferred.resolveWith( promise, resolveArray ); + } + }, deferred.reject ); + } ); + } else if ( deferred !== object ) { + deferred.resolve( object ); + } + return promise; + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySubclass( selector, context ) { + return new jQuerySubclass.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySubclass, this ); + jQuerySubclass.superclass = this; + jQuerySubclass.fn = jQuerySubclass.prototype = this(); + jQuerySubclass.fn.constructor = jQuerySubclass; + jQuerySubclass.subclass = this.subclass; + jQuerySubclass.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) { + context = jQuerySubclass(context); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass ); + }; + jQuerySubclass.fn.init.prototype = jQuerySubclass.fn; + var rootjQuerySubclass = jQuerySubclass(document); + return jQuerySubclass; + }, + + browser: {} +}); + +// Create readyList deferred +readyList = jQuery._Deferred(); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +if ( indexOf ) { + jQuery.inArray = function( elem, array ) { + return indexOf.call( array, elem ); + }; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +// Expose jQuery to the global object +return (window.jQuery = window.$ = jQuery); + +})(); + + +(function() { + + jQuery.support = {}; + + var div = document.createElement("div"); + + div.style.display = "none"; + div.innerHTML = "
a"; + + var all = div.getElementsByTagName("*"), + a = div.getElementsByTagName("a")[0], + select = document.createElement("select"), + opt = select.appendChild( document.createElement("option") ); + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return; + } + + jQuery.support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: div.firstChild.nodeType === 3, + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText insted) + style: /red/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: a.getAttribute("href") === "/a", + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55$/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: div.getElementsByTagName("input")[0].value === "on", + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Will be defined later + deleteExpando: true, + optDisabled: false, + checkClone: false, + _scriptEval: null, + noCloneEvent: true, + boxModel: null, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableHiddenOffsets: true + }; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as diabled) + select.disabled = true; + jQuery.support.optDisabled = !opt.disabled; + + jQuery.support.scriptEval = function() { + if ( jQuery.support._scriptEval === null ) { + var root = document.documentElement, + script = document.createElement("script"), + id = "script" + jQuery.now(); + + script.type = "text/javascript"; + try { + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); + } catch(e) {} + + root.insertBefore( script, root.firstChild ); + + // Make sure that the execution of code works by injecting a script + // tag with appendChild/createTextNode + // (IE doesn't support this, fails, and uses .text instead) + if ( window[ id ] ) { + jQuery.support._scriptEval = true; + delete window[ id ]; + } else { + jQuery.support._scriptEval = false; + } + + root.removeChild( script ); + // release memory in IE + root = script = id = null; + } + + return jQuery.support._scriptEval; + }; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + + } catch(e) { + jQuery.support.deleteExpando = false; + } + + if ( div.attachEvent && div.fireEvent ) { + div.attachEvent("onclick", function click() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + jQuery.support.noCloneEvent = false; + div.detachEvent("onclick", click); + }); + div.cloneNode(true).fireEvent("onclick"); + } + + div = document.createElement("div"); + div.innerHTML = ""; + + var fragment = document.createDocumentFragment(); + fragment.appendChild( div.firstChild ); + + // WebKit doesn't clone checked state correctly in fragments + jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; + + // Figure out if the W3C box model works as expected + // document.body must exist before we can do this + jQuery(function() { + var div = document.createElement("div"), + body = document.getElementsByTagName("body")[0]; + + // Frameset documents with no body should not run this code + if ( !body ) { + return; + } + + div.style.width = div.style.paddingLeft = "1px"; + body.appendChild( div ); + jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; + + if ( "zoom" in div.style ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2; + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2; + } + + div.innerHTML = "
t
"; + var tds = div.getElementsByTagName("td"); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0; + + tds[0].style.display = ""; + tds[1].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE < 8 fail this test) + jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; + div.innerHTML = ""; + + body.removeChild( div ).style.display = "none"; + div = tds = null; + }); + + // Technique from Juriy Zaytsev + // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ + var eventSupported = function( eventName ) { + var el = document.createElement("div"); + eventName = "on" + eventName; + + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( !el.attachEvent ) { + return true; + } + + var isSupported = (eventName in el); + if ( !isSupported ) { + el.setAttribute(eventName, "return;"); + isSupported = typeof el[eventName] === "function"; + } + el = null; + + return isSupported; + }; + + jQuery.support.submitBubbles = eventSupported("submit"); + jQuery.support.changeBubbles = eventSupported("change"); + + // release memory in IE + div = all = a = null; +})(); + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + + return !!elem && !jQuery.isEmptyObject(elem); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ jQuery.expando ] = id = ++jQuery.uuid; + } else { + id = jQuery.expando; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" ) { + if ( pvt ) { + cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); + } else { + cache[ id ] = jQuery.extend(cache[ id ], name); + } + } + + thisCache = cache[ id ]; + + // Internal jQuery data is stored in a separate object inside the object's data + // cache in order to avoid key collisions between internal data and user-defined + // data + if ( pvt ) { + if ( !thisCache[ internalKey ] ) { + thisCache[ internalKey ] = {}; + } + + thisCache = thisCache[ internalKey ]; + } + + if ( data !== undefined ) { + thisCache[ name ] = data; + } + + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should + // not attempt to inspect the internal events object using jQuery.data, as this + // internal data object is undocumented and subject to change. + if ( name === "events" && !thisCache[name] ) { + return thisCache[ internalKey ] && thisCache[ internalKey ].events; + } + + return getByName ? thisCache[ name ] : thisCache; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var internalKey = jQuery.expando, isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; + + if ( thisCache ) { + delete thisCache[ name ]; + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !jQuery.isEmptyObject(thisCache) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( pvt ) { + delete cache[ id ][ internalKey ]; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !jQuery.isEmptyObject(cache[ id ]) ) { + return; + } + } + + var internalCache = cache[ id ][ internalKey ]; + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + if ( jQuery.support.deleteExpando || cache != window ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the entire user cache at once because it's faster than + // iterating through each key, but we need to continue to persist internal + // data if it existed + if ( internalCache ) { + cache[ id ] = {}; + cache[ id ][ internalKey ] = internalCache; + + // Otherwise, we need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + } else if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ jQuery.expando ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); + } else { + elem[ jQuery.expando ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 ) { + var attr = this[0].attributes, name; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = name.substr( 5 ); + dataAttr( this[0], name, data[ name ] ); + } + } + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + var parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var $this = jQuery( this ), + args = [ parts[0], value ]; + + $this.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + $this.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + data = elem.getAttribute( "data-" + key ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + !jQuery.isNaN( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + + + + +jQuery.extend({ + queue: function( elem, type, data ) { + if ( !elem ) { + return; + } + + type = (type || "fx") + "queue"; + var q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( !data ) { + return q || []; + } + + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + + } else { + q.push( data ); + } + + return q; + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(); + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift("inprogress"); + } + + fn.call(elem, function() { + jQuery.dequeue(elem, type); + }); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue", true ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function( i ) { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; + type = type || "fx"; + + return this.queue( type, function() { + var elem = this; + setTimeout(function() { + jQuery.dequeue( elem, type ); + }, time ); + }); + }, + + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspaces = /\s+/, + rreturn = /\r/g, + rspecialurl = /^(?:href|src|style)$/, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rradiocheck = /^(?:radio|checkbox)$/i; + +jQuery.props = { + "for": "htmlFor", + "class": "className", + readonly: "readOnly", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + colspan: "colSpan", + tabindex: "tabIndex", + usemap: "useMap", + frameborder: "frameBorder" +}; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name, fn ) { + return this.each(function(){ + jQuery.attr( this, name, "" ); + if ( this.nodeType === 1 ) { + this.removeAttribute( name ); + } + }); + }, + + addClass: function( value ) { + if ( jQuery.isFunction(value) ) { + return this.each(function(i) { + var self = jQuery(this); + self.addClass( value.call(this, i, self.attr("class")) ); + }); + } + + if ( value && typeof value === "string" ) { + var classNames = (value || "").split( rspaces ); + + for ( var i = 0, l = this.length; i < l; i++ ) { + var elem = this[i]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className ) { + elem.className = value; + + } else { + var className = " " + elem.className + " ", + setClass = elem.className; + + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { + if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { + setClass += " " + classNames[c]; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + if ( jQuery.isFunction(value) ) { + return this.each(function(i) { + var self = jQuery(this); + self.removeClass( value.call(this, i, self.attr("class")) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + var classNames = (value || "").split( rspaces ); + + for ( var i = 0, l = this.length; i < l; i++ ) { + var elem = this[i]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + var className = (" " + elem.className + " ").replace(rclass, " "); + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[c] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function(i) { + var self = jQuery(this); + self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspaces ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " "; + for ( var i = 0, l = this.length; i < l; i++ ) { + if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + if ( !arguments.length ) { + var elem = this[0]; + + if ( elem ) { + if ( jQuery.nodeName( elem, "option" ) ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + + // We need to handle select boxes special + if ( jQuery.nodeName( elem, "select" ) ) { + var index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery(option).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + } + + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { + return elem.getAttribute("value") === null ? "on" : elem.value; + } + + // Everything else, we just grab the value + return (elem.value || "").replace(rreturn, ""); + + } + + return undefined; + } + + var isFunction = jQuery.isFunction(value); + + return this.each(function(i) { + var self = jQuery(this), val = value; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call(this, i, self.val()); + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray(val) ) { + val = jQuery.map(val, function (value) { + return value == null ? "" : value + ""; + }); + } + + if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) { + this.checked = jQuery.inArray( self.val(), val ) >= 0; + + } else if ( jQuery.nodeName( this, "select" ) ) { + var values = jQuery.makeArray(val); + + jQuery( "option", this ).each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + this.selectedIndex = -1; + } + + } else { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) { + return undefined; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery(elem)[name](value); + } + + var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), + // Whether we are setting (or getting) + set = value !== undefined; + + // Try to normalize/fix the name + name = notxml && jQuery.props[ name ] || name; + + // Only do all the following if this is a node (faster for style) + if ( elem.nodeType === 1 ) { + // These attributes require special treatment + var special = rspecialurl.test( name ); + + // Safari mis-reports the default selected property of an option + // Accessing the parent's selectedIndex property fixes it + if ( name === "selected" && !jQuery.support.optSelected ) { + var parent = elem.parentNode; + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + } + + // If applicable, access the attribute via the DOM 0 way + // 'in' checks fail in Blackberry 4.7 #6931 + if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { + if ( set ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } + + if ( value === null ) { + if ( elem.nodeType === 1 ) { + elem.removeAttribute( name ); + } + + } else { + elem[ name ] = value; + } + } + + // browsers index elements by id/name on forms, give priority to attributes. + if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { + return elem.getAttributeNode( name ).nodeValue; + } + + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + if ( name === "tabIndex" ) { + var attributeNode = elem.getAttributeNode( "tabIndex" ); + + return attributeNode && attributeNode.specified ? + attributeNode.value : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + + return elem[ name ]; + } + + if ( !jQuery.support.style && notxml && name === "style" ) { + if ( set ) { + elem.style.cssText = "" + value; + } + + return elem.style.cssText; + } + + if ( set ) { + // convert the value to a string (all browsers do this but IE) see #1070 + elem.setAttribute( name, "" + value ); + } + + // Ensure that missing attributes return undefined + // Blackberry 4.7 returns "" from getAttribute #6938 + if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) { + return undefined; + } + + var attr = !jQuery.support.hrefNormalized && notxml && special ? + // Some attributes require a special call on IE + elem.getAttribute( name, 2 ) : + elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return attr === null ? undefined : attr; + } + // Handle everything which isn't a DOM element node + if ( set ) { + elem[ name ] = value; + } + return elem[ name ]; + } +}); + + + + +var rnamespaces = /\.(.*)$/, + rformElems = /^(?:textarea|input|select)$/i, + rperiod = /\./g, + rspace = / /g, + rescape = /[^\w\s.|`]/g, + fcleanup = function( nm ) { + return nm.replace(rescape, "\\$&"); + }, + eventKey = "events"; + +/* + * A number of helper functions used for managing events. + * Many of the ideas behind this code originated from + * Dean Edwards' addEvent library. + */ +jQuery.event = { + + // Bind an event to an element + // Original by Dean Edwards + add: function( elem, types, handler, data ) { + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // For whatever reason, IE has trouble passing the window object + // around, causing it to be cloned in the process + if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { + elem = window; + } + + if ( handler === false ) { + handler = returnFalse; + } else if ( !handler ) { + // Fixes bug #7229. Fix recommended by jdalton + return; + } + + var handleObjIn, handleObj; + + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the function being executed has a unique ID + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure + var elemData = jQuery._data( elem ); + + // If no elemData is found then we must be trying to bind to one of the + // banned noData elements + if ( !elemData ) { + return; + } + + var events = elemData[ eventKey ], + eventHandle = elemData.handle; + + if ( typeof events === "function" ) { + // On plain objects events is a fn that holds the the data + // which prevents this data from being JSON serialized + // the function does not need to be called, it just contains the data + eventHandle = events.handle; + events = events.events; + + } else if ( !events ) { + if ( !elem.nodeType ) { + // On plain objects, create a fn that acts as the holder + // of the values to avoid JSON serialization of event data + elemData[ eventKey ] = elemData = function(){}; + } + + elemData.events = events = {}; + } + + if ( !eventHandle ) { + elemData.handle = eventHandle = function() { + // Handle the second event of a trigger and when + // an event is called after a page has unloaded + return typeof jQuery !== "undefined" && !jQuery.event.triggered ? + jQuery.event.handle.apply( eventHandle.elem, arguments ) : + undefined; + }; + } + + // Add elem as a property of the handle function + // This is to prevent a memory leak with non-native events in IE. + eventHandle.elem = elem; + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = types.split(" "); + + var type, i = 0, namespaces; + + while ( (type = types[ i++ ]) ) { + handleObj = handleObjIn ? + jQuery.extend({}, handleObjIn) : + { handler: handler, data: data }; + + // Namespaced event handlers + if ( type.indexOf(".") > -1 ) { + namespaces = type.split("."); + type = namespaces.shift(); + handleObj.namespace = namespaces.slice(0).sort().join("."); + + } else { + namespaces = []; + handleObj.namespace = ""; + } + + handleObj.type = type; + if ( !handleObj.guid ) { + handleObj.guid = handler.guid; + } + + // Get the current list of functions bound to this event + var handlers = events[ type ], + special = jQuery.event.special[ type ] || {}; + + // Init the event handler queue + if ( !handlers ) { + handlers = events[ type ] = []; + + // Check for a special event handler + // Only use addEventListener/attachEvent if the special + // events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add the function to the element's handler list + handlers.push( handleObj ); + + // Keep track of which events have been used, for global triggering + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, pos ) { + // don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } + + var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + events = elemData && elemData[ eventKey ]; + + if ( !elemData || !events ) { + return; + } + + if ( typeof events === "function" ) { + elemData = events; + events = events.events; + } + + // types is actually an event object here + if ( types && types.type ) { + handler = types.handler; + types = types.type; + } + + // Unbind all events for the element + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { + types = types || ""; + + for ( type in events ) { + jQuery.event.remove( elem, type + types ); + } + + return; + } + + // Handle multiple events separated by a space + // jQuery(...).unbind("mouseover mouseout", fn); + types = types.split(" "); + + while ( (type = types[ i++ ]) ) { + origType = type; + handleObj = null; + all = type.indexOf(".") < 0; + namespaces = []; + + if ( !all ) { + // Namespaced event handlers + namespaces = type.split("."); + type = namespaces.shift(); + + namespace = new RegExp("(^|\\.)" + + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + eventType = events[ type ]; + + if ( !eventType ) { + continue; + } + + if ( !handler ) { + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( all || namespace.test( handleObj.namespace ) ) { + jQuery.event.remove( elem, origType, handleObj.handler, j ); + eventType.splice( j--, 1 ); + } + } + + continue; + } + + special = jQuery.event.special[ type ] || {}; + + for ( j = pos || 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( handler.guid === handleObj.guid ) { + // remove the given handler for the given type + if ( all || namespace.test( handleObj.namespace ) ) { + if ( pos == null ) { + eventType.splice( j--, 1 ); + } + + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + + if ( pos != null ) { + break; + } + } + } + + // remove generic event handler if no more handlers exist + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + ret = null; + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + var handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + delete elemData.events; + delete elemData.handle; + + if ( typeof elemData === "function" ) { + jQuery.removeData( elem, eventKey, true ); + + } else if ( jQuery.isEmptyObject( elemData ) ) { + jQuery.removeData( elem, undefined, true ); + } + } + }, + + // bubbling is internal + trigger: function( event, data, elem /*, bubbling */ ) { + // Event object or event type + var type = event.type || event, + bubbling = arguments[3]; + + if ( !bubbling ) { + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + jQuery.extend( jQuery.Event(type), event ) : + // Just the event type (string) + jQuery.Event(type); + + if ( type.indexOf("!") >= 0 ) { + event.type = type = type.slice(0, -1); + event.exclusive = true; + } + + // Handle a global trigger + if ( !elem ) { + // Don't bubble custom events when global (to avoid too much overhead) + event.stopPropagation(); + + // Only trigger if we've ever bound an event for it + if ( jQuery.event.global[ type ] ) { + // XXX This code smells terrible. event.js should not be directly + // inspecting the data cache + jQuery.each( jQuery.cache, function() { + // internalKey variable is just used to make it easier to find + // and potentially change this stuff later; currently it just + // points to jQuery.expando + var internalKey = jQuery.expando, + internalCache = this[ internalKey ]; + if ( internalCache && internalCache.events && internalCache.events[type] ) { + jQuery.event.trigger( event, data, internalCache.handle.elem ); + } + }); + } + } + + // Handle triggering a single element + + // don't do events on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { + return undefined; + } + + // Clean up in case it is reused + event.result = undefined; + event.target = elem; + + // Clone the incoming data, if any + data = jQuery.makeArray( data ); + data.unshift( event ); + } + + event.currentTarget = elem; + + // Trigger the event, it is assumed that "handle" is a function + var handle = elem.nodeType ? + jQuery._data( elem, "handle" ) : + (jQuery._data( elem, eventKey ) || {}).handle; + + if ( handle ) { + handle.apply( elem, data ); + } + + var parent = elem.parentNode || elem.ownerDocument; + + // Trigger an inline bound script + try { + if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) { + if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) { + event.result = false; + event.preventDefault(); + } + } + + // prevent IE from throwing an error for some elements with some event types, see #3533 + } catch (inlineError) {} + + if ( !event.isPropagationStopped() && parent ) { + jQuery.event.trigger( event, data, parent, true ); + + } else if ( !event.isDefaultPrevented() ) { + var old, + target = event.target, + targetType = type.replace( rnamespaces, "" ), + isClick = jQuery.nodeName( target, "a" ) && targetType === "click", + special = jQuery.event.special[ targetType ] || {}; + + if ( (!special._default || special._default.call( elem, event ) === false) && + !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { + + try { + if ( target[ targetType ] ) { + // Make sure that we don't accidentally re-trigger the onFOO events + old = target[ "on" + targetType ]; + + if ( old ) { + target[ "on" + targetType ] = null; + } + + jQuery.event.triggered = true; + target[ targetType ](); + } + + // prevent IE from throwing an error for some elements with some event types, see #3533 + } catch (triggerError) {} + + if ( old ) { + target[ "on" + targetType ] = old; + } + + jQuery.event.triggered = false; + } + } + }, + + handle: function( event ) { + var all, handlers, namespaces, namespace_re, events, + namespace_sort = [], + args = jQuery.makeArray( arguments ); + + event = args[0] = jQuery.event.fix( event || window.event ); + event.currentTarget = this; + + // Namespaced event handlers + all = event.type.indexOf(".") < 0 && !event.exclusive; + + if ( !all ) { + namespaces = event.type.split("."); + event.type = namespaces.shift(); + namespace_sort = namespaces.slice(0).sort(); + namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + event.namespace = event.namespace || namespace_sort.join("."); + + events = jQuery._data(this, eventKey); + + if ( typeof events === "function" ) { + events = events.events; + } + + handlers = (events || {})[ event.type ]; + + if ( events && handlers ) { + // Clone the handlers to prevent manipulation + handlers = handlers.slice(0); + + for ( var j = 0, l = handlers.length; j < l; j++ ) { + var handleObj = handlers[ j ]; + + // Filter the functions by class + if ( all || namespace_re.test( handleObj.namespace ) ) { + // Pass in a reference to the handler function itself + // So that we can later remove it + event.handler = handleObj.handler; + event.data = handleObj.data; + event.handleObj = handleObj; + + var ret = handleObj.handler.apply( this, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + } + + return event.result; + }, + + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // store a copy of the original event object + // and "clone" to set read-only properties + var originalEvent = event; + event = jQuery.Event( originalEvent ); + + for ( var i = this.props.length, prop; i; ) { + prop = this.props[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary + if ( !event.target ) { + // Fixes #1925 where srcElement might not be defined either + event.target = event.srcElement || document; + } + + // check if target is a textnode (safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && event.fromElement ) { + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; + } + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && event.clientX != null ) { + var doc = document.documentElement, + body = document.body; + + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); + } + + // Add which for key events + if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { + event.which = event.charCode != null ? event.charCode : event.keyCode; + } + + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) + if ( !event.metaKey && event.ctrlKey ) { + event.metaKey = event.ctrlKey; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && event.button !== undefined ) { + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); + } + + return event; + }, + + // Deprecated, use jQuery.guid instead + guid: 1E8, + + // Deprecated, use jQuery.proxy instead + proxy: jQuery.proxy, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady, + teardown: jQuery.noop + }, + + live: { + add: function( handleObj ) { + jQuery.event.add( this, + liveConvert( handleObj.origType, handleObj.selector ), + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); + }, + + remove: function( handleObj ) { + jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); + } + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + } +}; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src ) { + // Allow instantiation without the 'new' keyword + if ( !this.preventDefault ) { + return new jQuery.Event( src ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // timeStamp is buggy for some events on Firefox(#3843) + // So we won't rely on the native value + this.timeStamp = jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Checks if an event happened on an element within another element +// Used in jQuery.event.special.mouseenter and mouseleave handlers +var withinElement = function( event ) { + // Check if mouse(over|out) are still within the same parent element + var parent = event.relatedTarget; + + // Firefox sometimes assigns relatedTarget a XUL element + // which we cannot access the parentNode property of + try { + // Traverse up the tree + while ( parent && parent !== this ) { + parent = parent.parentNode; + } + + if ( parent !== this ) { + // set the correct event type + event.type = event.data; + + // handle event if we actually just moused on to a non sub-element + jQuery.event.handle.apply( this, arguments ); + } + + // assuming we've left the element since we most likely mousedover a xul element + } catch(e) { } +}, + +// In case of event delegation, we only need to rename the event.type, +// liveHandler will take care of the rest. +delegate = function( event ) { + event.type = event.data; + jQuery.event.handle.apply( this, arguments ); +}; + +// Create mouseenter and mouseleave events +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + setup: function( data ) { + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); + }, + teardown: function( data ) { + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); + } + }; +}); + +// submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function( data, namespaces ) { + if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) { + jQuery.event.add(this, "click.specialSubmit", function( e ) { + var elem = e.target, + type = elem.type; + + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { + e.liveFired = undefined; + return trigger( "submit", this, arguments ); + } + }); + + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { + var elem = e.target, + type = elem.type; + + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { + e.liveFired = undefined; + return trigger( "submit", this, arguments ); + } + }); + + } else { + return false; + } + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialSubmit" ); + } + }; + +} + +// change delegation, happens here so we have bind. +if ( !jQuery.support.changeBubbles ) { + + var changeFilters, + + getVal = function( elem ) { + var type = elem.type, val = elem.value; + + if ( type === "radio" || type === "checkbox" ) { + val = elem.checked; + + } else if ( type === "select-multiple" ) { + val = elem.selectedIndex > -1 ? + jQuery.map( elem.options, function( elem ) { + return elem.selected; + }).join("-") : + ""; + + } else if ( elem.nodeName.toLowerCase() === "select" ) { + val = elem.selectedIndex; + } + + return val; + }, + + testChange = function testChange( e ) { + var elem = e.target, data, val; + + if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { + return; + } + + data = jQuery._data( elem, "_change_data" ); + val = getVal(elem); + + // the current data will be also retrieved by beforeactivate + if ( e.type !== "focusout" || elem.type !== "radio" ) { + jQuery._data( elem, "_change_data", val ); + } + + if ( data === undefined || val === data ) { + return; + } + + if ( data != null || val ) { + e.type = "change"; + e.liveFired = undefined; + return jQuery.event.trigger( e, arguments[1], elem ); + } + }; + + jQuery.event.special.change = { + filters: { + focusout: testChange, + + beforedeactivate: testChange, + + click: function( e ) { + var elem = e.target, type = elem.type; + + if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { + return testChange.call( this, e ); + } + }, + + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + keydown: function( e ) { + var elem = e.target, type = elem.type; + + if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" ) { + return testChange.call( this, e ); + } + }, + + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information + beforeactivate: function( e ) { + var elem = e.target; + jQuery._data( elem, "_change_data", getVal(elem) ); + } + }, + + setup: function( data, namespaces ) { + if ( this.type === "file" ) { + return false; + } + + for ( var type in changeFilters ) { + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); + } + + return rformElems.test( this.nodeName ); + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialChange" ); + + return rformElems.test( this.nodeName ); + } + }; + + changeFilters = jQuery.event.special.change.filters; + + // Handle when the input is .focus()'d + changeFilters.focus = changeFilters.beforeactivate; +} + +function trigger( type, elem, args ) { + args[0].type = type; + return jQuery.event.handle.apply( elem, args ); +} + +// Create "bubbling" focus and blur events +if ( document.addEventListener ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + jQuery.event.special[ fix ] = { + setup: function() { + this.addEventListener( orig, handler, true ); + }, + teardown: function() { + this.removeEventListener( orig, handler, true ); + } + }; + + function handler( e ) { + e = jQuery.event.fix( e ); + e.type = fix; + return jQuery.event.handle.call( this, e ); + } + }); +} + +jQuery.each(["bind", "one"], function( i, name ) { + jQuery.fn[ name ] = function( type, data, fn ) { + // Handle object literals + if ( typeof type === "object" ) { + for ( var key in type ) { + this[ name ](key, data, type[key], fn); + } + return this; + } + + if ( jQuery.isFunction( data ) || data === false ) { + fn = data; + data = undefined; + } + + var handler = name === "one" ? jQuery.proxy( fn, function( event ) { + jQuery( this ).unbind( event, handler ); + return fn.apply( this, arguments ); + }) : fn; + + if ( type === "unload" && name !== "one" ) { + this.one( type, data, fn ); + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.add( this[i], type, handler, data ); + } + } + + return this; + }; +}); + +jQuery.fn.extend({ + unbind: function( type, fn ) { + // Handle object literals + if ( typeof type === "object" && !type.preventDefault ) { + for ( var key in type ) { + this.unbind(key, type[key]); + } + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.remove( this[i], type, fn ); + } + } + + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.live( types, data, fn, selector ); + }, + + undelegate: function( selector, types, fn ) { + if ( arguments.length === 0 ) { + return this.unbind( "live" ); + + } else { + return this.die( types, null, fn, selector ); + } + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + + triggerHandler: function( type, data ) { + if ( this[0] ) { + var event = jQuery.Event( type ); + event.preventDefault(); + event.stopPropagation(); + jQuery.event.trigger( event, data, this[0] ); + return event.result; + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + i = 1; + + // link all the functions, so any of them can unbind this click handler + while ( i < args.length ) { + jQuery.proxy( fn, args[ i++ ] ); + } + + return this.click( jQuery.proxy( fn, function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + })); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +var liveMap = { + focus: "focusin", + blur: "focusout", + mouseenter: "mouseover", + mouseleave: "mouseout" +}; + +jQuery.each(["live", "die"], function( i, name ) { + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { + var type, i = 0, match, namespaces, preType, + selector = origSelector || this.selector, + context = origSelector ? this : jQuery( this.context ); + + if ( typeof types === "object" && !types.preventDefault ) { + for ( var key in types ) { + context[ name ]( key, data, types[key], selector ); + } + + return this; + } + + if ( jQuery.isFunction( data ) ) { + fn = data; + data = undefined; + } + + types = (types || "").split(" "); + + while ( (type = types[ i++ ]) != null ) { + match = rnamespaces.exec( type ); + namespaces = ""; + + if ( match ) { + namespaces = match[0]; + type = type.replace( rnamespaces, "" ); + } + + if ( type === "hover" ) { + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); + continue; + } + + preType = type; + + if ( type === "focus" || type === "blur" ) { + types.push( liveMap[ type ] + namespaces ); + type = type + namespaces; + + } else { + type = (liveMap[ type ] || type) + namespaces; + } + + if ( name === "live" ) { + // bind live handler + for ( var j = 0, l = context.length; j < l; j++ ) { + jQuery.event.add( context[j], "live." + liveConvert( type, selector ), + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); + } + + } else { + // unbind live handler + context.unbind( "live." + liveConvert( type, selector ), fn ); + } + } + + return this; + }; +}); + +function liveHandler( event ) { + var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, + elems = [], + selectors = [], + events = jQuery._data( this, eventKey ); + + if ( typeof events === "function" ) { + events = events.events; + } + + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { + return; + } + + if ( event.namespace ) { + namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + event.liveFired = this; + + var live = events.live.slice(0); + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { + selectors.push( handleObj.selector ); + + } else { + live.splice( j--, 1 ); + } + } + + match = jQuery( event.target ).closest( selectors, event.currentTarget ); + + for ( i = 0, l = match.length; i < l; i++ ) { + close = match[i]; + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { + elem = close.elem; + related = null; + + // Those two events require additional checking + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { + event.type = handleObj.preType; + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; + } + + if ( !related || related !== elem ) { + elems.push({ elem: elem, handleObj: handleObj, level: close.level }); + } + } + } + } + + for ( i = 0, l = elems.length; i < l; i++ ) { + match = elems[i]; + + if ( maxLevel && match.level > maxLevel ) { + break; + } + + event.currentTarget = match.elem; + event.data = match.handleObj.data; + event.handleObj = match.handleObj; + + ret = match.handleObj.origHandler.apply( match.elem, arguments ); + + if ( ret === false || event.isPropagationStopped() ) { + maxLevel = match.level; + + if ( ret === false ) { + stop = false; + } + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + + return stop; +} + +function liveConvert( type, selector ) { + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&"); +} + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.bind( name, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } +}); + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set; + + if ( !expr ) { + return []; + } + + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { + var match, + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + var left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace(/\\/g, ""); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( var type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + var found, item, + filter = Expr.filter[ type ], + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( var i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + var pass = not ^ !!found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw "Syntax error, unrecognized expression: " + msg; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !/\W/.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !/\W/.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !/\W/.test(part) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !/\W/.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace(/\\/g, "") + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace(/\\/g, ""); + }, + + TAG: function( match, curLoop ) { + return match[1].toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace(/\\/g, ""); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace(/\\/g, ""); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + elem.parentNode.selectedIndex; + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + return "text" === elem.type; + }, + radio: function( elem ) { + return "radio" === elem.type; + }, + + checkbox: function( elem ) { + return "checkbox" === elem.type; + }, + + file: function( elem ) { + return "file" === elem.type; + }, + password: function( elem ) { + return "password" === elem.type; + }, + + submit: function( elem ) { + return "submit" === elem.type; + }, + + image: function( elem ) { + return "image" === elem.type; + }, + + reset: function( elem ) { + return "reset" === elem.type; + }, + + button: function( elem ) { + return "button" === elem.type || elem.nodeName.toLowerCase() === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + var first = match[2], + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + var doneName = match[0], + parent = elem.parentNode; + + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { + var count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent.sizcache = doneName; + } + + var diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // If the nodes are siblings (or identical) we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Utility function for retreiving the text value of an array of DOM nodes +Sizzle.getText = function( elems ) { + var ret = "", elem; + + for ( var i = 0; elems[i]; i++ ) { + elem = elems[i]; + + // Get the text from text nodes and CDATA nodes + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { + ret += elem.nodeValue; + + // Traverse everything else, except comment nodes + } else if ( elem.nodeType !== 8 ) { + ret += Sizzle.getText( elem.childNodes ); + } + } + + return ret; +}; + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + context.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + if ( matches ) { + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + return matches.call( node, expr ); + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem.sizcache = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem.sizcache = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var ret = this.pushStack( "", "find", selector ), + length = 0; + + for ( var i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( var n = length; n < ret.length; n++ ) { + for ( var r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && jQuery.filter( selector, this ).length > 0; + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + if ( jQuery.isArray( selectors ) ) { + var match, selector, + matches = {}, + level = 1; + + if ( cur && selectors.length ) { + for ( i = 0, l = selectors.length; i < l; i++ ) { + selector = selectors[i]; + + if ( !matches[selector] ) { + matches[selector] = jQuery.expr.match.POS.test( selector ) ? + jQuery( selector, context || this.context ) : + selector; + } + } + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( selector in matches ) { + match = matches[selector]; + + if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) { + ret.push({ selector: selector, elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + } + + return ret; + } + + var pos = POS.test( selectors ) ? + jQuery( selectors, context || this.context ) : null; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique(ret) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + if ( !elem || typeof elem === "string" ) { + return jQuery.inArray( this[0], + // If it receives a string, the selector is used + // If it receives nothing, the siblings are used + elem ? jQuery( elem ) : this.parent().children() ); + } + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ), + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, args.join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return (elem === qualifier) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return (jQuery.inArray( elem, qualifier ) >= 0) === keep; + }); +} + + + + +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }; + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and + + + + + + + + + +
+
+
+
+ +
+

Differences between D:YAML and the YAML specification

+

There are some differences between D:YAML and the YAML 1.1 specification. Some +are caused by difficulty of implementation of some features, such as multiple +Unicode encodings within single stream, and some by unnecessary restrictions or +ambiguities in the specification.

+

Still, D:YAML tries to be as close to the specification as possible. D:YAML should +never load documents with different meaning than according to the specification, +and documents that fail to load should be very rare (for instance, very few +files use multiple Unicode encodings).

+
+

List of known differences:

+

Differences that can cause valid YAML documents not to load:

+
    +
  • At the moment, all mappings in the internal representation are ordered, +and a comparison for equality between equal mappings with differing order +will return false. This will be fixed once Phobos has a usable map type or +D associative arrays work with variants.

    +
  • +
  • No support for byte order marks and multiple Unicode encodings in a stream.

    +
  • +
  • Plain scalars in flow context cannot contain ,, : and ?. +This might change with : in the future. +See http://pyyaml.org/wiki/YAMLColonInFlowContext for details.

    +
  • +
  • The specification does not restrict characters for anchors and +aliases. This may lead to problems, for instance, the document:

    +
    [ *alias, value ]
    +
    +
    +

    can be interpteted in two ways, as:

    +
    [ "value" ]
    +
    +
    +

    and:

    +
    [ *alias , "value" ]
    +
    +
    +

    Therefore we restrict aliases and anchors to ASCII alphanumeric characters.

    +
  • +
  • The specification is confusing about tabs in plain scalars. We don’t use tabs +in plain scalars at all.

    +
  • +
  • There is no support for recursive data structures in DYAML.

    +
  • +
+

Other differences:

+
    +
  • Indentation is ignored in the flow context, which is less restrictive than the +specification. This allows code such as:

    +
    key: {
    +}
    +
    +
    +
  • +
  • Indentation rules for quoted scalars are loosed: They don’t need to adhere +indentation as " and ' clearly mark the beginning and the end of them.

    +
  • +
  • We allow _ in tag handles.

    +
  • +
  • Right now, two mappings with the same contents but different orderings are +considered unequal, even if they are unordered mappings. This is because all +mappings are ordered in the D:YAML implementation. This should change in +future, once D associative arrays work with variant types or a map class or +struct appears in Phobos.

    +
  • +
+
+
+ + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/doc/html/index.html b/doc/html/index.html new file mode 100644 index 0000000..4d5cd6f --- /dev/null +++ b/doc/html/index.html @@ -0,0 +1,110 @@ + + + + + + + + + Welcome to D:YAML documentation! — D:YAML v0.1 documentation + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/html/objects.inv b/doc/html/objects.inv new file mode 100644 index 0000000000000000000000000000000000000000..5b82b6e34cfe40f4bd23b7a7bb97dd56c948711e GIT binary patch literal 202 zcmY#Z2rkIT%&Sny%qvUHE6FdaR47X=D$dN$Q!wIERtPA{&q_@$u~Klcigfh#0g8k{ zWUUko^bCRAkc?D?qSV~P%)FG;B8B`kg_4ZSVuiHKoKyuMot&RrP?TC+oSLFgTAZ1e zu27YenWV>6aqIM1|C49DJ=X?k=y`5D<>}*fHt>RJh{lR5XIs5qq)vJAOhfy}v*lBs xEzzoIYT0oq`16L0rcS3)hbdyq)x=cO7ihI~I8J4C7GY6Yw!Dau;r=s2NdPxHPg?*0 literal 0 HcmV?d00001 diff --git a/doc/html/search.html b/doc/html/search.html new file mode 100644 index 0000000..2c4a917 --- /dev/null +++ b/doc/html/search.html @@ -0,0 +1,94 @@ + + + + + + + + + Search — D:YAML v0.1 documentation + + + + + + + + + + + + + + + +
+
+
+
+ +

Search

+
+ +

+ Please activate JavaScript to enable the search + functionality. +

+
+

+ From here you can search these documents. Enter your search + words into the box below and click "search". Note that the search + function will automatically search for all of the words. Pages + containing fewer words won't appear in the result list. +

+
+ + + +
+ +
+ +
+ +
+
+
+
+
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/doc/html/searchindex.js b/doc/html/searchindex.js new file mode 100644 index 0000000..b2df8bc --- /dev/null +++ b/doc/html/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({objects:{},terms:{represent:1,all:[1,3,4],code:[0,1,3,4],scalar:[0,1,2,3,4],follow:[3,4],depend:[0,3],show:[0,3],readabl:0,specif:[0,1,2],articl:[0,2],program:4,digit:[3,4],sourc:[3,4],everi:3,string:[0,3,4],powervr:0,"void":[3,4],phobo:1,failur:3,yamlexcept:[3,4],implicitli:[0,3],tri:1,gender:0,list:[0,1,2],iter:4,"try":[3,4],item:0,slower:0,past:4,fold:0,second:[0,4],design:0,pass:3,download:4,rrr:3,even:1,index:[3,4],what:3,appear:1,defin:0,current:4,version:4,"new":3,method:[3,4],usag:4,never:1,here:4,ggg:3,ldyaml:4,path:4,modifi:4,implicit:[0,3],valu:[0,1,3,4],convert:[0,4],anchor:[0,1,2],datetim:0,omap:0,chang:[0,1,3],loadsingledocu:3,commonli:4,modul:4,unix:4,subnod:4,instal:4,regex:3,from:3,describ:4,would:4,doubl:0,two:[0,1,3],next:[3,4],few:1,call:[3,4],msg:3,type:[0,1,2,3,4],tell:4,more:[0,4],python:0,phone:0,known:[1,2,4],hold:3,must:[3,4],word:4,alia:[0,1],work:1,paragraph:0,can:[0,1,3,4],learn:4,male:0,root:[3,4],overrid:3,want:3,stream:[0,1],give:4,process:3,topic:3,tag:[0,1,3,2],tab:1,serial:[0,3],multipl:[0,1],newlin:0,quot:[0,1],getting_start:4,how:[3,4],foreach:[3,4],answer:[0,4],instead:0,simpl:[0,4],map:[0,1,2,3,4],mar:4,clone:0,variant:1,usabl:1,ff0000:3,uint:3,mai:1,end:[0,1,3],associ:[0,1,4],read:[0,3],stdio:4,explicit:0,correspond:3,ambigu:1,caus:1,alias:[0,1,2],"switch":3,green:[0,3],allow:[0,1],first:[0,2,3,4],order:[1,4],over:4,move:4,orang:3,becaus:1,veri:1,hierarchi:0,still:[0,1],style:0,fix:1,complex:[0,3],yaml:[0,1,2,3,4],window:4,html:3,therefor:[1,3],might:[0,1,3,4],easier:0,them:[0,1,4],"float":[0,3],"return":[1,3,4],thei:[0,1,3,4],handl:[1,3],auto:3,"break":3,now:[1,3,4],introduct:[0,4],name:[0,3],separ:0,each:[0,3],found:4,went:3,complet:3,mean:1,compil:[3,4],unequ:1,idea:4,expect:[3,4],our:[3,4],extract:4,out:0,space:0,content:[1,3,4],rel:4,"0123456789abcdefabcdef":3,ref:3,red:[0,3],difficulti:1,advanc:[0,4],base:0,dictionari:0,put:[3,4],org:[1,3],"byte":1,thrown:4,pyyaml:[0,1],indent:[0,1],could:4,keep:4,length:3,yamlcoloninflowcontext:1,confus:1,assign:0,radeon:0,oper:[0,4],onc:[0,1],arrai:[0,1,3,4],restrict:1,date:4,unlik:0,alreadi:4,done:3,size:0,differ:[1,2],script:4,data:[0,1,3,2],addimplicitresolv:3,system:[0,4],construct:[0,3],nodeexcept:3,gpu:0,conveni:0,"final":3,store:[0,3],adher:1,consol:4,option:[0,4],especi:0,ishexdigit:3,specifi:[0,3,4],pars:[0,3,4],somewhat:0,exactli:4,than:1,serv:4,remov:0,structur:[0,1],charact:[0,1,3],project:[2,4],str:[0,3],were:3,posit:3,clearli:1,packag:[3,4],have:[0,3,4],tabl:0,need:[0,1,3,4],"null":0,lib:4,inform:[0,4],constructcolormap:3,note:[3,4],also:[0,3,4],take:3,which:[0,1,3],brace:0,singl:[0,1],uppercas:3,blue:[0,3],begin:[0,1],normal:4,previou:3,most:[0,3,4],regular:3,pair:[0,3],"class":[1,3],don:[1,3,4],later:3,cover:4,doe:[0,1,4],bracket:0,cortex:0,fact:0,ldc:4,cdc:4,alphanumer:1,syntax:[0,2],identifi:[0,3],find:[3,4],onli:[0,4],explicitli:0,just:[3,4],explain:4,should:[1,3,4],meant:4,std:[3,4],get:[2,3,4],express:3,cannot:[1,4],report:3,whether:3,common:0,contain:[0,1,3,4],where:[0,3,4],wiki:1,set:[0,2,4],seq:0,see:[0,1,3],result:3,fail:1,close:1,athlon:0,wikipedia:0,between:[0,1,2],"import":4,altern:3,accord:1,kei:[0,1,3,4],both:3,last:0,howev:[0,4],equal:1,comment:0,etc:3,tutori:[2,3,4],context:[0,1],load:[1,3,4],point:4,color:[0,3],hyphen:0,loader:3,colon:0,addconstructor:3,suppli:3,respect:3,rgb:3,empti:0,mark:[0,1,3],json:0,basic:4,resolut:[0,3],ani:[0,3,4],togeth:3,input:[3,4],"catch":3,present:4,"case":3,multi:0,main:[3,4],look:4,plain:[0,1],ffff00:3,cast:3,ain:0,error:[3,4],loos:1,non:[0,3],archiv:4,tediou:3,ascii:[1,3],welcom:[2,4],same:[0,1,3],member:3,binari:0,instanc:[1,3,4],timestamp:0,android:0,document:[0,1,2,3,4],difficult:0,http:1,nest:0,moment:[1,4],user:[0,3],implement:[1,3],markup:0,constructorexcept:3,person:0,exampl:[3,4],command:4,thi:[0,1,3,4],everyth:3,left:0,explan:4,systim:0,newest:4,execut:4,less:1,gdc:4,human:0,languag:[0,4],struct:[1,3],libdyaml:4,interptet:1,except:4,constructcolorscalar:3,add:[3,4],other:[1,4],els:0,match:3,build:4,real:0,format:[0,3],preserv:0,world:4,recurs:[0,1],tolow:3,like:3,success:3,resolv:[0,2,3],integ:[0,3,4],arthur:0,api:[2,4],either:[0,3,4],output:4,unnecessari:1,right:1,often:3,linux:[0,4],some:[0,1,3,4],intern:1,home:4,ubyt:[0,3],librari:4,lead:1,unord:1,refer:0,run:4,acronym:0,dyaml:[1,3,4],unicod:1,chapter:0,comparison:1,about:[1,4],simplest:4,rare:1,page:0,constructor:[2,3],fals:1,produc:4,block:0,subset:0,within:1,encod:1,automat:4,bbb:3,bsd:0,bool:[0,3],your:[2,3,4],wai:[1,3],support:[0,1,3],question:0,"long":0,custom:[0,2,3],writeln:[3,4],start:[0,2,3,4],"function":[3,4],form:3,continu:0,link:4,line:0,"true":3,conclus:4,"throw":[3,4],dmd:4,consist:0,possibl:[0,1,3,4],"default":[0,3],until:0,directori:[3,4],problem:1,similar:[0,4],featur:[0,1],creat:[0,3,4],"int":[0,3,4],flow:[0,1],dure:3,parser:[0,4],repres:[0,4],"char":3,exist:4,file:[1,3,4],yamlnul:0,isdigit:3,dent:0,check:[3,4],probabl:0,hex:3,when:4,detail:[0,1],invalid:3,valid:1,rrggbb:3,futur:[0,1],test:3,you:[0,3,4],node:[0,3,4],xxx:4,sequenc:[0,2,3,4],consid:1,debian:0,reduc:0,longer:3,anywher:0,rule:1,hello:4,ignor:1,far:3,escap:0,cpu:0},objtypes:{},titles:["YAML syntax","Differences between D:YAML and the YAML specification","Welcome to D:YAML documentation!","Custom YAML data types","Getting started"],objnames:{},filenames:["tutorials/yaml_syntax","articles/spec_differences","index","tutorials/custom_types","tutorials/getting_started"]}) \ No newline at end of file diff --git a/doc/html/tutorials/custom_types.html b/doc/html/tutorials/custom_types.html new file mode 100644 index 0000000..da8d4b0 --- /dev/null +++ b/doc/html/tutorials/custom_types.html @@ -0,0 +1,289 @@ + + + + + + + + + Custom YAML data types — D:YAML v0.1 documentation + + + + + + + + + + + + + +
+
+
+
+ +
+

Custom YAML data types

+

Often you will want to serialize complex data types such as classes. You can use +functions to process nodes; e.g. a mapping containing class data members indexed +by name. Alternatively, YAML supports custom data types using identifiers called +tags. That is the topic of this tutorial.

+

Each YAML node has a tag specifying its type. For instance: strings use the tag +tag:yaml.org,2002:str. Tags of most default types are implicitly resolved +during parsing, so you don’t need to specify tag for each float, integer, etc. +It is also possible to implicitly resolve custom tags, as we will show later.

+
+

Constructor

+

D:YAML uses the Constructor class to process each node to hold data type +corresponding to its tag. Constructor stores a function for each supported +tag to process it. These functions can be supplied by the user using the +addConstructor() method. Constructor is then passed to Loader, which will +parse YAML input.

+

We will implement support for an RGB color type. It is implemented as the +following struct:

+
struct Color
+{
+    ubyte red;
+    ubyte green;
+    ubyte blue;
+}
+
+
+

First, we need a function to construct our data type. It must take two Mark +structs, which store position of the node in the file, and either a string, an +array of Node or of Node.Pair, depending on whether we’re constructing our +value from a scalar, sequence, or mapping, respectively. In this tutorial, we +have functions to construct a color from a scalar, using HTML-like format, +RRGGBB, or from a mapping, where we use the following format: +{r:RRR, g:GGG, b:BBB} . Code of these functions:

+
Color constructColorScalar(Mark start, Mark end, string value)
+{
+    if(value.length != 6)
+    {
+        throw new ConstructorException("Invalid color: " ~ value, start, end);
+    }
+    //We don't need to check for uppercase chars this way.
+    value = value.toLower();
+
+    //Get value of a hex digit.
+    uint hex(char c)
+    {
+        if(!std.ascii.isHexDigit(c))
+        {
+            throw new ConstructorException("Invalid color: " ~ value, start, end);
+        }
+
+        if(std.ascii.isDigit(c))
+        {
+            return c - '0';
+        }
+        return c - 'a' + 10;
+    }
+
+    Color result;
+    result.red   = cast(ubyte)(16 * hex(value[0]) + hex(value[1]));
+    result.green = cast(ubyte)(16 * hex(value[2]) + hex(value[3]));
+    result.blue  = cast(ubyte)(16 * hex(value[4]) + hex(value[5]));
+
+    return result;
+}
+
+Color constructColorMapping(Mark start, Mark end, Node.Pair[] pairs)
+{
+    int r, g, b;
+    r = g = b = -1;
+    bool error = pairs.length != 3;
+
+    foreach(ref pair; pairs)
+    {
+        //Key might not be a string, and value might not be an int,
+        //so we need to check for that
+        try
+        {
+            switch(pair.key.get!string)
+            {
+                case "r": r = pair.value.get!int; break;
+                case "g": g = pair.value.get!int; break;
+                case "b": b = pair.value.get!int; break;
+                default:  error = true;
+            }
+        }
+        catch(NodeException e)
+        {
+            error = true;
+        }
+    }
+
+    if(error || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
+    {
+        throw new ConstructorException("Invalid color", start, end);
+    }
+
+    return Color(cast(ubyte)r, cast(ubyte)g, cast(ubyte)b);
+}
+
+
+

Next, we need some YAML code using our new tag. Create a file called input.yaml +with the following contents:

+
scalar-red: !color FF0000
+scalar-orange: !color FFFF00
+mapping-red: !color-mapping {r: 255, g: 0, b: 0}
+mapping-orange:
+    !color-mapping
+    r: 255
+    g: 255
+    b: 0
+
+
+

You can see that we’re using tag !color for scalar colors, and +!color-mapping for colors expressed as mappings.

+

Finally, the code to put it all together:

+
void main()
+{
+    auto red    = Color(255, 0, 0);
+    auto orange = Color(255, 255, 0);
+
+    try
+    {
+        auto constructor = new Constructor;
+        //both functions handle the same tag, but one handles scalar, one mapping.
+        constructor.addConstructor("!color", &constructColorScalar);
+        constructor.addConstructor("!color-mapping", &constructColorMapping);
+
+        auto loader = new Loader("input.yaml", constructor, new Resolver);
+
+        auto root = loader.loadSingleDocument();
+
+        if(root["scalar-red"].get!Color == red &&
+           root["mapping-red"].get!Color == red &&
+           root["scalar-orange"].get!Color == orange &&
+           root["mapping-orange"].get!Color == orange)
+        {
+            writeln("SUCCESS");
+            return;
+        }
+    }
+    catch(YAMLException e)
+    {
+        writeln(e.msg);
+    }
+
+    writeln("FAILURE");
+}
+
+
+

First, we create a Constructor and pass functions to handle the !color +and !color-mapping tag. We construct a Loader using the Constructor. +We also need a Resolver, but for now we just default-construct it. We then +load the YAML document, and finally, read the colors using get() method to +test if they were loaded as expected.

+

You can find the source code for what we’ve done so far in the +examples/constructor directory in the D:YAML package.

+
+
+

Resolver

+

Specifying tag for every color value can be tedious. D:YAML can implicitly +resolve tag of a scalar using a regular expression. This is how default types, +e.g. int, are resolved. We will use the Resolver class to add implicit tag +resolution for the Color data type (in its scalar form).

+

We use the addImplicitResolver method of Resolver, passing the tag, regular +expression the value must match to resolve to this tag, and a string of possible +starting characters of the value. Then we pass the Resolver to the constructor +of Loader.

+

Note that resolvers added first override ones added later. If no resolver +matches a scalar, YAML string tag is used. Therefore our custom values must not +be resolvable as any non-string YAML data type.

+

Add this to your code to add implicit resolution of !color.

+
//code from the previous example...
+
+auto resolver = new Resolver;
+resolver.addImplicitResolver("!color", std.regex.regex("[0-9a-fA-F]{6}",
+                             "0123456789abcdefABCDEF"));
+
+auto loader = new Loader("input.yaml", constructor, resolver);
+
+//code from the previous example...
+
+
+

Now, change contents of input.dyaml to this:

+
scalar-red: FF0000
+scalar-orange: FFFF00
+mapping-red: !color-mapping {r: 255, g: 0, b: 0}
+mapping-orange:
+    !color-mapping
+    r: 255
+    g: 255
+    b: 0
+
+
+

We no longer need to specify the tag for scalar color values. Compile and test +the example. If everything went as expected, it should report success.

+

You can find the complete code in the examples/resolver directory in the +D:YAML package.

+
+
+ + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/doc/html/tutorials/getting_started.html b/doc/html/tutorials/getting_started.html new file mode 100644 index 0000000..f5e45be --- /dev/null +++ b/doc/html/tutorials/getting_started.html @@ -0,0 +1,231 @@ + + + + + + + + + Getting started — D:YAML v0.1 documentation + + + + + + + + + + + + + +
+
+
+
+ +
+

Getting started

+

Welcome to D:YAML! D:YAML is a YAML parser +library for the D programming language. This tutorial will +explain how to set D:YAML up and use it in your projects.

+

This is meant to be the simplest possible introduction to D:YAML. Some of the +information present might already be known to you. Only basic usage is covered. +More advanced usage is described in other tutorials.

+
+

Setting up

+
+

Install the DMD compiler

+

Digital Mars D compiler, or DMD, is the most commonly used D compiler. You can +find its newest version here. +Download the version of DMD for your operating system and install it.

+
+

Note

+

Other D compilers exist, such as +GDC and +LDC. +Setting up with either one of them should be similar to DMD, +however, at the moment they are not as up to date as DMD.

+
+
+
+

Download and compile D:YAML

+

The newest version of D:YAML can be found here. Download a source +archive, extract it, and move to the extracted directory.

+

D:YAML uses a modified version of the CDC +script for compilation. To compile D:YAML, you first need to build CDC. +Do this by typing the following command into the console:

+
dmd cdc.d
+
+

Now you can use CDC to compile D:YAML. +To do this on Unix/Linux, use the following command:

+
./cdc
+
+

On Windows:

+
cdc.exe
+
+
+

This will compile the library to a file called libdyaml.a on Unix/Linux or +libdyaml.lib on Windows.

+
+
+
+

Your first D:YAML project

+

Create a directory for your project and in that directory, create a file called +input.yaml with the following contents:

+
Hello World :
+    - Hello
+    - World
+Answer: 42
+
+
+

This will serve as input for our example.

+

Now we need to parse it. Create a file called “main.d”. Paste following code +into the file:

+
import std.stdio;
+import yaml;
+
+void main()
+{
+    yaml.Node root = yaml.load("input.yaml");
+    foreach(string word; root["Hello World"])
+    {
+        writeln(word);
+    }
+    writeln("The answer is ", root["Answer"].get!int);
+}
+
+
+
+

Explanation of the code

+

First, we import the yaml module. This is the only module you need to import +to use D:YAML - it automatically imports all needed modules.

+

Next we load the file using the yaml.load() function - this loads the file as +one YAML document and throws YAMLException, D:YAML exception type, if the +file could not be parsed or does not contain exactly one document. Note that we +don’t do any error checking here in order to keep the example as simple as +possible.

+

yaml.Node represents a node in a YAML document. It can be a sequence (array), +mapping (associative array) or a scalar (value). Here the root node is a +mapping, and we use the index operator to get subnodes with keys “Hello World” +and “Answer”. We iterate over the first, as it is a sequence, and use the +yaml.Node.get() method on the second to get its value as an integer.

+

You can iterate over a mapping or sequence as if it was an associative or normal +array. If you try to iterate over a scalar, it will throw a YAMLException.

+

You can iterate over subnodes using yaml.Node as the iterated type, or specify +the type subnodes are expected to have. D:YAML will automatically convert +iterated subnodes to that type if possible. Here we specify the string type, +so we iterate over the “Hello World” sequence as an array of strings. If it is +not possible to convert to iterated type, a YAMLException is thrown. For +instance, if we specified int here, we would get an error, as “Hello” +cannot be converted to an integer.

+

The yaml.Node.get() method is used to get value of a scalar node as specified +type. D:YAML will try to return the scalar as specified type, converting if +needed, throwing YAMLException if not possible.

+
+
+

Compiling

+

To compile your project, you must give DMD the directories containing import +modules and the library. You also need to tell it to link with D:YAML. The import +directory should be the D:YAML package directory. You can specify it using the +-I option of DMD. The library directory should point to where you put the +compiled D:YAML library. On Unix/Linux you can specify it using the -L-L +option, and link with D:YAML using the -L-l option. On Windows, the import +directory is used as the library directory. To link with the library on Windows, +just add the path to it relative to the current directory.

+

For example, if you extracted D:YAML to /home/xxx/dyaml and compiled it in +that directory, your project is in /home/xxx/dyaml-project, and you are +currently in that directory, you can compile the project with the following +command on Unix/Linux:

+
dmd -I../dyaml -L-L../dyaml -L-ldyaml main.d
+
+

And the following on Windows:

+
dmd -I../dyaml ../dyaml/libdyaml.lib main.d
+
+

This will produce an executable called main or main.exe in your +directory. When you run it, it should produce the following output:

+
Hello
+World
+The answer is 42
+
+
+
+

Conclusion

+

You should now have a basic idea about how to use D:YAML. To learn more, look at +the API documentation and other tutorials. You can find code for this +example in the example/getting_started directory in the package.

+
+
+
+ + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/doc/html/tutorials/yaml_syntax.html b/doc/html/tutorials/yaml_syntax.html new file mode 100644 index 0000000..507eba6 --- /dev/null +++ b/doc/html/tutorials/yaml_syntax.html @@ -0,0 +1,338 @@ + + + + + + + + + YAML syntax — D:YAML v0.1 documentation + + + + + + + + + + + + + +
+
+
+
+ +
+

YAML syntax

+

This is an introduction to the most common YAML constructs. For more detailed +information, see PyYAML documentation, +which this article is based on, +Chapter 2 of the YAML specification +or the Wikipedia page.

+

YAML is a data serialization format designed to be as human readable as +possible. YAML is a recursive acronym for “YAML Ain’t Markup Language”.

+

YAML is similar to JSON, and in fact, JSON is a subset of YAML 1.2; but YAML has +some more advanced features and is easier to read. However, YAML is also more +difficult to parse (and probably somewhat slower). Data is stored in mappings +(associative arrays), sequences (lists) and scalars (single values). Data +structure hierarchy either depends on indentation (block context, similar to +Python code), or nesting of brackets and braces (flow context, similar to JSON). +YAML comments begin with # and continue until the end of line.

+
+

Documents

+

A YAML stream consists of one or more documents starting with --- and +optionally ending with ... . If there is only one document, --- can be +left out.

+

Single document with no explicit start or end:

+
- Red
+- Green
+- Blue
+
+
+

Same document with explicit start and end:

+
---
+- Red
+- Green
+- Blue
+...
+
+
+

A stream containing multiple documents:

+
---
+- Red
+- Green
+- Blue
+---
+- Linux
+- BSD
+---
+answer : 42
+
+
+
+
+

Sequences

+

Sequences are arrays of nodes of any type, similar e.g. to Python lists. +In block context, each item begins with hyphen+space “- “. In flow context, +sequences have syntax similar to D arrays.

+
#Block context
+- Red
+- Green
+- Blue
+
+
+
#Flow context
+[Red, Green, Blue]
+
+
+
#Nested
+-
+  - Red
+  - Green
+  - Blue
+-
+  - Linux
+  - BSD
+
+
+
#Nested flow
+[[Red, Green, Blue], [Linux, BSD]]
+
+
+
#Nested in a mapping
+Colors:
+  - Red
+  - Green
+  - Blue
+Operating systems:
+  - Linux
+  - BSD
+
+
+
+
+

Mappings

+

Mappings are associative arrays where each key and value can be of any type, +similar e.g. to Python dictionaries. In block context, keys and values are +separated by colon+space “: “. In flow context, mappings have syntax similar +to D associative arrays, but with braces instead of brackets:

+
#Block context
+CPU: Athlon
+GPU: Radeon
+OS: Linux
+
+
+
#Flow context
+{CPU: Athlon, GPU: Radeon, OS: Linux}
+
+
+
#Nested
+PC:
+  CPU: Athlon
+  GPU: Radeon
+  OS: Debian
+Phone:
+  CPU: Cortex
+  GPU: PowerVR
+  OS: Android
+
+
+
#Nested flow
+{PC: {CPU: Athlon, GPU: Radeon, OS: Debian},
+ Phone: {CPU: Cortex, GPU: PowerVR, OS: Android}}
+
+
+
#Nested in a sequence
+- CPU: Athlon
+  GPU: Radeon
+  OS: Debian
+- CPU: Cortex
+  GPU: PowerVR
+  OS: Android
+
+
+

Complex keys start with question mark+space “? “.

+
#Nested in a sequence
+? [CPU, GPU]: [Athlon, Radeon]
+OS: Debian
+
+
+
+
+

Scalars

+

Scalars are simple values such as integers, strings, timestamps and so on. +There are multiple scalar styles.

+

Plain scalars use no quotes, start with the first non-space and end with the +last non-space character:

+
scalar: Plain scalar
+
+
+

Single quoted scalars start and end with single quotes. A single quote is +represented by a pair of single quotes ‘’.

+
scalar: 'Single quoted scalar ending with some spaces    '
+
+
+

Double quoted scalars support C-style escape sequences.

+
scalar: "Double quoted scalar \n with some \\ escape sequences"
+
+
+

Block scalars are convenient for multi-line values. They start either with +| or with >. With |, the newlines in the scalar are preserved. +With >, the newlines between two non-empty lines are removed.

+
scalar: |
+  Newlines are preserved
+  First line
+  Second line
+
+
+
scalar: >
+  Newlines are folded
+  This is still the first paragraph
+
+  This is the second
+  paragraph
+
+
+
+
+

Anchors and aliases

+

Anchors and aliases can reduce size of YAML code by allowing you to define a +value once, assign an anchor to it and use alias referring to that anchor +anywhere else you need that value. It is possible to use this to create +recursive data structures and some parsers support this; however, D:YAML does +not (this might change in the future, but it is unlikely).

+
Person: &AD
+  gender: male
+  name: Arthur Dent
+Clone: *AD
+
+
+
+
+

Tags

+

Tags are identifiers that specify data types of YAML nodes. Most default YAML +tags are resolved implicitly, so there is no need to specify them. D:YAML also +supports implicit resolution for custom, user specified tags.

+

Explicitly specified tags:

+
answer: !!int "42"
+name:   !!str "Arthur Dent"
+
+
+

Implicit tags:

+
answer: 42        #int
+name: Arthur Dent #string
+
+
+

This table shows D types stored in yaml.Node default YAML tags are converted to. +Some of these might change in the future (especially !!map and !!set).

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
YAML tagD type
!!nullyaml.YAMLNull
!!boolbool
!!intlong
!!floatreal
!!binaryubyte[]
!!timestampdatetime.SysTime
!!map, !!omap, !!pairsNode.Pair[]
!!seq, !!setNode[]
!!strstring
+
+
+ + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/docsrc/Makefile b/docsrc/Makefile new file mode 100644 index 0000000..0d810db --- /dev/null +++ b/docsrc/Makefile @@ -0,0 +1,139 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = ../doc + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean ddoc_html html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +################################################################################ +# DDOC GENERATION CODE +################################################################################ +ddoc_html : + cd ../ && ./autoddoc.py +################################################################################ +# DDOC GENERATION CODE END +################################################################################ + +html: ddoc_html + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DYAML.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DYAML.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/DYAML" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/DYAML" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + make -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docsrc/articles/spec_differences.rst b/docsrc/articles/spec_differences.rst new file mode 100644 index 0000000..c864fb5 --- /dev/null +++ b/docsrc/articles/spec_differences.rst @@ -0,0 +1,65 @@ +.. highlight:: yaml + +===================================================== +Differences between D:YAML and the YAML specification +===================================================== + +There are some differences between D:YAML and the YAML 1.1 specification. Some +are caused by difficulty of implementation of some features, such as multiple +Unicode encodings within single stream, and some by unnecessary restrictions or +ambiguities in the specification. + +Still, D:YAML tries to be as close to the specification as possible. D:YAML should +never load documents with different meaning than according to the specification, +and documents that fail to load should be very rare (for instance, very few +files use multiple Unicode encodings). + + +-------------------------- +List of known differences: +-------------------------- + +Differences that can cause valid YAML documents not to load: + +* At the moment, all mappings in the internal representation are ordered, + and a comparison for equality between equal mappings with differing order + will return false. This will be fixed once Phobos has a usable map type or + D associative arrays work with variants. +* No support for byte order marks and multiple Unicode encodings in a stream. +* Plain scalars in flow context cannot contain ``,``, ``:`` and ``?``. + This might change with ``:`` in the future. + See http://pyyaml.org/wiki/YAMLColonInFlowContext for details. +* The specification does not restrict characters for anchors and + aliases. This may lead to problems, for instance, the document:: + + [ *alias, value ] + + can be interpteted in two ways, as:: + + [ "value" ] + + and:: + + [ *alias , "value" ] + + Therefore we restrict aliases and anchors to ASCII alphanumeric characters. +* The specification is confusing about tabs in plain scalars. We don't use tabs + in plain scalars at all. +* There is no support for recursive data structures in DYAML. + +Other differences: + +* Indentation is ignored in the flow context, which is less restrictive than the + specification. This allows code such as:: + + key: { + } + +* Indentation rules for quoted scalars are loosed: They don't need to adhere + indentation as ``"`` and ``'`` clearly mark the beginning and the end of them. +* We allow ``_`` in tag handles. +* Right now, two mappings with the same contents but different orderings are + considered unequal, even if they are unordered mappings. This is because all + mappings are ordered in the D:YAML implementation. This should change in + future, once D associative arrays work with variant types or a map class or + struct appears in Phobos. diff --git a/docsrc/autoddoc_index.dd b/docsrc/autoddoc_index.dd new file mode 100644 index 0000000..0d414fb --- /dev/null +++ b/docsrc/autoddoc_index.dd @@ -0,0 +1,19 @@ +Ddoc + +$(P +This is the complete API documentation for D:YAML. It describes all classes, +methods and global functions provided by the library. This is not the best place +to start learning how to use D:YAML. Rather, it should serve as a reference when +you need detailed information about every bit of D:YAML functionality. You can +find more introductory material in D:YAML $(LINK2 ../index.html, tutorials). +) + +$(P +In this API documentation, each D:YAML module is documented separately. However, +to use D:YAML, you don't need to import these modules. All you need to do is +import the $(I yaml) module, which will import all needed modules. +) + +Macros: + TITLE=$(PROJECT_NAME) $(PROJECT_VERSION) API documentation + diff --git a/docsrc/conf.py b/docsrc/conf.py new file mode 100644 index 0000000..30ac5d6 --- /dev/null +++ b/docsrc/conf.py @@ -0,0 +1,236 @@ +# -*- coding: utf-8 -*- +# +# D:YAML documentation build configuration file, created by +# sphinx-quickstart on Sun Jul 24 15:16:35 2011. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'D:YAML' +copyright = (u'2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org ' + 'by Kirill Simonov') + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.1' +# The full version, including alpha/beta/rc tags. +release = '0.1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options =\ +{ + "footerbgcolor" : "#1f252b", + "footertextcolor" : "#ccc", + "sidebarbgcolor" : "#1f252b", + "sidebarlinkcolor" : "#ddd", + "relbarbgcolor" : "#303333", + "relbartextcolor" : "#ccc", + "bgcolor" : "#f6f6f6", + "textcolor" : "black", + "linkcolor" : "#006", + "visitedlinkcolor" : "#606", + "headbgcolor" : "#f6f6f6", + "headtextcolor" : "#633", + "headlinkcolor" : "#006", + "codebgcolor" : "fcfcfc", + "codetextcolor" : "000066", + "bodyfont" : "Verdana, \"Deja Vu\", \"Bitstream Vera Sans\", sans-serif", + "headfont" : "Georgia, \"Times New Roman\", Times, serif" +} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +html_logo = "logo210.png" + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +html_sidebars = {"**" : ["localtoc.html"]} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +html_domain_indices = False + +# If false, no index is generated. +html_use_index = False + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'DYAMLdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'DYAML.tex', u'D:YAML Documentation', + u'Ferdinand Majerech', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'dyaml', u'D:YAML Documentation', + [u'Ferdinand Majerech'], 1) +] diff --git a/docsrc/index.rst b/docsrc/index.rst new file mode 100644 index 0000000..eed7bc6 --- /dev/null +++ b/docsrc/index.rst @@ -0,0 +1,21 @@ +================================ +Welcome to D:YAML documentation! +================================ + +`API Documentation `_ + +Tutorials: + +.. toctree:: + :maxdepth: 2 + + tutorials/getting_started + tutorials/custom_types + tutorials/yaml_syntax + +Articles: + +.. toctree:: + :maxdepth: 2 + + articles/spec_differences diff --git a/docsrc/logo128.png b/docsrc/logo128.png new file mode 100644 index 0000000000000000000000000000000000000000..f00ae05fca2f3591d0fe42591444df69b205768a GIT binary patch literal 2812 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 V;5$Fq2(Xkux|&8BU)3C9{{xEKa&Z6v literal 0 HcmV?d00001 diff --git a/docsrc/tutorials/custom_types.rst b/docsrc/tutorials/custom_types.rst new file mode 100644 index 0000000..ff6f3c8 --- /dev/null +++ b/docsrc/tutorials/custom_types.rst @@ -0,0 +1,227 @@ +====================== +Custom YAML data types +====================== + +Often you will want to serialize complex data types such as classes. You can use +functions to process nodes; e.g. a mapping containing class data members indexed +by name. Alternatively, YAML supports custom data types using identifiers called +*tags*. That is the topic of this tutorial. + +Each YAML node has a tag specifying its type. For instance: strings use the tag +``tag:yaml.org,2002:str``. Tags of most default types are *implicitly resolved* +during parsing, so you don't need to specify tag for each float, integer, etc. +It is also possible to implicitly resolve custom tags, as we will show later. + + +----------- +Constructor +----------- + +D:YAML uses the *Constructor* class to process each node to hold data type +corresponding to its tag. *Constructor* stores a function for each supported +tag to process it. These functions can be supplied by the user using the +*addConstructor()* method. *Constructor* is then passed to *Loader*, which will +parse YAML input. + +We will implement support for an RGB color type. It is implemented as the +following struct: + +.. code-block:: d + + struct Color + { + ubyte red; + ubyte green; + ubyte blue; + } + +First, we need a function to construct our data type. It must take two *Mark* +structs, which store position of the node in the file, and either a *string*, an +array of *Node* or of *Node.Pair*, depending on whether we're constructing our +value from a scalar, sequence, or mapping, respectively. In this tutorial, we +have functions to construct a color from a scalar, using HTML-like format, +RRGGBB, or from a mapping, where we use the following format: +{r:RRR, g:GGG, b:BBB} . Code of these functions: + +.. code-block:: d + + Color constructColorScalar(Mark start, Mark end, string value) + { + if(value.length != 6) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + //We don't need to check for uppercase chars this way. + value = value.toLower(); + + //Get value of a hex digit. + uint hex(char c) + { + if(!std.ascii.isHexDigit(c)) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + + if(std.ascii.isDigit(c)) + { + return c - '0'; + } + return c - 'a' + 10; + } + + Color result; + result.red = cast(ubyte)(16 * hex(value[0]) + hex(value[1])); + result.green = cast(ubyte)(16 * hex(value[2]) + hex(value[3])); + result.blue = cast(ubyte)(16 * hex(value[4]) + hex(value[5])); + + return result; + } + + Color constructColorMapping(Mark start, Mark end, Node.Pair[] pairs) + { + int r, g, b; + r = g = b = -1; + bool error = pairs.length != 3; + + foreach(ref pair; pairs) + { + //Key might not be a string, and value might not be an int, + //so we need to check for that + try + { + switch(pair.key.get!string) + { + case "r": r = pair.value.get!int; break; + case "g": g = pair.value.get!int; break; + case "b": b = pair.value.get!int; break; + default: error = true; + } + } + catch(NodeException e) + { + error = true; + } + } + + if(error || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) + { + throw new ConstructorException("Invalid color", start, end); + } + + return Color(cast(ubyte)r, cast(ubyte)g, cast(ubyte)b); + } + +Next, we need some YAML code using our new tag. Create a file called input.yaml +with the following contents: + +.. code-block:: yaml + + scalar-red: !color FF0000 + scalar-orange: !color FFFF00 + mapping-red: !color-mapping {r: 255, g: 0, b: 0} + mapping-orange: + !color-mapping + r: 255 + g: 255 + b: 0 + +You can see that we're using tag ``!color`` for scalar colors, and +``!color-mapping`` for colors expressed as mappings. + +Finally, the code to put it all together: + +.. code-block:: d + + void main() + { + auto red = Color(255, 0, 0); + auto orange = Color(255, 255, 0); + + try + { + auto constructor = new Constructor; + //both functions handle the same tag, but one handles scalar, one mapping. + constructor.addConstructor("!color", &constructColorScalar); + constructor.addConstructor("!color-mapping", &constructColorMapping); + + auto loader = new Loader("input.yaml", constructor, new Resolver); + + auto root = loader.loadSingleDocument(); + + if(root["scalar-red"].get!Color == red && + root["mapping-red"].get!Color == red && + root["scalar-orange"].get!Color == orange && + root["mapping-orange"].get!Color == orange) + { + writeln("SUCCESS"); + return; + } + } + catch(YAMLException e) + { + writeln(e.msg); + } + + writeln("FAILURE"); + } + +First, we create a *Constructor* and pass functions to handle the ``!color`` +and ``!color-mapping`` tag. We construct a *Loader* using the *Constructor*. +We also need a *Resolver*, but for now we just default-construct it. We then +load the YAML document, and finally, read the colors using *get()* method to +test if they were loaded as expected. + +You can find the source code for what we've done so far in the +``examples/constructor`` directory in the D:YAML package. + + +-------- +Resolver +-------- + +Specifying tag for every color value can be tedious. D:YAML can implicitly +resolve tag of a scalar using a regular expression. This is how default types, +e.g. int, are resolved. We will use the *Resolver* class to add implicit tag +resolution for the Color data type (in its scalar form). + +We use the *addImplicitResolver* method of *Resolver*, passing the tag, regular +expression the value must match to resolve to this tag, and a string of possible +starting characters of the value. Then we pass the *Resolver* to the constructor +of *Loader*. + +Note that resolvers added first override ones added later. If no resolver +matches a scalar, YAML string tag is used. Therefore our custom values must not +be resolvable as any non-string YAML data type. + +Add this to your code to add implicit resolution of ``!color``. + +.. code-block:: d + + //code from the previous example... + + auto resolver = new Resolver; + resolver.addImplicitResolver("!color", std.regex.regex("[0-9a-fA-F]{6}", + "0123456789abcdefABCDEF")); + + auto loader = new Loader("input.yaml", constructor, resolver); + + //code from the previous example... + +Now, change contents of input.dyaml to this: + +.. code-block:: yaml + + scalar-red: FF0000 + scalar-orange: FFFF00 + mapping-red: !color-mapping {r: 255, g: 0, b: 0} + mapping-orange: + !color-mapping + r: 255 + g: 255 + b: 0 + +We no longer need to specify the tag for scalar color values. Compile and test +the example. If everything went as expected, it should report success. + +You can find the complete code in the ``examples/resolver`` directory in the +D:YAML package. diff --git a/docsrc/tutorials/getting_started.rst b/docsrc/tutorials/getting_started.rst new file mode 100644 index 0000000..1cf6cff --- /dev/null +++ b/docsrc/tutorials/getting_started.rst @@ -0,0 +1,168 @@ +=============== +Getting started +=============== + +Welcome to D:YAML! D:YAML is a `YAML `_ parser +library for the `D programming language `_. This tutorial will +explain how to set D:YAML up and use it in your projects. + +This is meant to be the **simplest possible** introduction to D:YAML. Some of the +information present might already be known to you. Only basic usage is covered. +More advanced usage is described in other tutorials. + + +---------- +Setting up +---------- + +^^^^^^^^^^^^^^^^^^^^^^^^ +Install the DMD compiler +^^^^^^^^^^^^^^^^^^^^^^^^ + +Digital Mars D compiler, or DMD, is the most commonly used D compiler. You can +find its newest version `here `_. +Download the version of DMD for your operating system and install it. + +.. note:: + Other D compilers exist, such as + `GDC `_ and + `LDC `_. + Setting up with either one of them should be similar to DMD, + however, at the moment they are not as up to date as DMD. + + +^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Download and compile D:YAML +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The newest version of D:YAML can be found `here `_. Download a source +archive, extract it, and move to the extracted directory. + +D:YAML uses a modified version of the `CDC `_ +script for compilation. To compile D:YAML, you first need to build CDC. +Do this by typing the following command into the console:: + + dmd cdc.d + +Now you can use CDC to compile D:YAML. +To do this on Unix/Linux, use the following command:: + + ./cdc + +On Windows:: + + cdc.exe + +This will compile the library to a file called ``libdyaml.a`` on Unix/Linux or +``libdyaml.lib`` on Windows. + + +------------------------- +Your first D:YAML project +------------------------- + +Create a directory for your project and in that directory, create a file called +``input.yaml`` with the following contents: + +.. code-block:: yaml + + Hello World : + - Hello + - World + Answer: 42 + +This will serve as input for our example. + +Now we need to parse it. Create a file called "main.d". Paste following code +into the file: + +.. code-block:: d + + import std.stdio; + import yaml; + + void main() + { + yaml.Node root = yaml.load("input.yaml"); + foreach(string word; root["Hello World"]) + { + writeln(word); + } + writeln("The answer is ", root["Answer"].get!int); + } + + +^^^^^^^^^^^^^^^^^^^^^^^ +Explanation of the code +^^^^^^^^^^^^^^^^^^^^^^^ + +First, we import the *yaml* module. This is the only module you need to import +to use D:YAML - it automatically imports all needed modules. + +Next we load the file using the *yaml.load()* function - this loads the file as +**one** YAML document and throws *YAMLException*, D:YAML exception type, if the +file could not be parsed or does not contain exactly one document. Note that we +don't do any error checking here in order to keep the example as simple as +possible. + +*yaml.Node* represents a node in a YAML document. It can be a sequence (array), +mapping (associative array) or a scalar (value). Here the root node is a +mapping, and we use the index operator to get subnodes with keys "Hello World" +and "Answer". We iterate over the first, as it is a sequence, and use the +*yaml.Node.get()* method on the second to get its value as an integer. + +You can iterate over a mapping or sequence as if it was an associative or normal +array. If you try to iterate over a scalar, it will throw a *YAMLException*. + +You can iterate over subnodes using yaml.Node as the iterated type, or specify +the type subnodes are expected to have. D:YAML will automatically convert +iterated subnodes to that type if possible. Here we specify the *string* type, +so we iterate over the "Hello World" sequence as an array of strings. If it is +not possible to convert to iterated type, a *YAMLException* is thrown. For +instance, if we specified *int* here, we would get an error, as "Hello" +cannot be converted to an integer. + +The *yaml.Node.get()* method is used to get value of a scalar node as specified +type. D:YAML will try to return the scalar as specified type, converting if +needed, throwing *YAMLException* if not possible. + + +^^^^^^^^^ +Compiling +^^^^^^^^^ + +To compile your project, you must give DMD the directories containing import +modules and the library. You also need to tell it to link with D:YAML. The import +directory should be the D:YAML package directory. You can specify it using the +``-I`` option of DMD. The library directory should point to where you put the +compiled D:YAML library. On Unix/Linux you can specify it using the ``-L-L`` +option, and link with D:YAML using the ``-L-l`` option. On Windows, the import +directory is used as the library directory. To link with the library on Windows, +just add the path to it relative to the current directory. + +For example, if you extracted D:YAML to ``/home/xxx/dyaml`` and compiled it in +that directory, your project is in ``/home/xxx/dyaml-project``, and you are +currently in that directory, you can compile the project with the following +command on Unix/Linux:: + + dmd -I../dyaml -L-L../dyaml -L-ldyaml main.d + +And the following on Windows:: + + dmd -I../dyaml ../dyaml/libdyaml.lib main.d + +This will produce an executable called ``main`` or ``main.exe`` in your +directory. When you run it, it should produce the following output:: + + Hello + World + The answer is 42 + + +^^^^^^^^^^ +Conclusion +^^^^^^^^^^ + +You should now have a basic idea about how to use D:YAML. To learn more, look at +the `API documentation <../api/index.html>`_ and other tutorials. You can find code for this +example in the ``example/getting_started`` directory in the package. diff --git a/docsrc/tutorials/yaml_syntax.rst b/docsrc/tutorials/yaml_syntax.rst new file mode 100644 index 0000000..09fe3af --- /dev/null +++ b/docsrc/tutorials/yaml_syntax.rst @@ -0,0 +1,273 @@ +=========== +YAML syntax +=========== + +This is an introduction to the most common YAML constructs. For more detailed +information, see `PyYAML documentation `_, +which this article is based on, +`Chapter 2 of the YAML specification `_ +or the `Wikipedia page `_. + +YAML is a data serialization format designed to be as human readable as +possible. YAML is a recursive acronym for "YAML Ain't Markup Language". + +YAML is similar to JSON, and in fact, JSON is a subset of YAML 1.2; but YAML has +some more advanced features and is easier to read. However, YAML is also more +difficult to parse (and probably somewhat slower). Data is stored in mappings +(associative arrays), sequences (lists) and scalars (single values). Data +structure hierarchy either depends on indentation (block context, similar to +Python code), or nesting of brackets and braces (flow context, similar to JSON). +YAML comments begin with ``#`` and continue until the end of line. + + +--------- +Documents +--------- + +A YAML stream consists of one or more documents starting with ``---`` and +optionally ending with ``...`` . If there is only one document, ``---`` can be +left out. + +Single document with no explicit start or end: + +.. code-block:: yaml + + - Red + - Green + - Blue + +Same document with explicit start and end: + +.. code-block:: yaml + + --- + - Red + - Green + - Blue + ... + +A stream containing multiple documents: + +.. code-block:: yaml + + --- + - Red + - Green + - Blue + --- + - Linux + - BSD + --- + answer : 42 + + +--------- +Sequences +--------- + +Sequences are arrays of nodes of any type, similar e.g. to Python lists. +In block context, each item begins with hyphen+space "- ". In flow context, +sequences have syntax similar to D arrays. + +.. code-block:: yaml + + #Block context + - Red + - Green + - Blue + +.. code-block:: yaml + + #Flow context + [Red, Green, Blue] + +.. code-block:: yaml + + #Nested + - + - Red + - Green + - Blue + - + - Linux + - BSD + +.. code-block:: yaml + + #Nested flow + [[Red, Green, Blue], [Linux, BSD]] + +.. code-block:: yaml + + #Nested in a mapping + Colors: + - Red + - Green + - Blue + Operating systems: + - Linux + - BSD + + +-------- +Mappings +-------- + +Mappings are associative arrays where each key and value can be of any type, +similar e.g. to Python dictionaries. In block context, keys and values are +separated by colon+space ": ". In flow context, mappings have syntax similar +to D associative arrays, but with braces instead of brackets: + +.. code-block:: yaml + + #Block context + CPU: Athlon + GPU: Radeon + OS: Linux + +.. code-block:: yaml + + #Flow context + {CPU: Athlon, GPU: Radeon, OS: Linux} + +.. code-block:: yaml + + #Nested + PC: + CPU: Athlon + GPU: Radeon + OS: Debian + Phone: + CPU: Cortex + GPU: PowerVR + OS: Android + +.. code-block:: yaml + + #Nested flow + {PC: {CPU: Athlon, GPU: Radeon, OS: Debian}, + Phone: {CPU: Cortex, GPU: PowerVR, OS: Android}} + +.. code-block:: yaml + + #Nested in a sequence + - CPU: Athlon + GPU: Radeon + OS: Debian + - CPU: Cortex + GPU: PowerVR + OS: Android + +Complex keys start with question mark+space "? ". + +.. code-block:: yaml + + #Nested in a sequence + ? [CPU, GPU]: [Athlon, Radeon] + OS: Debian + + +------- +Scalars +------- + +Scalars are simple values such as integers, strings, timestamps and so on. +There are multiple scalar styles. + +Plain scalars use no quotes, start with the first non-space and end with the +last non-space character: + +.. code-block:: yaml + + scalar: Plain scalar + +Single quoted scalars start and end with single quotes. A single quote is +represented by a pair of single quotes ''. + +.. code-block:: yaml + + scalar: 'Single quoted scalar ending with some spaces ' + +Double quoted scalars support C-style escape sequences. + +.. code-block:: yaml + + scalar: "Double quoted scalar \n with some \\ escape sequences" + +Block scalars are convenient for multi-line values. They start either with +``|`` or with ``>``. With ``|``, the newlines in the scalar are preserved. +With ``>``, the newlines between two non-empty lines are removed. + +.. code-block:: yaml + + scalar: | + Newlines are preserved + First line + Second line + +.. code-block:: yaml + + scalar: > + Newlines are folded + This is still the first paragraph + + This is the second + paragraph + + +------------------- +Anchors and aliases +------------------- + +Anchors and aliases can reduce size of YAML code by allowing you to define a +value once, assign an anchor to it and use alias referring to that anchor +anywhere else you need that value. It is possible to use this to create +recursive data structures and some parsers support this; however, D:YAML does +not (this might change in the future, but it is unlikely). + +.. code-block:: yaml + + Person: &AD + gender: male + name: Arthur Dent + Clone: *AD + + +---- +Tags +---- + +Tags are identifiers that specify data types of YAML nodes. Most default YAML +tags are resolved implicitly, so there is no need to specify them. D:YAML also +supports implicit resolution for custom, user specified tags. + +Explicitly specified tags: + +.. code-block:: yaml + + answer: !!int "42" + name: !!str "Arthur Dent" + +Implicit tags: + +.. code-block:: yaml + + answer: 42 #int + name: Arthur Dent #string + +This table shows D types stored in *yaml.Node* default YAML tags are converted to. +Some of these might change in the future (especially !!map and !!set). + +====================== ================ +YAML tag D type +====================== ================ +!!null yaml.YAMLNull +!!bool bool +!!int long +!!float real +!!binary ubyte[] +!!timestamp datetime.SysTime +!!map, !!omap, !!pairs Node.Pair[] +!!seq, !!set Node[] +!!str string +====================== ================ diff --git a/dyaml/composer.d b/dyaml/composer.d new file mode 100644 index 0000000..36d701a --- /dev/null +++ b/dyaml/composer.d @@ -0,0 +1,324 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * Composes nodes from YAML events provided by parser. + * Code based on PyYAML: http://www.pyyaml.org + */ +module dyaml.composer; + + +import std.conv; +import std.exception; +import std.typecons; + +import dyaml.constructor; +import dyaml.event; +import dyaml.node; +import dyaml.parser; +import dyaml.resolver; +import dyaml.exception; + + +package: +/** + * Marked exception thrown at composer errors. + * + * See_Also: MarkedYAMLException + */ +class ComposerException : MarkedYAMLException +{ + this(string context, Mark contextMark, string problem, Mark problemMark) + { + super(context, contextMark, problem, problemMark); + } + + this(string problem, Mark problemMark){super(problem, problemMark);} +} + +///Composes YAML documents from events provided by a Parser. +final class Composer +{ + private: + ///Parser providing YAML events. + Parser parser_; + ///Resolver resolving tags (data types). + Resolver resolver_; + ///Constructor constructing YAML values. + Constructor constructor_; + ///Nodes associated with anchors. Used by YAML aliases. + Node[string] anchors_; + + public: + /** + * Construct a composer. + * + * Params: parser = Parser to provide YAML events. + * resolver = Resolver to resolve tags (data types). + * constructor = Constructor to construct nodes. + */ + this(Parser parser, Resolver resolver, Constructor constructor) + { + parser_ = parser; + resolver_ = resolver; + constructor_ = constructor; + } + + ///Destroy the composer. + ~this() + { + parser_ = null; + resolver_ = null; + constructor_ = null; + clear(anchors_); + anchors_ = null; + } + + /** + * Determine if there are any nodes left. + * + * Must be called before loading as it handles the stream start event. + */ + bool checkNode() + { + //Drop the STREAM-START event. + if(parser_.checkEvent(EventID.StreamStart)) + { + parser_.getEvent(); + } + + //True if there are more documents available. + return !parser_.checkEvent(EventID.StreamEnd); + } + + ///Get a YAML document as a node (the root of the document). + Node getNode() + { + //Get the root node of the next document. + assert(!parser_.checkEvent(EventID.StreamEnd), + "Trying to get a node from Composer when there is no node to " + "get. use checkNode() to determine if there is a node."); + + return composeDocument(); + } + + ///Get single YAML document, throwing if there is more than one document. + Node getSingleNode() + { + assert(!parser_.checkEvent(EventID.StreamEnd), + "Trying to get a node from Composer when there is no node to " + "get. use checkNode() to determine if there is a node."); + + Node document = composeDocument(); + + //Ensure that the stream contains no more documents. + enforce(parser_.checkEvent(EventID.StreamEnd), + new ComposerException("Expected single document in the stream, " + "but found another document: ", + parser_.getEvent().startMark)); + + //Drop the STREAM-END event. + parser_.getEvent(); + + return document; + } + + private: + ///Compose a YAML document and return its root node. + Node composeDocument() + { + //Drop the DOCUMENT-START event. + parser_.getEvent(); + + //Compose the root node. + Node node = composeNode(); + + //Drop the DOCUMENT-END event. + parser_.getEvent(); + + //Clear anchors. + Node[string] empty; + anchors_ = empty; + return node; + } + + ///Compose a node. + Node composeNode() + { + if(parser_.checkEvent(EventID.Alias)) + { + Event event = parser_.getEvent(); + const anchor = event.anchor; + enforce((anchor in anchors_) !is null, + new ComposerException("Found undefined alias: " ~ anchor, + event.startMark)); + + //If the node referenced by the anchor is uninitialized, + //it's not finished, i.e. we're currently composing it + //and trying to use it recursively here. + enforce(anchors_[anchor] != Node(), + new ComposerException("Found recursive alias: " ~ anchor, + event.startMark)); + return anchors_[anchor]; + } + + Event event = parser_.peekEvent(); + const anchor = event.anchor; + if(anchor !is null && (anchor in anchors_) !is null) + { + throw new ComposerException("Found duplicate anchor: " ~ anchor, + event.startMark); + } + + Node result; + //Associate the anchor, if any, with an uninitialized node. + //used to detect duplicate and recursive anchors. + if(anchor !is null){anchors_[anchor] = Node();} + + if(parser_.checkEvent(EventID.Scalar)) + { + result = composeScalarNode(); + } + else if(parser_.checkEvent(EventID.SequenceStart)) + { + result = composeSequenceNode(); + } + else if(parser_.checkEvent(EventID.MappingStart)) + { + result = composeMappingNode(); + } + else{assert(false, "This code should never be reached");} + + if(anchor !is null){anchors_[anchor] = result;} + return result; + } + + ///Compose a scalar node. + Node composeScalarNode() + { + Event event = parser_.getEvent(); + const tag = resolver_.resolve(NodeID.Scalar, event.tag, event.value, + event.implicit); + + Node node = constructor_.node(event.startMark, event.endMark, tag, + event.value); + + return node; + } + + ///Compose a sequence node. + Node composeSequenceNode() + { + Event startEvent = parser_.getEvent(); + const tag = resolver_.resolve(NodeID.Sequence, startEvent.tag, null, + startEvent.implicit); + + Node[] children; + while(!parser_.checkEvent(EventID.SequenceEnd)) + { + children ~= composeNode(); + } + + Node node = constructor_.node(startEvent.startMark, parser_.getEvent().endMark, + tag, children); + + return node; + } + + /** + * Flatten a node, merging it with nodes referenced through YAMLMerge data type. + * + * Node must be a mapping or a sequence of mappings. + * + * Params: root = Node to flatten. + * startMark = Start position of the node. + * endMark = End position of the node. + * + * Returns: Flattened mapping as pairs. + */ + Node.Pair[] flatten(ref Node root, in Mark startMark, in Mark endMark) + { + Node.Pair[] result; + + if(root.isMapping) + { + Node[] toMerge; + foreach(ref Node key, ref Node value; root) + { + if(key.isType!YAMLMerge){toMerge ~= value;} + else{merge(result, Node.Pair(key, value));} + } + foreach(node; toMerge) + { + merge(result, flatten(node, startMark, endMark)); + } + } + else if(root.isSequence) + { + //Must be a sequence of mappings. + foreach(ref Node node; root) + { + //this is Composer, but the code is related to constructor + enforce(node.isType!(Node.Pair[]), + new ConstructorException("While constructing a mapping, " ~ + "expected a mapping for merging, but found" + ~ node.value_.type.toString() ~ + "NOTE: line/column shows topmost parent " + "to which the content is being merged", + startMark, endMark)); + merge(result, flatten(node, startMark, endMark)); + } + } + else + { + //this is Composer, but the code is related to constructor + throw new ConstructorException("While constructing a mapping, " ~ + "expected a mapping or a list of mappings for " + "merging, but found: " + ~ root.value_.type.toString() ~ + "NOTE: line/column shows topmost parent " + "to which the content is being merged", + startMark, endMark); + } + + return result; + } + + ///Compose a mapping node. + Node composeMappingNode() + { + Event startEvent = parser_.getEvent(); + string tag = resolver_.resolve(NodeID.Mapping, startEvent.tag, null, + startEvent.implicit); + + Node.Pair[] children; + Tuple!(Node, Mark)[] toMerge; + while(!parser_.checkEvent(EventID.MappingEnd)) + { + auto pair = Node.Pair(composeNode(), composeNode()); + + //Need to flatten and merge the node referred by YAMLMerge. + if(pair.key.isType!YAMLMerge) + { + toMerge ~= tuple(pair.value, cast(Mark)parser_.peekEvent().endMark); + } + //Not YAMLMerge, just add the pair. + else + { + merge(children, pair); + } + } + foreach(node; toMerge) + { + merge(children, flatten(node[0], startEvent.startMark, node[1])); + } + + Node node = constructor_.node(startEvent.startMark, parser_.getEvent().endMark, + tag, children); + + return node; + } +} diff --git a/dyaml/constructor.d b/dyaml/constructor.d new file mode 100644 index 0000000..55df342 --- /dev/null +++ b/dyaml/constructor.d @@ -0,0 +1,683 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * Implements a class that processes YAML mappings, sequences and scalars into + * nodes. This can be used to implement custom data types. A tutorial can be + * found $(LINK2 ../tutorials/custom_types.html, here). + */ +module dyaml.constructor; + + +import std.array; +import std.algorithm; +import std.base64; +import std.conv; +import std.datetime; +import std.exception; +import std.stdio; +import std.regex; +import std.string; +import std.utf; + +import dyaml.node; +import dyaml.exception; +import dyaml.token; + + +/** + * Exception thrown at constructor errors. + * + * Can be thrown by custom constructor functions. + */ +class ConstructorException : YAMLException +{ + /** + * Construct a ConstructorException. + * + * Params: msg = Error message. + * start = Start position of the error context. + * end = End position of the error context. + */ + this(string msg, Mark start, Mark end) + { + super(msg ~ "\nstart:" ~ start.toString() ~ "\nend:" ~ end.toString()); + } +} + +/** + * Constructs YAML values. + * + * Each YAML scalar, sequence or mapping has a tag specifying its data type. + * Constructor uses user-specifyable functions to create a node of desired + * data type from a scalar, sequence or mapping. + * + * Each of these functions is associated with a tag, and can process either + * a scalar, a sequence, or a mapping. The constructor passes each value to + * the function with corresponding tag, which then returns the resulting value + * that can be stored in a node. + * + * If a tag is detected with no known constructor function, it is considered an error. + */ +final class Constructor +{ + private: + ///Constructor functions from scalars. + Node.Value delegate(Mark, Mark, string) [string] fromScalar_; + ///Constructor functions from sequences. + Node.Value delegate(Mark, Mark, Node[]) [string] fromSequence_; + ///Constructor functions from mappings. + Node.Value delegate (Mark, Mark, Node.Pair[])[string] fromMapping_; + + public: + /** + * Construct a Constructor. + * + * If you don't want to support default YAML tags/data types, you can use + * defaultConstructors to disable constructor functions for these. + * + * Params: defaultConstructors = Use constructors for default YAML tags? + */ + this(in bool defaultConstructors = true) + { + if(defaultConstructors) + { + addConstructor("tag:yaml.org,2002:null", &constructNull); + addConstructor("tag:yaml.org,2002:bool", &constructBool); + addConstructor("tag:yaml.org,2002:int", &constructLong); + addConstructor("tag:yaml.org,2002:float", &constructReal); + addConstructor("tag:yaml.org,2002:binary", &constructBinary); + addConstructor("tag:yaml.org,2002:timestamp", &constructTimestamp); + addConstructor("tag:yaml.org,2002:str", &constructString); + + ///In a mapping, the default value is kept as an entry with the '=' key. + addConstructor("tag:yaml.org,2002:value", &constructString); + + addConstructor("tag:yaml.org,2002:omap", &constructOrderedMap); + addConstructor("tag:yaml.org,2002:pairs", &constructPairs); + addConstructor("tag:yaml.org,2002:set", &constructSet); + addConstructor("tag:yaml.org,2002:seq", &constructSequence); + addConstructor("tag:yaml.org,2002:map", &constructMap); + addConstructor("tag:yaml.org,2002:merge", &constructMerge); + } + } + + ///Destroy the constructor. + ~this() + { + clear(fromScalar_); + fromScalar_ = null; + clear(fromSequence_); + fromSequence_ = null; + clear(fromMapping_); + fromMapping_ = null; + } + + /** + * Add a constructor function. + * + * The function passed must two Marks (determining start and end positions of + * the node in file) and either a string (if constructing from scalar), + * an array of Nodes (from sequence) or an array of Node.Pair (from mapping). + * The value returned by this function will be stored in the resulring node. + * + * Params: tag = Tag for the function to handle. + * ctor = Constructor function. + */ + void addConstructor(T, U)(in string tag, T function(Mark, Mark, U) ctor) + if(is(U == string) || is(U == Node[]) || is(U == Node.Pair[])) + { + Node.Value delegate(Mark, Mark, U) deleg; + + //Type that natively fits into Node.Value. + static if(Node.Value.allowed!T) + { + deleg = (Mark s, Mark e, U p){return Node.Value(ctor(s,e,p));}; + } + //User defined type. + else + { + deleg = (Mark s, Mark e, U p){return Node.userValue(ctor(s,e,p));}; + } + + assert((tag in fromScalar_) is null && + (tag in fromSequence_) is null && + (tag in fromMapping_) is null, + "Constructor function for tag " ~ tag ~ " is already " + "specified. Can't specify another one."); + + + static if(is(U == string)) + { + fromScalar_[tag] = deleg; + } + else static if(is(U == Node[])) + { + fromSequence_[tag] = deleg; + } + else static if(is(U == Node.Pair[])) + { + fromMapping_[tag] = deleg; + } + } + + package: + /* + * Construct a node from scalar. + * + * Params: start = Start position of the node. + * end = End position of the node. + * value = String value of the node. + * + * Returns: Constructed node. + */ + Node node(in Mark start, in Mark end, in string tag, string value) const + { + enforce((tag in fromScalar_) !is null, + new ConstructorException("Could not determine a constructor from " + "scalar for tag " ~ tag, start, end)); + return Node(fromScalar_[tag](start, end, value), start, end); + } + + /* + * Construct a node from sequence. + * + * Params: start = Start position of the node. + * end = End position of the node. + * value = Sequence to construct node from. + * + * Returns: Constructed node. + */ + Node node(in Mark start, in Mark end, in string tag, Node[] value) const + { + enforce((tag in fromSequence_) !is null, + new ConstructorException("Could not determine a constructor from " + "sequence for tag " ~ tag, start, end)); + return Node(fromSequence_[tag](start, end, value), start, end); + } + + /* + * Construct a node from mapping. + * + * Params: start = Start position of the node. + * end = End position of the node. + * value = Mapping to construct node from. + * + * Returns: Constructed node. + */ + Node node(in Mark start, in Mark end, in string tag, Node.Pair[] value) const + { + enforce((tag in fromMapping_) !is null, + new ConstructorException("Could not determine a constructor from " + "mapping for tag " ~ tag, start, end)); + return Node(fromMapping_[tag](start, end, value), start, end); + } +} + + +///Construct a null node. +YAMLNull constructNull(Mark start, Mark end, string value) +{ + return YAMLNull(); +} + +///Construct a merge node - a node that merges another node into a mapping. +YAMLMerge constructMerge(Mark start, Mark end, string value) +{ + return YAMLMerge(); +} + +///Construct a boolean node. +bool constructBool(Mark start, Mark end, string value) +{ + value = value.toLower(); + if(["yes", "true", "on"].canFind(value)) {return true;} + if(["no", "false", "off"].canFind(value)){return false;} + throw new ConstructorException("Unable to parse boolean value: " ~ value, start, end); +} + +///Construct an integer (long) node. +long constructLong(Mark start, Mark end, string value) +{ + value = value.replace("_", ""); + const char c = value[0]; + const long sign = c != '-' ? 1 : -1; + if(c == '-' || c == '+') + { + value = value[1 .. $]; + } + + enforce(value != "", new ConstructorException("Unable to parse float value: " ~ value, + start, end)); + + long result; + try + { + //Zero. + if(value == "0") {result = cast(long)0;} + //Binary. + else if(value.startsWith("0b")){result = sign * parse!int(value[2 .. $], 2);} + //Hexadecimal. + else if(value.startsWith("0x")){result = sign * parse!int(value[2 .. $], 16);} + //Octal. + else if(value[0] == '0') {result = sign * parse!int(value, 8);} + //Sexagesimal. + else if(value.canFind(":")) + { + long val = 0; + long base = 1; + foreach_reverse(digit; value.split(":")) + { + val += to!long(digit) * base; + base *= 60; + } + result = sign * val; + } + //Decimal. + else{result = sign * to!long(value);} + } + catch(ConvException e) + { + throw new ConstructorException("Unable to parse integer value: " ~ value, start, end); + } + + return result; +} +unittest +{ + long getLong(string str) + { + return constructLong(Mark(), Mark(), str); + } + + string canonical = "685230"; + string decimal = "+685_230"; + string octal = "02472256"; + string hexadecimal = "0x_0A_74_AE"; + string binary = "0b1010_0111_0100_1010_1110"; + string sexagesimal = "190:20:30"; + + assert(685230 == getLong(canonical)); + assert(685230 == getLong(decimal)); + assert(685230 == getLong(octal)); + assert(685230 == getLong(hexadecimal)); + assert(685230 == getLong(binary)); + assert(685230 == getLong(sexagesimal)); +} + +///Construct a floating point (real) node. +real constructReal(Mark start, Mark end, string value) +{ + value = value.replace("_", "").toLower(); + const char c = value[0]; + const real sign = c != '-' ? 1.0 : -1.0; + if(c == '-' || c == '+') + { + value = value[1 .. $]; + } + + enforce(value != "" && value != "nan" && value != "inf" && value != "-inf", + new ConstructorException("Unable to parse float value: " ~ value, start, end)); + + real result; + try + { + //Infinity. + if (value == ".inf"){result = sign * real.infinity;} + //Not a Number. + else if(value == ".nan"){result = real.nan;} + //Sexagesimal. + else if(value.canFind(":")) + { + real val = 0.0; + real base = 1.0; + foreach_reverse(digit; value.split(":")) + { + val += to!real(digit) * base; + base *= 60.0; + } + result = sign * val; + } + //Plain floating point. + else{result = sign * to!real(value);} + } + catch(ConvException e) + { + throw new ConstructorException("Unable to parse float value: " ~ value, start, end); + } + + return result; +} +unittest +{ + bool eq(real a, real b, real epsilon = 0.2) + { + return a >= (b - epsilon) && a <= (b + epsilon); + } + + real getReal(string str) + { + return constructReal(Mark(), Mark(), str); + } + + string canonical = "6.8523015e+5"; + string exponential = "685.230_15e+03"; + string fixed = "685_230.15"; + string sexagesimal = "190:20:30.15"; + string negativeInf = "-.inf"; + string NaN = ".NaN"; + + assert(eq(685230.15, getReal(canonical))); + assert(eq(685230.15, getReal(exponential))); + assert(eq(685230.15, getReal(fixed))); + assert(eq(685230.15, getReal(sexagesimal))); + assert(eq(-real.infinity, getReal(negativeInf))); + assert(to!string(getReal(NaN)) == "nan"); +} + +///Construct a binary (base64) node. +ubyte[] constructBinary(Mark start, Mark end, string value) +{ + //For an unknown reason, this must be nested to work (compiler bug?). + try + { + try{return Base64.decode(value.removechars("\n"));} + catch(Exception e) + { + throw new ConstructorException("Unable to decode base64 value: " ~ e.msg, start, + end); + } + } + catch(UtfException e) + { + throw new ConstructorException("Unable to decode base64 value: " ~ e.msg, start, end); + } +} +unittest +{ + ubyte[] test = cast(ubyte[])"The Answer: 42"; + char[] buffer; + buffer.length = 256; + string input = cast(string)Base64.encode(test, buffer); + auto value = constructBinary(Mark(), Mark(), input); + assert(value == test); +} + +///Construct a timestamp (SysTime) node. +SysTime constructTimestamp(Mark start, Mark end, string value) +{ + immutable YMDRegexp = regex("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)"); + immutable HMSRegexp = regex("^[Tt \t]+([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(\\.[0-9]*)?"); + immutable TZRegexp = regex("^[ \t]*Z|([-+][0-9][0-9]?)(:[0-9][0-9])?"); + + try + { + //First, get year, month and day. + auto matches = match(value, YMDRegexp); + + enforce(!matches.empty, new ConstructorException("Unable to parse timestamp value: " + ~ value, start, end)); + + auto captures = matches.front.captures; + const year = to!int(captures[1]); + const month = to!int(captures[2]); + const day = to!int(captures[3]); + + //If available, get hour, minute, second and fraction, if present. + value = matches.front.post; + matches = match(value, HMSRegexp); + if(matches.empty) + { + return SysTime(DateTime(year, month, day), UTC()); + } + + captures = matches.front.captures; + const hour = to!int(captures[1]); + const minute = to!int(captures[2]); + const second = to!int(captures[3]); + const hectonanosecond = cast(int)(to!real("0" ~ captures[4]) * 10000000); + + //If available, get timezone. + value = matches.front.post; + matches = match(value, TZRegexp); + if(matches.empty || matches.front.captures[0] == "Z") + { + return SysTime(DateTime(year, month, day, hour, minute, second), + FracSec.from!"hnsecs"(hectonanosecond), UTC()); + } + + captures = matches.front.captures; + int sign = 1; + int tzHours = 0; + if(!captures[1].empty) + { + if(captures[1][0] == '-'){sign = -1;} + tzHours = to!int(captures[1][1 .. $]); + } + const tzMinutes = (!captures[2].empty) ? to!int(captures[2][1 .. $]) : 0; + const tzOffset = sign * (60 * tzHours + tzMinutes); + + return SysTime(DateTime(year, month, day, hour, minute, second), + FracSec.from!"hnsecs"(hectonanosecond), + new SimpleTimeZone(tzOffset)); + } + catch(ConvException e) + { + throw new ConstructorException("Unable to parse timestamp value: " ~ value ~ + " Reason: " ~ e.msg, start, end); + } + catch(DateTimeException e) + { + throw new ConstructorException("Invalid timestamp value: " ~ value ~ + " Reason: " ~ e.msg, start, end); + } + + assert(false, "This code should never be reached"); +} +unittest +{ + writeln("D:YAML construction timestamp unittest"); + + string timestamp(string value) + { + return constructTimestamp(Mark(), Mark(), value).toISOString(); + } + + string canonical = "2001-12-15T02:59:43.1Z"; + string iso8601 = "2001-12-14t21:59:43.10-05:00"; + string spaceSeparated = "2001-12-14 21:59:43.10 -5"; + string noTZ = "2001-12-15 2:59:43.10"; + string noFraction = "2001-12-15 2:59:43"; + string ymd = "2002-12-14"; + + assert(timestamp(canonical) == "20011215T025943.1Z"); + //avoiding float conversion errors + assert(timestamp(iso8601) == "20011214T215943.0999999-05:00" || + timestamp(iso8601) == "20011214T215943.1-05:00"); + assert(timestamp(spaceSeparated) == "20011214T215943.0999999-05:00" || + timestamp(spaceSeparated) == "20011214T215943.1-05:00"); + assert(timestamp(noTZ) == "20011215T025943.0999999Z" || + timestamp(noTZ) == "20011215T025943.1Z"); + assert(timestamp(noFraction) == "20011215T025943Z"); + assert(timestamp(ymd) == "20021214T000000Z"); +} + +///Construct a string node. +string constructString(Mark start, Mark end, string value) +{ + return value; +} + +///Convert a sequence of single-element mappings into a sequence of pairs. +Node.Pair[] getPairs(string type, Mark start, Mark end, Node[] nodes) +{ + Node.Pair[] pairs; + + foreach(ref node; nodes) + { + enforce(node.isMapping && node.length == 1, + new ConstructorException("While constructing " ~ type ~ + ", expected a mapping with single element,", start, + end)); + + pairs ~= node.get!(Node.Pair[]); + } + + return pairs; +} + +///Construct an ordered map (ordered sequence of key:value pairs without duplicates) node. +Node.Pair[] constructOrderedMap(Mark start, Mark end, Node[] nodes) +{ + auto pairs = getPairs("ordered map", start, end, nodes); + + //In future, the map here should be replaced with something with deterministic + //memory allocation if possible. + //Detect duplicates. + Node[Node] map; + foreach(ref pair; pairs) + { + enforce((pair.key in map) is null, + new ConstructorException("Found a duplicate entry in an ordered map", + start, end)); + map[pair.key] = pair.value; + } + clear(map); + return pairs; +} +unittest +{ + writeln("D:YAML construction ordered map unittest"); + + alias Node.Pair Pair; + + Node[] alternateTypes(uint length) + { + Node[] pairs; + foreach(long i; 0 .. length) + { + auto pair = (i % 2) ? Pair(Node(Node.Value(to!string(i))), Node(Node.Value(i))) + : Pair(Node(Node.Value(i)), Node(Node.Value(to!string(i)))); + pairs ~= Node(Node.Value([pair])); + } + return pairs; + } + + Node[] sameType(uint length) + { + Node[] pairs; + foreach(long i; 0 .. length) + { + auto pair = Pair(Node(Node.Value(to!string(i))), Node(Node.Value(i))); + pairs ~= Node(Node.Value([pair])); + } + return pairs; + } + + bool hasDuplicates(Node[] nodes) + { + return null !is collectException(constructOrderedMap(Mark(), Mark(), nodes)); + } + + assert(hasDuplicates(alternateTypes(8) ~ alternateTypes(2))); + assert(!hasDuplicates(alternateTypes(8))); + assert(hasDuplicates(sameType(64) ~ sameType(16))); + assert(hasDuplicates(alternateTypes(64) ~ alternateTypes(16))); + assert(!hasDuplicates(sameType(64))); + assert(!hasDuplicates(alternateTypes(64))); +} + +///Construct a pairs (ordered sequence of key: value pairs allowing duplicates) node. +Node.Pair[] constructPairs(Mark start, Mark end, Node[] nodes) +{ + return getPairs("pairs", start, end, nodes); +} + +///Construct a set node. +Node[] constructSet(Mark start, Mark end, Node.Pair[] pairs) +{ + //In future, the map here should be replaced with something with deterministic + //memory allocation if possible. + //Detect duplicates. + ubyte[Node] map; + Node[] nodes; + foreach(ref pair; pairs) + { + enforce((pair.key in map) is null, + new ConstructorException("Found a duplicate entry in a set", start, end)); + map[pair.key] = 0; + nodes ~= pair.key; + } + + clear(map); + return nodes; +} +unittest +{ + writeln("D:YAML construction set unittest"); + + Node.Pair[] set(uint length) + { + Node.Pair[] pairs; + foreach(long i; 0 .. length) + { + pairs ~= Node.Pair(Node(Node.Value(to!string(i))), Node()); + } + + return pairs; + } + + auto DuplicatesShort = set(8) ~ set(2); + auto noDuplicatesShort = set(8); + auto DuplicatesLong = set(64) ~ set(4); + auto noDuplicatesLong = set(64); + + bool eq(Node.Pair[] a, Node[] b) + { + if(a.length != b.length){return false;} + foreach(i; 0 .. a.length) + { + if(a[i].key != b[i]) + { + return false; + } + } + return true; + } + + assert(null !is collectException + (constructSet(Mark(), Mark(), DuplicatesShort.dup))); + assert(null is collectException + (constructSet(Mark(), Mark(), noDuplicatesShort.dup))); + assert(null !is collectException + (constructSet(Mark(), Mark(), DuplicatesLong.dup))); + assert(null is collectException + (constructSet(Mark(), Mark(), noDuplicatesLong.dup))); +} + +///Construct a sequence (array) node. +Node[] constructSequence(Mark start, Mark end, Node[] nodes) +{ + return nodes; +} + +///Construct an unordered map (unordered set of key: value _pairs without duplicates) node. +Node.Pair[] constructMap(Mark start, Mark end, Node.Pair[] pairs) +{ + //In future, the map here should be replaced with something with deterministic + //memory allocation if possible. + //Detect duplicates. + Node[Node] map; + foreach(ref pair; pairs) + { + enforce((pair.key in map) is null, + new ConstructorException("Found a duplicate entry in a map", start, end)); + map[pair.key] = pair.value; + } + + clear(map); + return pairs; +} diff --git a/dyaml/event.d b/dyaml/event.d new file mode 100644 index 0000000..5b5d98b --- /dev/null +++ b/dyaml/event.d @@ -0,0 +1,153 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * YAML events. + * Code based on PyYAML: http://www.pyyaml.org + */ +module dyaml.event; + +import std.array; +import std.conv; +import std.typecons; + +import dyaml.reader; +import dyaml.token; +import dyaml.exception; + + +package: +///Event types. +enum EventID : ubyte +{ + Invalid = 0, /// Invalid (uninitialized) event. + StreamStart, /// Stream start + StreamEnd, /// Stream end + DocumentStart, /// Document start + DocumentEnd, /// Document end + Alias, /// Alias + Scalar, /// Scalar + SequenceStart, /// Sequence start + SequenceEnd, /// Sequence end + MappingStart, /// Mapping start + MappingEnd /// Mapping end +} + +/** + * YAML event produced by parser. + * + * 64 bytes on 64-bit. + */ +immutable struct Event +{ + ///Start position of the event in file/stream. + Mark startMark; + ///End position of the event in file/stream. + Mark endMark; + ///Anchor of the event, if any. + string anchor; + ///Tag of the event, if any. + string tag; + ///Value of the event, if any. + string value; + ///Event type. + EventID id; + ///Style of scalar event, if this is a scalar event. + ScalarStyle style; + ///Should the tag be implicitly resolved? + bool implicit; + /** + * Is this document event explicit? + * + * Used if this is a DocumentStart or DocumentEnd. + */ + alias implicit explicitDocument; +} + +/** + * Construct a simple event. + * + * Params: start = Start position of the event in the file/stream. + * end = End position of the event in the file/stream. + * anchor = Anchor, if this is an alias event. + */ +Event event(EventID id)(in Mark start, in Mark end, in string anchor = null) pure +{ + return Event(start, end, anchor, null, null, id); +} + +/** + * Construct a collection (mapping or sequence) start event. + * + * Params: start = Start position of the event in the file/stream. + * end = End position of the event in the file/stream. + * anchor = Anchor of the sequence, if any. + * tag = Tag of the sequence, if specified. + * implicit = Should the tag be implicitly resolved? + */ +Event collectionStartEvent(EventID id)(in Mark start, in Mark end, in string anchor, + in string tag, in bool implicit) pure +{ + static assert(id == EventID.SequenceStart || id == EventID.SequenceEnd || + id == EventID.MappingStart || id == EventID.MappingEnd); + return Event(start, end, anchor, tag, null, id, ScalarStyle.Invalid, implicit); +} + +///Aliases for simple events. +alias event!(EventID.StreamStart) streamStartEvent; +alias event!(EventID.StreamEnd) streamEndEvent; +alias event!(EventID.Alias) aliasEvent; +alias event!(EventID.SequenceEnd) sequenceEndEvent; +alias event!(EventID.MappingEnd) mappingEndEvent; + +///Aliases for collection start events. +alias collectionStartEvent!(EventID.SequenceStart) sequenceStartEvent; +alias collectionStartEvent!(EventID.MappingStart) mappingStartEvent; + +/** + * Construct a document start event. + * + * Params: start = Start position of the event in the file/stream. + * end = End position of the event in the file/stream. + * explicit = Is this an explicit document start? + * YAMLVersion = YAML version string of the document. + */ +Event documentStartEvent(Mark start, Mark end, bool explicit, string YAMLVersion) pure +{ + return Event(start, end, null, null, YAMLVersion, EventID.DocumentStart, + ScalarStyle.Invalid, explicit); +} + +/** + * Construct a document end event. + * + * Params: start = Start position of the event in the file/stream. + * end = End position of the event in the file/stream. + * explicit = Is this an explicit document end? + */ +Event documentEndEvent(Mark start, Mark end, bool explicit) +{ + return Event(start, end, null, null, null, EventID.DocumentEnd, + ScalarStyle.Invalid, explicit); +} + +/** + * Construct a scalar event. + * + * Params: start = Start position of the event in the file/stream. + * end = End position of the event in the file/stream. + * anchor = Anchor of the scalar, if any. + * tag = Tag of the scalar, if specified. + * implicit = Should the tag be implicitly resolved? + * value = String value of the scalar. + * style = Scalar style. + */ +Event scalarEvent(in Mark start, in Mark end, in string anchor, in string tag, + in bool implicit, in string value, + in ScalarStyle style = ScalarStyle.Invalid) pure +{ + return Event(start, end, anchor, tag, value, EventID.Scalar, style, implicit); +} diff --git a/dyaml/exception.d b/dyaml/exception.d new file mode 100644 index 0000000..ec8c1a1 --- /dev/null +++ b/dyaml/exception.d @@ -0,0 +1,75 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +///D:YAML exceptions and exception related code. +module dyaml.exception; + + +import std.algorithm; +import std.array; +import std.string; + + +///Base class for all exceptions thrown by D:YAML. +class YAMLException : Exception +{ + public: + ///Construct a YAMLException with specified message. + this(string msg){super(msg);} + + package: + //Set name of the file that was being processed when this exception was thrown. + @property name(in string name) + { + msg = name ~ ":\n" ~ msg; + } +} + +///Position in a YAML stream, used for error messages. +align(1) struct Mark +{ + private: + ///Line number. + ushort line_; + ///Column number. + ushort column_; + + public: + ///Construct a Mark with specified line and column in the file. + this(in uint line, in uint column) + { + line_ = cast(ushort)min(ushort.max, line); + column_ = cast(ushort)min(ushort.max, column); + } + + ///Get a string representation of the mark. + string toString() const + { + //Line/column numbers start at zero internally, make them start at 1. + string clamped(ushort v){return format(v + 1, v == ushort.max ? " or higher" : "");} + return format("line ", clamped(line_), ",column ", clamped(column_)); + } +} + +package: +//Base class of YAML exceptions with marked positions of the problem. +abstract class MarkedYAMLException : YAMLException +{ + //Construct a MarkedYAMLException with specified context and problem. + this(string context, Mark contextMark, string problem, Mark problemMark) + { + string msg = context ~ '\n'; + if(contextMark != problemMark){msg ~= contextMark.toString() ~ '\n';} + msg ~= problem ~ '\n' ~ problemMark.toString() ~ '\n'; + super(msg); + } + + //Construct a MarkedYAMLException with specified problem. + this(string problem, Mark problemMark) + { + super(problem ~ '\n' ~ problemMark.toString()); + } +} diff --git a/dyaml/loader.d b/dyaml/loader.d new file mode 100644 index 0000000..ba9c5b8 --- /dev/null +++ b/dyaml/loader.d @@ -0,0 +1,330 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * Class and convenience functions used to load YAML documents. + */ +module dyaml.loader; + + +import std.exception; +import std.stream; + +import dyaml.event; +import dyaml.node; +import dyaml.composer; +import dyaml.constructor; +import dyaml.resolver; +import dyaml.parser; +import dyaml.reader; +import dyaml.scanner; +import dyaml.token; +import dyaml.exception; + + +/** + * Load single YAML document from a file. + * + * If there is no or more than one YAML document in the file, this will throw. + * Use $(LREF loadAll) for such files. + * + * Params: filename = Name of the file to _load from. + * + * Returns: Root node of the document. + * + * Throws: YAMLException if there wasn't exactly one document in the file, + * the file could not be opened or on a YAML parsing error. + */ +Node load(in string filename) +{ + auto loader = Loader(filename); + return loader.loadSingleDocument(); +} + +/** + * Load single YAML document from a stream. + * + * You can use this to e.g _load YAML from memory. + * + * If there is no or more than one YAML document in the stream, this will throw. + * Use $(LREF loadAll) for such files. + * + * Params: input = Stream to read from. Must be readable. + * name = Name of the stream, used in error messages. + * + * Returns: Root node of the document. + * + * Throws: YAMLException if there wasn't exactly one document in the stream, + * the stream could not be read from or on a YAML parsing error. + * + * Examples: + * + * Loading YAML from memory: + * -------------------- + * import std.stream; + * import std.stdio; + * + * string yaml_input = "red: '#ff0000'\n" + * "green: '#00ff00'\n" + * "blue: '#0000ff'"; + * + * auto colors = yaml.load(new MemoryStream(cast(char[])yaml_input)); + * + * foreach(string color, string value; colors) + * { + * writeln(color, " is ", value, " in HTML/CSS"); + * } + * -------------------- + */ +Node load(Stream input, in string name = "") +{ + auto loader = Loader(input, name, new Constructor, new Resolver); + return loader.loadSingleDocument(); +} +unittest +{ + import std.stream; + import std.stdio; + + string yaml_input = "red: '#ff0000'\n" + "green: '#00ff00'\n" + "blue: '#0000ff'"; + + auto colors = load(new MemoryStream(cast(char[])yaml_input)); + + foreach(string color, string value; colors) + { + writeln(color, " is ", value, " in HTML/CSS"); + } +} + +/** + * Load all YAML documents from a file. + * + * Params: filename = Name of the file to load from. + * + * Returns: Array of root nodes of documents in the stream. + * If the stream is empty, empty array will be returned. + * + * Throws: YAMLException if the file could not be opened or on a YAML parsing error. + */ +Node[] loadAll(in string filename) +{ + auto loader = Loader(filename); + Node[] result; + foreach(ref node; loader){result ~= node;} + return result; +} + + +/** + * Load all YAML documents from a stream. + * + * Params: input = Stream to read from. Must be readable. + * name = Name of the stream, used in error messages. + * + * Returns: Array of root nodes of documents in the file. + * If the file is empty, empty array will be returned. + * + * Throws: YAMLException if the stream could not be read from or on a YAML parsing error. + */ +Node[] loadAll(Stream input, in string name = "") +{ + auto loader = Loader(input, name, new Constructor, new Resolver); + Node[] result; + foreach(ref node; loader){result ~= node;} + return result; +} + +///Loads YAML documents from files or streams. +struct Loader +{ + private: + ///Reads character data from a stream. + Reader reader_; + ///Processes character data to YAML tokens. + Scanner scanner_; + ///Processes tokens to YAML events. + Parser parser_; + ///Resolves tags (data types). + Resolver resolver_; + ///Constructs YAML data types. + Constructor constructor_; + ///Composes YAML nodes. + Composer composer_; + ///Name of the input file or stream, used in error messages. + string name_; + ///Input file stream, if the stream is created by Loader itself. + File file_ = null; + + public: + /** + * Construct a Loader to load YAML from a file. + * + * Params: filename = Name of the file to load from. + * + * Throws: YAMLException if the file could not be opened or read from. + */ + this(in string filename) + { + try{file_ = new File(filename);} + catch(StreamException e) + { + throw new YAMLException("Unable to load YAML file " ~ filename ~ " : " ~ e.msg); + } + this(file_, filename, new Constructor, new Resolver); + } + + /** + * Construct a Loader to load YAML from a file, with provided _constructor and _resolver. + * + * Constructor and _resolver can be used to implement custom data types in YAML. + * + * Params: filename = Name of the file to load from. + * constructor = Constructor to use. + * resolver = Resolver to use. + * + * Throws: YAMLException if the file could not be opened or read from. + */ + this(in string filename, Constructor constructor, Resolver resolver) + { + try{file_ = new File(filename);} + catch(StreamException e) + { + throw new YAMLException("Unable to load YAML file " ~ filename ~ " : " ~ e.msg); + } + + this(file_, filename, constructor, resolver); + } + + /** + * Construct a Loader to load YAML from a stream with provided _constructor and _resolver. + * + * Stream can be used to load YAML from memory and other sources. + * Constructor and _resolver can be used to implement custom data types in YAML. + * + * Params: input = Stream to read from. Must be readable. + * name = Name of the stream. Used in error messages. + * constructor = Constructor to use. + * resolver = Resolver to use. + * + * Throws: YAMLException if the stream could not be read from. + */ + this(Stream input, in string name, Constructor constructor, Resolver resolver) + { + try + { + reader_ = new Reader(input); + scanner_ = new Scanner(reader_); + parser_ = new Parser(scanner_); + resolver_ = resolver; + constructor_ = constructor; + composer_ = new Composer(parser_, resolver_, constructor_); + name_ = name; + } + catch(YAMLException e) + { + e.name = name_; + throw e; + } + } + + /** + * Load single YAML document. + * + * If no or more than one YAML document is found, this will throw a YAMLException. + * + * Returns: Root node of the document. + * + * Throws: YAMLException if there wasn't exactly one document + * or on a YAML parsing error. + */ + Node loadSingleDocument() + { + try + { + enforce(composer_.checkNode(), new YAMLException("No YAML document to load")); + return composer_.getSingleNode(); + } + catch(YAMLException e) + { + e.name = name_; + throw e; + } + } + + /** + * Foreach over YAML documents. + * + * Parses documents lazily, as they are needed. + * + * Throws: YAMLException on a parsing error. + */ + int opApply(int delegate(ref Node) dg) + { + try + { + int result = 0; + while(composer_.checkNode()) + { + auto node = composer_.getNode(); + result = dg(node); + if(result){break;} + } + + return result; + } + catch(YAMLException e) + { + e.name = name_; + throw e; + } + } + + ///Destroy the Loader. + ~this() + { + clear(reader_); + clear(scanner_); + clear(parser_); + clear(composer_); + //Can't clear constructor, resolver: they might be supplied by the user. + if(file_ !is null){file_.close();} + } + + package: + //Scan and return all tokens. Used for debugging. + Token[] scan() + { + try + { + Token[] result; + while(scanner_.checkToken()){result ~= scanner_.getToken();} + return result; + } + catch(YAMLException e) + { + e.name = name_; + throw e; + } + } + + //Parse and return all events. Used for debugging. + Event[] parse() + { + try + { + Event[] result; + while(parser_.checkEvent()){result ~= parser_.getEvent();} + return result; + } + catch(YAMLException e) + { + e.name = name_; + throw e; + } + } +} diff --git a/dyaml/node.d b/dyaml/node.d new file mode 100644 index 0000000..87e1a9a --- /dev/null +++ b/dyaml/node.d @@ -0,0 +1,720 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * Node of a YAML document. Used to read YAML data once it's loaded. + */ +module dyaml.node; + + +import std.algorithm; +import std.conv; +import std.datetime; +import std.exception; +import std.math; +import std.stdio; +import std.traits; +import std.typecons; +import std.variant; + +import dyaml.event; +import dyaml.exception; + + +///Exception thrown at node related errors. +class NodeException : YAMLException +{ + package: + /* + * Construct a NodeException. + * + * Params: msg = Error message. + * start = Start position of the node. + * end = End position of the node. + */ + this(string msg, Mark start, Mark end) + { + super(msg ~ "\nstart:" ~ start.toString() ~ "\nend:" ~ end.toString()); + } +} + +//Node kinds. +package enum NodeID : ubyte +{ + Scalar, + Sequence, + Mapping +} + +///Null YAML type. Used in nodes with _null values. +struct YAMLNull{} + +//Merge YAML type, used to support "tag:yaml.org,2002:merge". +package struct YAMLMerge{} + +///Base class for YAMLContainer - used for user defined YAML types. +private abstract class YAMLObject +{ + protected: + ///Get type of the stored value. + @property TypeInfo type() const; + + ///Test for equality with another YAMLObject. + bool equals(YAMLObject rhs); +} + +//Stores a user defined YAML data type. +private class YAMLContainer(T) : YAMLObject +{ + private: + //Stored value. + T value_; + + //Construct a YAMLContainer holding specified value. + this(T value){value_ = value;} + + protected: + //Get type of the stored value. + @property override TypeInfo type() const {return typeid(T);} + + //Test for equality with another YAMLObject. + override bool equals(YAMLObject rhs) + { + if(rhs.type !is typeid(T)){return false;} + return value_ == (cast(YAMLContainer)rhs).value_; + } +} + +/** + * YAML node. + * + * This is a pseudo-dynamic type that can store any YAML value, including sequence + * or a mapping of nodes. You can get data from a Node directly or iterate over it + * if it's a sequence or a mapping. + */ +struct Node +{ + + public: + ///Pair of YAML nodes, used in mappings. + struct Pair + { + ///Key node. + Node key; + ///Value node. + Node value; + + ///Test for equality with another Pair. + bool equals(ref Pair rhs) + { + return key == rhs.key && value == rhs.value; + } + } + package: + //YAML value type. + alias Algebraic!(YAMLNull, YAMLMerge, bool, long, real, ubyte[], SysTime, string, + Node.Pair[], Node[], YAMLObject) Value; + + //Stored value. + Value value_; + + private: + ///Start position of the node. + Mark startMark_; + ///End position of the node. + Mark endMark_; + + public: + ///Is this node valid (initialized)? + @property bool isValid() const {return value_.hasValue;} + + ///Is this node a scalar value? + @property bool isScalar() const {return !(isMapping || isSequence);} + + ///Is this node a sequence of nodes? + @property bool isSequence() const {return isType!(Node[]);} + + ///Is this node a mapping of nodes? + @property bool isMapping() const {return isType!(Pair[]);} + + ///Is this node a user defined type? + @property bool isUserType() const {return isType!YAMLObject;} + + /** + * Equality test. + * + * If T is Node, recursively compare all + * subnodes and might be quite expensive if testing entire documents. + * + * If T is not Node, convert the node to T and test equality with that. + * + * Examples: + * -------------------- + * //node is a Node that contains integer 42 + * assert(node == 42); + * assert(node == "42"); + * assert(node != "43"); + * -------------------- + * + * Params: rhs = Variable to test equality with. + * + * Returns: true if equal, false otherwise. + */ + bool opEquals(T)(ref T rhs) + { + static if(is(T == Node)) + { + if(!isValid){return !rhs.isValid;} + if(!rhs.isValid || (value_.type !is rhs.value_.type)) + { + return false; + } + if(isSequence) + { + auto seq1 = get!(Node[]); + auto seq2 = rhs.get!(Node[]); + if(seq1.length != seq2.length){return false;} + foreach(node; 0 .. seq1.length) + { + if(seq1[node] != seq2[node]){return false;} + } + return true; + } + if(isMapping) + { + auto map1 = get!(Node.Pair[]); + auto map2 = rhs.get!(Node.Pair[]); + if(map1.length != map2.length){return false;} + foreach(pair; 0 .. map1.length) + { + if(!map1[pair].equals(map2[pair])){return false;} + } + return true; + } + if(isScalar) + { + if(isUserType) + { + if(!rhs.isUserType){return false;} + return get!YAMLObject.equals(rhs.get!YAMLObject); + } + if(isFloat) + { + if(!rhs.isFloat){return false;} + real r1 = get!real; + real r2 = rhs.get!real; + if(isNaN(r1)){return isNaN(r2);} + return r1 == r2; + } + else{return value_ == rhs.value_;} + } + assert(false, "Unknown kind of node"); + } + else + { + try{return rhs == get!T;} + catch(NodeException e){return false;} + } + } + + /** + * Get the value of the node as specified type. + * + * If the specifed type does not match type in the node, + * conversion is attempted if possible. + * + * Timestamps are stored as std.datetime.SysTime. + * Binary values are decoded and stored as ubyte[]. + * + * $(BR)$(B Mapping default values:) + * + * $(PBR + * The '=' key can be used to denote the default value of a mapping. + * This can be used when a node is scalar in early versions of a program, + * but is replaced by a mapping later. Even if the node is a mapping, the + * get method can be used as if it was a scalar if it has a default value. + * This way, new YAML files where the node is a mapping can still be read + * by old versions of the program, which expects the node to be a scalar. + * ) + * + * Examples: + * + * Automatic type conversion: + * -------------------- + * //node is a node that contains integer 42 + * assert(node.get!int == 42); + * assert(node.get!string == "42"); + * assert(node.get!double == 42.0); + * -------------------- + * + * Returns: Value of the node as specified type. + * + * Throws: NodeException if unable to convert to specified type. + */ + @property T get(T)() + { + T result; + getToVar(result); + return result; + } + + /** + * Write the value of the node to target. + * + * If the type of target does not match type of the node, + * conversion is attempted, if possible. + * + * Params: target = Variable to write to. + * + * Throws: NodeException if unable to convert to specified type. + */ + void getToVar(T)(out T target) + { + if(isType!T) + { + target = value_.get!T; + return; + } + + ///Must go before others, as even string/int/etc could be stored in a YAMLObject. + if(isUserType) + { + auto object = get!YAMLObject; + if(object.type is typeid(T)) + { + target = (cast(YAMLContainer!T)object).value_; + return; + } + } + + //If we're getting from a mapping and we're not getting Node.Pair[], + //we're getting the default value. + if(isMapping){return this["="].get!T;} + + static if(isSomeString!T) + { + //Try to convert to string. + try + { + target = value_.coerce!T(); + return; + } + catch(VariantException e) + { + throw new NodeException("Unable to convert node value to a string", + startMark_, endMark_); + } + } + else static if(isFloatingPoint!T) + { + ///Can convert int to float. + if(isInt()) + { + target = to!T(value_.get!long); + return; + } + else if(isFloat()) + { + target = to!T(value_.get!real); + return; + } + } + else static if(isIntegral!T) + { + if(isInt()) + { + long temp = value_.get!long; + if(temp < T.min || temp > T.max) + { + throw new NodeException("Integer value out of range of type " ~ + typeid(T).toString ~ "Value: " ~ + to!string(temp), startMark_, endMark_); + } + target = to!T(temp); + return; + } + } + else + { + //Can't get the value. + throw new NodeException("Node has unexpected type " ~ value_.type.toString ~ + ". Expected " ~ typeid(T).toString, startMark_, endMark_); + } + } + + /** + * If this is a sequence or a mapping, return its length. + * + * Otherwise, throw NodeException. + * + * Returns: Number of elements in a sequence or key-value pairs in a mapping. + * + * Throws: NodeException if this is not a sequence nor a mapping. + */ + @property size_t length() + { + if(isSequence) {return get!(Node[]).length;} + else if(isMapping){return get!(Pair[]).length;} + throw new NodeException("Trying to get length of a node that is not a collection", + startMark_, endMark_); + } + + /** + * Get the element with specified index. + * + * If the node is a sequence, index must be integral. + * + * If the node is a mapping, return the value corresponding to the first + * key equal to index, even after conversion. I.e; node["12"] will + * return value of the first key that equals "12", even if it's an integer. + * + * Params: index = Index to use. + * + * Returns: Value corresponding to the index. + * + * Throws: NodeException if the index could not be found. + */ + Node opIndex(T)(in T index) + { + if(isSequence) + { + //Sequence, index must be integral. + static if(isIntegral!T) + { + auto nodes = value_.get!(Node[]); + enforce(index >= 0 && index < nodes.length, + new NodeException("Index to a sequence out of range: " + ~ to!string(index), startMark_, endMark_)); + return nodes[index]; + } + else + { + throw new NodeException("Indexing a sequence with a non-integer type.", + startMark_, endMark_); + } + } + else if(isMapping) + { + //Mapping, look for keys convertible to T with value of index. + foreach(ref pair; get!(Pair[])) + { + //Handle NaN. + static if(isFloatingPoint!T) + { + if(isFloat && isNaN(index) && isNaN(pair.key.get!real)) + { + return pair.value; + } + } + //If we can get the key as type T, get it and compare to + //index, and return value if the key matches. + if(pair.key.convertsTo!T && pair.key.get!T == index) + { + return pair.value; + } + } + throw new NodeException("Mapping index not found" ~ + isSomeString!T ? ": " ~ to!string(index) : "", + startMark_, endMark_); + } + throw new NodeException("Trying to index node that does not support indexing", + startMark_, endMark_); + } + unittest + { + writeln("D:YAML Node opIndex unittest"); + + alias Node.Value Value; + alias Node.Pair Pair; + Node n1 = Node(Value(cast(long)11)); + Node n2 = Node(Value(cast(long)12)); + Node n3 = Node(Value(cast(long)13)); + Node n4 = Node(Value(cast(long)14)); + + Node k1 = Node(Value("11")); + Node k2 = Node(Value("12")); + Node k3 = Node(Value("13")); + Node k4 = Node(Value("14")); + + Node narray = Node(Value([n1, n2, n3, n4])); + Node nmap = Node(Value([Pair(k1, n1), + Pair(k2, n2), + Pair(k3, n3), + Pair(k4, n4)])); + + assert(narray[0].get!int == 11); + assert(null !is collectException(narray[42])); + assert(nmap["11"].get!int == 11); + assert(nmap["14"].get!int == 14); + assert(null !is collectException(nmap["42"])); + } + + /** + * Iterate over a sequence, getting each element as T. + * + * If T is Node, simply iterate over the nodes in the sequence. + * Otherwise, convert each node to T during iteration. + * + * Throws: NodeException if the node is not a sequence or an + * element could not be converted to specified type. + */ + int opApply(T)(int delegate(ref T) dg) + { + enforce(isSequence, + new NodeException("Trying to iterate over a node that is not a sequence", + startMark_, endMark_)); + + int result = 0; + foreach(ref node; get!(Node[])) + { + static if(is(T == Node)) + { + result = dg(node); + } + else + { + T temp = node.get!T; + result = dg(temp); + } + if(result){break;} + } + return result; + } + unittest + { + writeln("D:YAML Node opApply unittest 1"); + + alias Node.Value Value; + alias Node.Pair Pair; + + Node n1 = Node(Value(cast(long)11)); + Node n2 = Node(Value(cast(long)12)); + Node n3 = Node(Value(cast(long)13)); + Node n4 = Node(Value(cast(long)14)); + Node narray = Node(Value([n1, n2, n3, n4])); + + int[] array, array2; + foreach(int value; narray) + { + array ~= value; + } + foreach(Node node; narray) + { + array2 ~= node.get!int; + } + assert(array == [11, 12, 13, 14]); + assert(array2 == [11, 12, 13, 14]); + } + + /** + * Iterate over a mapping, getting each key/value as K/V. + * + * If the K and/or V is Node, simply iterate over the nodes in the mapping. + * Otherwise, convert each key/value to T during iteration. + * + * Throws: NodeException if the node is not a mapping or an + * element could not be converted to specified type. + */ + int opApply(K, V)(int delegate(ref K, ref V) dg) + { + enforce(isMapping, + new NodeException("Trying to iterate over a node that is not a mapping", + startMark_, endMark_)); + + int result = 0; + foreach(ref pair; get!(Node.Pair[])) + { + static if(is(K == Node) && is(V == Node)) + { + result = dg(pair.key, pair.value); + } + else static if(is(K == Node)) + { + V tempValue = pair.value.get!V; + result = dg(pair.key, tempValue); + } + else static if(is(V == Node)) + { + K tempKey = pair.key.get!K; + result = dg(tempKey, pair.value); + } + else + { + K tempKey = pair.key.get!K; + V tempValue = pair.value.get!V; + result = dg(tempKey, tempValue); + } + + if(result){break;} + } + return result; + } + unittest + { + writeln("D:YAML Node opApply unittest 2"); + + alias Node.Value Value; + alias Node.Pair Pair; + + Node n1 = Node(Value(cast(long)11)); + Node n2 = Node(Value(cast(long)12)); + Node n3 = Node(Value(cast(long)13)); + Node n4 = Node(Value(cast(long)14)); + + Node k1 = Node(Value("11")); + Node k2 = Node(Value("12")); + Node k3 = Node(Value("13")); + Node k4 = Node(Value("14")); + + Node nmap1 = Node(Value([Pair(k1, n1), + Pair(k2, n2), + Pair(k3, n3), + Pair(k4, n4)])); + + int[string] expected = ["11" : 11, + "12" : 12, + "13" : 13, + "14" : 14]; + int[string] array; + foreach(string key, int value; nmap1) + { + array[key] = value; + } + assert(array == expected); + + Node nmap2 = Node(Value([Pair(k1, Node(Value(cast(long)5))), + Pair(k2, Node(Value(true))), + Pair(k3, Node(Value(cast(real)1.0))), + Pair(k4, Node(Value("yarly")))])); + + foreach(string key, Node value; nmap2) + { + switch(key) + { + case "11": assert(value.get!int == 5 ); break; + case "12": assert(value.get!bool == true ); break; + case "13": assert(value.get!float == 1.0 ); break; + case "14": assert(value.get!string == "yarly"); break; + default: assert(false); + } + } + } + + package: + /* + * Get a string representation of the node tree. Used for debugging. + * + * Params: level = Level of the node in the tree. + * + * Returns: String representing the node tree. + */ + @property string debugString(uint level = 0) + { + string indent; + foreach(i; 0 .. level){indent ~= " ";} + + if(!isValid){return indent ~ "invalid";} + + if(isSequence) + { + string result = indent ~ "sequence:\n"; + foreach(ref node; get!(Node[])) + { + result ~= node.debugString(level + 1); + } + return result; + } + if(isMapping) + { + string result = indent ~ "mapping:\n"; + foreach(ref pair; get!(Node.Pair[])) + { + result ~= indent ~ " pair\n"; + result ~= pair.key.debugString(level + 2); + result ~= pair.value.debugString(level + 2); + } + return result; + } + if(isScalar) + { + return indent ~ "scalar(" ~ + (convertsTo!string ? get!string : value_.type.toString) ~ ")\n"; + } + assert(false); + } + + //Construct Node.Value from user defined type. + static Value userValue(T)(T value) + { + return Value(cast(YAMLObject)new YAMLContainer!T(value)); + } + + private: + /* + * Determine if the value stored by the node is of specified type. + * + * This only works for default YAML types, not for user defined types. + */ + @property bool isType(T)() const {return value_.type is typeid(T);} + + ///Is the value an integer of some kind? + alias isType!long isInt; + + ///Is the value a floating point number of some kind? + alias isType!real isFloat; + + //Determine if the value can be converted to specified type. + bool convertsTo(T)() + { + if(isType!T){return true;} + + static if(isSomeString!T) + { + try + { + auto dummy = value_.coerce!T(); + return true; + } + catch(VariantException e){return false;} + } + else static if(isFloatingPoint!T){return isInt() || isFloat();} + else static if(isIntegral!T) {return isInt();} + else {return false;} + } +} + +package: +/* + * Merge a pair into an array of pairs based on merge rules in the YAML spec. + * + * The new pair will only be added if there is not already a pair + * with the same key. + * + * Params: pairs = Array of pairs to merge into. + * toMerge = Pair to merge. + */ +void merge(ref Node.Pair[] pairs, ref Node.Pair toMerge) +{ + foreach(ref pair; pairs) + { + if(pair.key == toMerge.key){return;} + } + pairs ~= toMerge; +} + +/* + * Merge pairs into an array of pairs based on merge rules in the YAML spec. + * + * Any new pair will only be added if there is not already a pair + * with the same key. + * + * Params: pairs = Array of pairs to merge into. + * toMerge = Pairs to merge. + */ +void merge(ref Node.Pair[] pairs, Node.Pair[] toMerge) +{ + foreach(ref pair; toMerge){merge(pairs, pair);} +} diff --git a/dyaml/parser.d b/dyaml/parser.d new file mode 100644 index 0000000..f9e00a5 --- /dev/null +++ b/dyaml/parser.d @@ -0,0 +1,842 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * YAML parser. + * Code based on PyYAML: http://www.pyyaml.org + */ +module dyaml.parser; + + +import std.array; +import std.conv; +import std.exception; + +import dyaml.event; +import dyaml.scanner; +import dyaml.token; +import dyaml.exception; + + +package: +/** + * The following YAML grammar is LL(1) and is parsed by a recursive descent + * parser. + * + * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END + * implicit_document ::= block_node DOCUMENT-END* + * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* + * block_node_or_indentless_sequence ::= + * ALIAS + * | properties (block_content | indentless_block_sequence)? + * | block_content + * | indentless_block_sequence + * block_node ::= ALIAS + * | properties block_content? + * | block_content + * flow_node ::= ALIAS + * | properties flow_content? + * | flow_content + * properties ::= TAG ANCHOR? | ANCHOR TAG? + * block_content ::= block_collection | flow_collection | SCALAR + * flow_content ::= flow_collection | SCALAR + * block_collection ::= block_sequence | block_mapping + * flow_collection ::= flow_sequence | flow_mapping + * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END + * indentless_sequence ::= (BLOCK-ENTRY block_node?)+ + * block_mapping ::= BLOCK-MAPPING_START + * ((KEY block_node_or_indentless_sequence?)? + * (VALUE block_node_or_indentless_sequence?)?)* + * BLOCK-END + * flow_sequence ::= FLOW-SEQUENCE-START + * (flow_sequence_entry FLOW-ENTRY)* + * flow_sequence_entry? + * FLOW-SEQUENCE-END + * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + * flow_mapping ::= FLOW-MAPPING-START + * (flow_mapping_entry FLOW-ENTRY)* + * flow_mapping_entry? + * FLOW-MAPPING-END + * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + * + * FIRST sets: + * + * stream: { STREAM-START } + * explicit_document: { DIRECTIVE DOCUMENT-START } + * implicit_document: FIRST(block_node) + * block_node: { ALIAS TAG ANCHOR SCALAR BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START } + * flow_node: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START } + * block_content: { BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START SCALAR } + * flow_content: { FLOW-SEQUENCE-START FLOW-MAPPING-START SCALAR } + * block_collection: { BLOCK-SEQUENCE-START BLOCK-MAPPING-START } + * flow_collection: { FLOW-SEQUENCE-START FLOW-MAPPING-START } + * block_sequence: { BLOCK-SEQUENCE-START } + * block_mapping: { BLOCK-MAPPING-START } + * block_node_or_indentless_sequence: { ALIAS ANCHOR TAG SCALAR BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START BLOCK-ENTRY } + * indentless_sequence: { ENTRY } + * flow_collection: { FLOW-SEQUENCE-START FLOW-MAPPING-START } + * flow_sequence: { FLOW-SEQUENCE-START } + * flow_mapping: { FLOW-MAPPING-START } + * flow_sequence_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY } + * flow_mapping_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY } + */ + + +/** + * Marked exception thrown at parser errors. + * + * See_Also: MarkedYAMLException + */ +class ParserException : MarkedYAMLException +{ + this(string context, Mark contextMark, string problem, Mark problemMark) + { + super(context, contextMark, problem, problemMark); + } + + this(string problem, Mark problemMark){super(problem, problemMark);} +} + +///Generates events from tokens provided by a Scanner. +final class Parser +{ + invariant() + { + assert(currentEvent_.length <= 1); + } + + private: + ///Default tag handle shortcuts and replacements. + static string[string] defaultTags_; + static this() + { + defaultTags_ = ["!" : "!", "!!" : "tag:yaml.org,2002:"]; + } + + ///Scanner providing YAML tokens. + Scanner scanner_; + + ///Holds zero or one event. + Event[] currentEvent_; + + ///YAML version string. + string YAMLVersion_ = null; + ///Tag handle shortcuts and replacements. + string[string] tagHandles_; + + ///Stack of states. + Event delegate()[] states_; + ///Stack of marks used to keep track of extents of e.g. YAML collections. + Mark[] marks_; + ///Current state. + Event delegate() state_; + + public: + ///Construct a Parser using specified Scanner. + this(Scanner scanner) + { + state_ = &parseStreamStart; + scanner_ = scanner; + } + + ///Destroy the parser. + ~this() + { + clear(currentEvent_); + currentEvent_ = null; + clear(tagHandles_); + tagHandles_ = null; + clear(states_); + states_ = null; + clear(marks_); + marks_ = null; + } + + /** + * Check if the next event is one of specified types. + * + * If no types are specified, checks if any events are left. + * + * Params: ids = Event IDs to check for. + * + * Returns: true if the next event is one of specified types, + * or if there are any events left if no types specified. + * false otherwise. + */ + bool checkEvent(EventID[] ids...) + { + //Check if the next event is one of specified types. + if(currentEvent_.empty && state_ !is null) + { + currentEvent_ ~= state_(); + } + + if(!currentEvent_.empty) + { + if(ids.length == 0){return true;} + else + { + const nextId = currentEvent_.front.id; + foreach(id; ids) + { + if(nextId == id){return true;} + } + } + } + + return false; + } + + /** + * Return the next event, but keep it in the queue. + * + * Must not be called if there are no events left. + */ + Event peekEvent() + { + if(currentEvent_.empty && state_ !is null) + { + currentEvent_ ~= state_(); + } + if(!currentEvent_.empty){return currentEvent_[0];} + assert(false, "No event left to peek"); + } + + /** + * Return the next event, removing it from the queue. + * + * Must not be called if there are no events left. + */ + Event getEvent() + { + //Get the next event and proceed further. + if(currentEvent_.empty && state_ !is null) + { + currentEvent_ ~= state_(); + } + + if(!currentEvent_.empty) + { + Event result = currentEvent_[0]; + currentEvent_.length = 0; + return result; + } + assert(false, "No event left to get"); + } + + private: + ///Pop and return the newest state in states_. + Event delegate() popState() + { + enforce(states_.length > 0, + new YAMLException("Parser: Need to pop a state but there are no states left")); + const result = states_.back(); + states_.popBack; + return result; + } + + ///Pop and return the newest mark in marks_. + Mark popMark() + { + enforce(marks_.length > 0, + new YAMLException("Parser: Need to pop a mark but there are no marks left")); + const result = marks_.back(); + marks_.popBack; + return result; + } + + /** + * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END + * implicit_document ::= block_node DOCUMENT-END* + * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* + */ + + ///Parse stream start. + Event parseStreamStart() + { + Token token = scanner_.getToken(); + state_ = &parseImplicitDocumentStart; + return streamStartEvent(token.startMark, token.endMark); + } + + ///Parse implicit document start, unless explicit is detected: if so, parse explicit. + Event parseImplicitDocumentStart() + { + //Parse an implicit document. + if(!scanner_.checkToken(TokenID.Directive, TokenID.DocumentStart, + TokenID.StreamEnd)) + { + tagHandles_ = defaultTags_; + Token token = scanner_.peekToken(); + + states_ ~= &parseDocumentEnd; + state_ = &parseBlockNode; + + return documentStartEvent(token.startMark, token.endMark, false, null); + } + return parseDocumentStart(); + } + + ///Parse explicit document start. + Event parseDocumentStart() + { + //Parse any extra document end indicators. + while(scanner_.checkToken(TokenID.DocumentEnd)){scanner_.getToken();} + + //Parse an explicit document. + if(!scanner_.checkToken(TokenID.StreamEnd)) + { + const startMark = scanner_.peekToken().startMark; + + processDirectives(); + enforce(scanner_.checkToken(TokenID.DocumentStart), + new ParserException("Expected document start but found " ~ + to!string(scanner_.peekToken().id), + scanner_.peekToken().startMark)); + + const endMark = scanner_.getToken().endMark; + states_ ~= &parseDocumentEnd; + state_ = &parseDocumentContent; + return documentStartEvent(startMark, endMark, true, YAMLVersion_); + } + else + { + //Parse the end of the stream. + Token token = scanner_.getToken(); + assert(states_.length == 0); + assert(marks_.length == 0); + state_ = null; + return streamEndEvent(token.startMark, token.endMark); + } + } + + ///Parse document end (explicit or implicit). + Event parseDocumentEnd() + { + Mark startMark = scanner_.peekToken().startMark; + const bool explicit = scanner_.checkToken(TokenID.DocumentEnd); + Mark endMark = explicit ? scanner_.getToken().endMark : startMark; + + state_ = &parseDocumentStart; + + return documentEndEvent(startMark, endMark, explicit); + } + + ///Parse document content. + Event parseDocumentContent() + { + if(scanner_.checkToken(TokenID.Directive, TokenID.DocumentStart, + TokenID.DocumentEnd, TokenID.StreamEnd)) + { + state_ = popState(); + return processEmptyScalar(scanner_.peekToken().startMark); + } + return parseBlockNode(); + } + + ///Process directives at the beginning of a document. + void processDirectives() + { + //Destroy version and tag handles from previous document. + YAMLVersion_ = null; + string[string] empty; + tagHandles_ = empty; + + //Process directives. + while(scanner_.checkToken(TokenID.Directive)) + { + Token token = scanner_.getToken(); + //Name and value are separated by '\0'. + const parts = token.value.split("\0"); + const name = parts[0]; + if(name == "YAML") + { + enforce(YAMLVersion_ is null, + new ParserException("Found duplicate YAML directive", + token.startMark)); + const minor = parts[1].split(".")[0]; + enforce(to!int(minor) == 1, + new ParserException("Found incompatible YAML document (version " + "1.* is required)", token.startMark)); + YAMLVersion_ = parts[1]; + } + else if(name == "TAG") + { + assert(parts.length == 3, "Tag directive stored incorrectly in a token"); + const handle = parts[1]; + + foreach(h, replacement; tagHandles_) + { + enforce(h != handle, new ParserException("Duplicate tag handle: " ~ + handle, token.startMark)); + } + tagHandles_[handle] = parts[2]; + } + } + + //Add any default tag handles that haven't been overridden. + foreach(key, value; defaultTags_) + { + if((key in tagHandles_) is null){tagHandles_[key] = value;} + } + } + + /** + * block_node_or_indentless_sequence ::= ALIAS + * | properties (block_content | indentless_block_sequence)? + * | block_content + * | indentless_block_sequence + * block_node ::= ALIAS + * | properties block_content? + * | block_content + * flow_node ::= ALIAS + * | properties flow_content? + * | flow_content + * properties ::= TAG ANCHOR? | ANCHOR TAG? + * block_content ::= block_collection | flow_collection | SCALAR + * flow_content ::= flow_collection | SCALAR + * block_collection ::= block_sequence | block_mapping + * flow_collection ::= flow_sequence | flow_mapping + */ + + ///Parse a node. + Event parseNode(bool block, bool indentlessSequence = false) + { + if(scanner_.checkToken(TokenID.Alias)) + { + Token token = scanner_.getToken(); + state_ = popState(); + return aliasEvent(token.startMark, token.endMark, token.value); + } + + string anchor = null; + string tag = null; + Mark startMark, endMark, tagMark; + bool invalidMarks = true; + + //Get anchor/tag if detected. Return false otherwise. + bool get(TokenID id, bool start, ref string target) + { + if(!scanner_.checkToken(id)){return false;} + invalidMarks = false; + Token token = scanner_.getToken(); + if(start){startMark = token.startMark;} + if(id == TokenID.Tag){tagMark = token.startMark;} + endMark = token.endMark; + target = token.value; + return true; + } + + //Anchor and/or tag can be in any order. + if(get(TokenID.Anchor, true, anchor)){get(TokenID.Tag, false, tag);} + else if(get(TokenID.Tag, true, tag)) {get(TokenID.Anchor, false, anchor);} + + if(tag !is null){tag = processTag(tag, startMark, tagMark);} + + if(invalidMarks) + { + startMark = endMark = scanner_.peekToken().startMark; + } + + bool implicit = (tag is null || tag == "!"); + + if(indentlessSequence && scanner_.checkToken(TokenID.BlockEntry)) + { + state_ = &parseIndentlessSequenceEntry; + return sequenceStartEvent(startMark, scanner_.peekToken().endMark, + anchor, tag, implicit); + } + + if(scanner_.checkToken(TokenID.Scalar)) + { + Token token = scanner_.getToken(); + + //PyYAML uses a Tuple!(bool, bool) here, but the second bool + //is never used after that - so we don't use it. + implicit = (token.style == ScalarStyle.Plain && tag is null) || tag == "!"; + state_ = popState(); + return scalarEvent(startMark, token.endMark, anchor, tag, + implicit, token.value, token.style); + } + + if(scanner_.checkToken(TokenID.FlowSequenceStart)) + { + endMark = scanner_.peekToken().endMark; + state_ = &parseFlowSequenceEntry!true; + return sequenceStartEvent(startMark, endMark, anchor, tag, implicit); + } + + if(scanner_.checkToken(TokenID.FlowMappingStart)) + { + endMark = scanner_.peekToken().endMark; + state_ = &parseFlowMappingKey!true; + return mappingStartEvent(startMark, endMark, anchor, tag, implicit); + } + + if(block && scanner_.checkToken(TokenID.BlockSequenceStart)) + { + endMark = scanner_.peekToken().endMark; + state_ = &parseBlockSequenceEntry!true; + return sequenceStartEvent(startMark, endMark, anchor, tag, implicit); + } + + if(block && scanner_.checkToken(TokenID.BlockMappingStart)) + { + endMark = scanner_.peekToken().endMark; + state_ = &parseBlockMappingKey!true; + return mappingStartEvent(startMark, endMark, anchor, tag, implicit); + } + + if(anchor != null || tag !is null) + { + state_ = popState(); + + //PyYAML uses a tuple(implicit, false) for the second last arg here, + //but the second bool is never used after that - so we don't use it. + + //Empty scalars are allowed even if a tag or an anchor is specified. + return scalarEvent(startMark, endMark, anchor, tag, implicit , ""); + } + + Token token = scanner_.peekToken(); + throw new ParserException("While parsing a " ~ (block ? "block" : "flow") ~ " node", + startMark, "expected the node content, but found: " + ~ to!string(token.id), token.startMark); + } + + /** + * Process a tag string retrieved from a tag token. + * + * Params: tag = Tag before processing. + * startMark = Position of the node the tag belongs to. + * tagMark = Position of the tag. + */ + string processTag(in string tag, in Mark startMark, in Mark tagMark) + { + //Tag handle and suffix are separated by '\0'. + const parts = tag.split("\0"); + assert(parts.length == 2, "Tag data stored incorrectly in a token"); + const handle = parts[0]; + const suffix = parts[1]; + + if(handle.length > 0) + { + //handle must be in tagHandles_ + enforce((handle in tagHandles_) !is null, + new ParserException("While parsing a node", startMark, + "found undefined tag handle: " ~ handle, tagMark)); + return tagHandles_[handle] ~ suffix; + } + return suffix; + } + + ///Wrappers to parse nodes. + Event parseBlockNode(){return parseNode(true);} + Event parseFlowNode(){return parseNode(false);} + Event parseBlockNodeOrIndentlessSequence(){return parseNode(true, true);} + + ///block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END + + ///Parse an entry of a block sequence. If first is true, this is the first entry. + Event parseBlockSequenceEntry(bool first)() + { + static if(first){marks_ ~= scanner_.getToken().startMark;} + + if(scanner_.checkToken(TokenID.BlockEntry)) + { + Token token = scanner_.getToken(); + if(!scanner_.checkToken(TokenID.BlockEntry, TokenID.BlockEnd)) + { + states_~= &parseBlockSequenceEntry!false; + return parseBlockNode(); + } + + state_ = &parseBlockSequenceEntry!false; + return processEmptyScalar(token.endMark); + } + + if(!scanner_.checkToken(TokenID.BlockEnd)) + { + Token token = scanner_.peekToken(); + throw new ParserException("While parsing a block collection", marks_[$ - 1], + "expected block end, but found " + ~ to!string(token.id), token.startMark); + } + + state_ = popState(); + popMark(); + Token token = scanner_.getToken(); + return sequenceEndEvent(token.startMark, token.endMark); + } + + ///indentless_sequence ::= (BLOCK-ENTRY block_node?)+ + + ///Parse an entry of an indentless sequence. + Event parseIndentlessSequenceEntry() + { + if(scanner_.checkToken(TokenID.BlockEntry)) + { + Token token = scanner_.getToken(); + + if(!scanner_.checkToken(TokenID.BlockEntry, TokenID.Key, + TokenID.Value, TokenID.BlockEnd)) + { + states_ ~= &parseIndentlessSequenceEntry; + return parseBlockNode(); + } + + state_ = &parseIndentlessSequenceEntry; + return processEmptyScalar(token.endMark); + } + + state_ = popState(); + Token token = scanner_.peekToken(); + return sequenceEndEvent(token.startMark, token.endMark); + } + + /** + * block_mapping ::= BLOCK-MAPPING_START + * ((KEY block_node_or_indentless_sequence?)? + * (VALUE block_node_or_indentless_sequence?)?)* + * BLOCK-END + */ + + ///Parse a key in a block mapping. If first is true, this is the first key. + Event parseBlockMappingKey(bool first)() + { + static if(first){marks_ ~= scanner_.getToken().startMark;} + + if(scanner_.checkToken(TokenID.Key)) + { + Token token = scanner_.getToken(); + + if(!scanner_.checkToken(TokenID.Key, TokenID.Value, TokenID.BlockEnd)) + { + states_ ~= &parseBlockMappingValue; + return parseBlockNodeOrIndentlessSequence(); + } + + state_ = &parseBlockMappingValue; + return processEmptyScalar(token.endMark); + } + + if(!scanner_.checkToken(TokenID.BlockEnd)) + { + Token token = scanner_.peekToken(); + throw new ParserException("While parsing a block mapping", marks_[$ - 1], + "expected block end, but found: " + ~ to!string(token.id), token.startMark); + } + + state_ = popState(); + popMark(); + Token token = scanner_.getToken(); + return mappingEndEvent(token.startMark, token.endMark); + } + + ///Parse a value in a block mapping. + Event parseBlockMappingValue() + { + if(scanner_.checkToken(TokenID.Value)) + { + Token token = scanner_.getToken(); + + if(!scanner_.checkToken(TokenID.Key, TokenID.Value, TokenID.BlockEnd)) + { + states_ ~= &parseBlockMappingKey!false; + return parseBlockNodeOrIndentlessSequence(); + } + + state_ = &parseBlockMappingKey!false; + return processEmptyScalar(token.endMark); + } + + state_= &parseBlockMappingKey!false; + return processEmptyScalar(scanner_.peekToken().startMark); + } + + /** + * flow_sequence ::= FLOW-SEQUENCE-START + * (flow_sequence_entry FLOW-ENTRY)* + * flow_sequence_entry? + * FLOW-SEQUENCE-END + * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + * + * Note that while production rules for both flow_sequence_entry and + * flow_mapping_entry are equal, their interpretations are different. + * For `flow_sequence_entry`, the part `KEY flow_node? (VALUE flow_node?)?` + * generate an inline mapping (set syntax). + */ + + ///Parse an entry in a flow sequence. If first is true, this is the first entry. + Event parseFlowSequenceEntry(bool first)() + { + static if(first){marks_ ~= scanner_.getToken().startMark;} + + if(!scanner_.checkToken(TokenID.FlowSequenceEnd)) + { + static if(!first) + { + if(scanner_.checkToken(TokenID.FlowEntry)) + { + scanner_.getToken(); + } + else + { + Token token = scanner_.peekToken; + throw new ParserException("While parsing a flow sequence", + marks_[$ - 1], + "expected ',' or ']', but got: " ~ + to!string(token.id), token.startMark); + } + } + + if(scanner_.checkToken(TokenID.Key)) + { + Token token = scanner_.peekToken(); + state_ = &parseFlowSequenceEntryMappingKey; + return mappingStartEvent(token.startMark, token.endMark, null, null, true); + } + else if(!scanner_.checkToken(TokenID.FlowSequenceEnd)) + { + states_ ~= &parseFlowSequenceEntry!false; + return parseFlowNode(); + } + } + + Token token = scanner_.getToken(); + state_ = popState(); + popMark(); + return sequenceEndEvent(token.startMark, token.endMark); + } + + ///Parse a key in flow context. + Event parseFlowKey(in Event delegate() nextState) + { + Token token = scanner_.getToken(); + + if(!scanner_.checkToken(TokenID.Value, TokenID.FlowEntry, + TokenID.FlowSequenceEnd)) + { + states_ ~= nextState; + return parseFlowNode(); + } + + state_ = nextState; + return processEmptyScalar(token.endMark); + } + + ///Parse a mapping key in an entry in a flow sequence. + Event parseFlowSequenceEntryMappingKey() + { + return parseFlowKey(&parseFlowSequenceEntryMappingValue); + } + + ///Parse a mapping value in a flow context. + Event parseFlowValue(TokenID checkId, in Event delegate() nextState) + { + if(scanner_.checkToken(TokenID.Value)) + { + Token token = scanner_.getToken(); + if(!scanner_.checkToken(TokenID.FlowEntry, checkId)) + { + states_ ~= nextState; + return parseFlowNode(); + } + + state_ = nextState; + return processEmptyScalar(token.endMark); + } + + state_ = nextState; + return processEmptyScalar(scanner_.peekToken().startMark); + } + + ///Parse a mapping value in an entry in a flow sequence. + Event parseFlowSequenceEntryMappingValue() + { + return parseFlowValue(TokenID.FlowSequenceEnd, + &parseFlowSequenceEntryMappingEnd); + } + + ///Parse end of a mapping in a flow sequence entry. + Event parseFlowSequenceEntryMappingEnd() + { + state_ = &parseFlowSequenceEntry!false; + Token token = scanner_.peekToken(); + return mappingEndEvent(token.startMark, token.startMark); + } + + /** + * flow_mapping ::= FLOW-MAPPING-START + * (flow_mapping_entry FLOW-ENTRY)* + * flow_mapping_entry? + * FLOW-MAPPING-END + * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + */ + + ///Parse a key in a flow mapping. + Event parseFlowMappingKey(bool first)() + { + static if(first){marks_ ~= scanner_.getToken().startMark;} + + if(!scanner_.checkToken(TokenID.FlowMappingEnd)) + { + static if(!first) + { + if(scanner_.checkToken(TokenID.FlowEntry)) + { + scanner_.getToken(); + } + else + { + Token token = scanner_.peekToken; + throw new ParserException("While parsing a flow mapping", + marks_[$ - 1], + "expected ',' or '}', but got: " ~ + to!string(token.id), token.startMark); + } + } + + if(scanner_.checkToken(TokenID.Key)) + { + return parseFlowKey(&parseFlowMappingValue); + } + + if(!scanner_.checkToken(TokenID.FlowMappingEnd)) + { + states_ ~= &parseFlowMappingEmptyValue; + return parseFlowNode(); + } + } + + Token token = scanner_.getToken(); + state_ = popState(); + popMark(); + return mappingEndEvent(token.startMark, token.endMark); + } + + ///Parse a value in a flow mapping. + Event parseFlowMappingValue() + { + return parseFlowValue(TokenID.FlowMappingEnd, &parseFlowMappingKey!false); + } + + ///Parse an empty value in a flow mapping. + Event parseFlowMappingEmptyValue() + { + state_ = &parseFlowMappingKey!false; + return processEmptyScalar(scanner_.peekToken().startMark); + } + + ///Return an empty scalar. + Event processEmptyScalar(in Mark mark) + { + //PyYAML uses a Tuple!(true, false) for the second last arg here, + //but the second bool is never used after that - so we don't use it. + return scalarEvent(mark, mark, null, null, true, ""); + } +} diff --git a/dyaml/reader.d b/dyaml/reader.d new file mode 100644 index 0000000..1ceb1cb --- /dev/null +++ b/dyaml/reader.d @@ -0,0 +1,482 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.reader; + + +import core.stdc.string; + +import std.algorithm; +import std.conv; +import std.exception; +import std.stdio; +import std.stream; +import std.string; +import std.system; +import std.utf; + +import dyaml.exception; + + +package: + +///Exception thrown at Reader errors. +class ReaderException : YAMLException +{ + this(string msg){super("Error reading YAML stream: " ~ msg);} +} + + +///Reads data from a stream and converts it to UTF-32 (dchar) data. +final class Reader +{ + private: + ///Unicode encodings. + enum UTF + { + ///UTF-8. + _8, + ///UTF-16. + _16, + ///UTF-32. + _32 + } + + ///Input stream. + EndianStream stream_; + ///Buffer of currently loaded characters. + dchar[] buffer_; + ///Current position within buffer. Only data after this position can be read. + uint bufferOffset_ = 0; + ///Index of the current character in the stream. + size_t charIndex_ = 0; + ///Encoding of the input stream. + UTF utf_= UTF._8; + ///Current line in file. + uint line_; + ///Current column in file. + uint column_; + + ///Capacity of raw buffers. + static immutable bufferLength8_ = 8; + ///Capacity of raw buffers. + static immutable bufferLength16_ = bufferLength8_ / 2; + + union + { + ///Buffer to hold UTF-8 data before decoding. + char[bufferLength8_] rawBuffer8_; + ///Buffer to hold UTF-16 data before decoding. + wchar[bufferLength16_] rawBuffer16_; + } + ///Number of elements held in the used raw buffer. + uint rawUsed_ = 0; + + public: + /** + * Construct a Reader. + * + * Params: stream = Input stream. Must be readable. + * + * Throws: ReaderException if the stream is invalid. + */ + this(Stream stream) + in{assert(stream.readable, "Can't read YAML from a non-readable stream");} + body + { + stream_ = new EndianStream(stream); + + //handle files short enough not to have a BOM + if(stream_.available < 2) + { + utf_ = UTF._8; + return; + } + + //readBOM will determine and set stream endianness + switch(stream_.readBOM(2)) + { + case -1: + //readBOM() eats two more bytes in this case so get them back + wchar bytes = stream_.getcw(); + rawBuffer8_[0] = cast(char)(bytes % 256); + rawBuffer8_[1] = cast(char)(bytes / 256); + rawUsed_ = 2; + goto case 0; + case 0: utf_ = UTF._8; break; + case 1, 2: + //readBOM() eats two more bytes in this case so get them back + utf_ = UTF._16; + rawBuffer16_[0] = stream_.getcw(); + rawUsed_ = 1; + enforce(stream_.available % 2 == 0, + new ReaderException("Odd number of bytes in an UTF-16 stream")); + break; + case 3, 4: + enforce(stream_.available % 4 == 0, + new ReaderException("Number of bytes in an UTF-32 stream not divisible by 4")); + utf_ = UTF._32; + break; + default: assert(false, "Unknown UTF BOM"); + } + } + + ///Destroy the Reader. + ~this() + { + clear(buffer_); + buffer_ = null; + } + + /** + * Get character at specified index relative to current position. + * + * Params: index = Index of the character to get relative to current position + * in the stream. + * + * Returns: Character at specified position. + * + * Throws: ReaderException if trying to read past the end of the stream + * or if invalid data is read. + */ + dchar peek(in size_t index = 0) + { + updateBuffer(index + 1); + + enforce(buffer_.length >= bufferOffset_ + index + 1, + new ReaderException("Trying to read past the end of the stream")); + return buffer_[bufferOffset_ + index]; + } + + /** + * Get specified number of characters starting at current position. + * + * Params: length = Number of characters to get. + * + * Returns: Characters starting at current position. + * + * Throws: ReaderException if trying to read past the end of the stream + * or if invalid data is read. + */ + dstring prefix(in size_t length) + { + if(length == 0){return "";} + updateBuffer(length); + const end = min(buffer_.length, bufferOffset_ + length); + //need to duplicate as we change buffer content with C functions + //and could end up with returned string referencing changed data + return cast(dstring)buffer_[bufferOffset_ .. end].dup; + } + + /** + * Get the next character, moving stream position beyond it. + * + * Returns: Next character. + * + * Throws: ReaderException if trying to read past the end of the stream + * or if invalid data is read. + */ + dchar get() + { + const result = peek(); + forward(); + return result; + } + + /** + * Get specified number of characters, moving stream position beyond them. + * + * Params: length = Number or characters to get. + * + * Returns: Characters starting at current position. + * + * Throws: ReaderException if trying to read past the end of the stream + * or if invalid data is read. + */ + dstring get(in size_t length) + { + dstring result = prefix(length); + forward(length); + return result; + } + + /** + * Move current position forward. + * + * Params: length = Number of characters to move position forward. + * + * Throws: ReaderException if trying to read past the end of the stream + * or if invalid data is read. + */ + void forward(size_t length = 1) + { + updateBuffer(length + 1); + + while(length > 0) + { + const c = buffer_[bufferOffset_]; + ++bufferOffset_; + ++charIndex_; + //new line + if(['\n', '\x85', '\u2028', '\u2029'].canFind(c) || + (c == '\r' && buffer_[bufferOffset_] != '\n')) + { + ++line_; + column_ = 0; + } + else if(c != '\uFEFF'){++column_;} + --length; + } + } + + ///Get a string describing current stream position, used for error messages. + @property Mark mark() const {return Mark(line_, column_);} + + ///Get current line number. + @property uint line() const {return line_;} + + ///Get current line number. + @property uint column() const {return column_;} + + ///Get index of the current character in the stream. + @property size_t charIndex() const {return charIndex_;} + + private: + /** + * Update buffer to be able to read length characters after buffer offset. + * + * If there are not enough characters in the stream, it will get + * as many as possible. + * + * Params: length = Number of characters we need to read. + * + * Throws: ReaderException if trying to read past the end of the stream + * or if invalid data is read. + */ + void updateBuffer(in size_t length) + { + if(buffer_.length > bufferOffset_ + length){return;} + + //get rid of unneeded data in the buffer + if(bufferOffset_ > 0) + { + size_t bufferLength = buffer_.length - bufferOffset_; + memmove(buffer_.ptr, buffer_.ptr + bufferOffset_, + bufferLength * dchar.sizeof); + buffer_.length = bufferLength; + bufferOffset_ = 0; + } + + ////load chars in batches of at most 64 bytes + while(buffer_.length <= bufferOffset_ + length) + { + loadChars(16); + + if(done) + { + if(buffer_.length == 0 || buffer_[$ - 1] != '\0') + { + buffer_ ~= '\0'; + } + break; + } + } + } + + /** + * Load at most specified number of characters. + * + * Params: chars = Maximum number of characters to load. + * + * Throws: ReaderException on unicode decoding error, + * if nonprintable characters are detected, or + * if there is an error reading from the stream. + */ + void loadChars(in uint chars) + { + const oldLength = buffer_.length; + + /** + * Get next character from the stream. + * + * Params: available = Bytes available in the stream. + * + * Returns: Next character in the stream. + */ + dchar getDChar(in size_t available) + { + switch(utf_) + { + case UTF._8: + //Temp buffer for moving data in rawBuffer8_. + char[bufferLength8_] temp; + //Shortcut for ASCII. + if(rawUsed_ > 0 && rawBuffer8_[0] < 128) + { + //Get the first byte (one char in ASCII). + const dchar result = rawBuffer8_[0]; + --rawUsed_; + //Move the data. + temp[0 .. rawUsed_] = rawBuffer8_[1 .. rawUsed_ + 1]; + rawBuffer8_[0 .. rawUsed_] = temp[0 .. rawUsed_]; + return result; + } + + //Bytes to read. + const readBytes = min(available, bufferLength8_ - rawUsed_); + //Length of data in rawBuffer8_ after reading. + const len = rawUsed_ + readBytes; + //Read the data. + stream_.readExact(rawBuffer8_.ptr + rawUsed_, readBytes); + + //After decoding, this will point to the first byte not decoded. + size_t idx = 0; + const dchar result = decode(rawBuffer8_, idx); + rawUsed_ = cast(uint)(len - idx); + + //Move the data. + temp[0 .. rawUsed_] = rawBuffer8_[idx .. len]; + rawBuffer8_[0 .. rawUsed_] = temp[0 .. rawUsed_]; + return result; + case UTF._16: + //Temp buffer for moving data in rawBuffer8_. + wchar[bufferLength16_] temp; + //Words to read. + size_t readWords = min(available / 2, bufferLength16_ - rawUsed_); + //Length of data in rawBuffer16_ after reading. + size_t len = rawUsed_; + //Read the data. + while(readWords > 0) + { + //Due to a bug in std.stream, we have to use getcw here. + rawBuffer16_[len] = stream_.getcw(); + --readWords; + ++len; + } + + //After decoding, this will point to the first word not decoded. + size_t idx = 0; + const dchar result = decode(rawBuffer16_, idx); + rawUsed_ = cast(uint)(len - idx); + + //Move the data. + temp[0 .. rawUsed_] = rawBuffer16_[idx .. len]; + rawBuffer16_[0 .. rawUsed_] = temp[0 .. rawUsed_]; + return result; + case UTF._32: + dchar result; + stream_.read(result); + return result; + default: assert(false); + } + } + + const oldPosition = stream_.position; + try + { + foreach(i; 0 .. chars) + { + if(done){break;} + const available = stream_.available; + buffer_ ~= getDChar(available); + } + } + catch(UtfException e) + { + const position = stream_.position; + throw new ReaderException("Unicode decoding error between bytes " ~ + to!string(oldPosition) ~ " and " ~ + to!string(position) ~ " " ~ e.msg); + } + catch(ReadException e) + { + throw new ReaderException("Error reading from the stream: " ~ e.msg); + } + + enforce(printable(buffer_[oldLength .. $]), + new ReaderException("Special unicode characters are not allowed")); + } + + /** + * Determine if all characters in an array are printable. + * + * Params: chars = Characters to check. + * + * Returns: True if all the characters are printable, false otherwise. + */ + static pure bool printable(const ref dchar[] chars) + { + foreach(c; chars) + { + if(!((c == 0x09 || c == 0x0A || c == 0x0D || c == 0x85) || + (c >= 0x20 && c <= 0x7E) || + (c >= 0xA0 && c <= '\uD7FF') || + (c >= '\uE000' && c <= '\uFFFD'))) + { + return false; + } + } + return true; + } + + ///Are we done reading? + @property bool done() + { + return (stream_.available == 0 && + ((utf_ == UTF._8 && rawUsed_ == 0) || + (utf_ == UTF._16 && rawUsed_ == 0) || + utf_ == UTF._32)); + } + + unittest + { + writeln("D:YAML reader endian unittest"); + void endian_test(ubyte[] data, UTF utf_expected, Endian endian_expected) + { + auto reader = new Reader(new MemoryStream(data)); + assert(reader.utf_ == utf_expected); + assert(reader.stream_.endian == endian_expected); + } + ubyte[] little_endian_utf_16 = [0xFF, 0xFE, 0x7A, 0x00]; + ubyte[] big_endian_utf_16 = [0xFE, 0xFF, 0x00, 0x7A]; + endian_test(little_endian_utf_16, UTF._16, Endian.LittleEndian); + endian_test(big_endian_utf_16, UTF._16, Endian.BigEndian); + } + unittest + { + writeln("D:YAML reader peek/prefix/forward unittest"); + ubyte[] data = ByteOrderMarks[BOM.UTF8] ~ cast(ubyte[])"data"; + auto reader = new Reader(new MemoryStream(data)); + assert(reader.peek() == 'd'); + assert(reader.peek(1) == 'a'); + assert(reader.peek(2) == 't'); + assert(reader.peek(3) == 'a'); + assert(reader.peek(4) == '\0'); + assert(reader.prefix(4) == "data"); + assert(reader.prefix(6) == "data\0"); + reader.forward(2); + assert(reader.peek(1) == 'a'); + assert(collectException(reader.peek(3))); + } + unittest + { + writeln("D:YAML reader UTF formats unittest"); + dchar[] data = cast(dchar[])"data"; + void utf_test(T)(T[] data, BOM bom) + { + ubyte[] bytes = ByteOrderMarks[bom] ~ + (cast(ubyte*)data.ptr)[0 .. data.length * T.sizeof]; + auto reader = new Reader(new MemoryStream(bytes)); + assert(reader.peek() == 'd'); + assert(reader.peek(1) == 'a'); + assert(reader.peek(2) == 't'); + assert(reader.peek(3) == 'a'); + } + utf_test!char(to!(char[])(data), BOM.UTF8); + utf_test!wchar(to!(wchar[])(data), endian == Endian.BigEndian ? BOM.UTF16BE : BOM.UTF16LE); + utf_test(data, endian == Endian.BigEndian ? BOM.UTF32BE : BOM.UTF32LE); + } +} diff --git a/dyaml/resolver.d b/dyaml/resolver.d new file mode 100644 index 0000000..6f33547 --- /dev/null +++ b/dyaml/resolver.d @@ -0,0 +1,221 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * Implements a class that resolves YAML tags. This can be used to implicitly + * resolve tags for custom data types, removing the need to explicitly + * specify tags in YAML. A tutorial can be found + * $(LINK2 ../tutorials/custom_types.html, here). + * + * Code based on $(LINK2 http://www.pyyaml.org, PyYAML). + */ +module dyaml.resolver; + + +import std.conv; +import std.regex; +import std.stdio; +import std.typecons; +import std.utf; + +import dyaml.node; +import dyaml.exception; + + +/** + * Resolves YAML tags (data types). + * + * Can be used to implicitly resolve custom data types of scalar values. + */ +final class Resolver +{ + private: + ///Default tag to use for scalars. + static string defaultScalarTag_ = "tag:yaml.org,2002:str"; + ///Default tag to use for sequences. + static string defaultSequenceTag_ = "tag:yaml.org,2002:seq"; + ///Default tag to use for mappings. + static string defaultMappingTag_ = "tag:yaml.org,2002:map"; + /** + * Arrays of scalar resolver tuples indexed by starting character of a scalar. + * + * Each tuple stores regular expression the scalar must match, + * and tag to assign to it if it matches. + */ + Tuple!(string, Regex!char)[][dchar] yamlImplicitResolvers_; + + public: + /** + * Construct a Resolver. + * + * If you don't want to implicitly resolve default YAML tags/data types, + * you can use defaultImplicitResolvers to disable default resolvers. + * + * Params: defaultImplicitResolvers = Use default YAML implicit resolvers? + */ + this(in bool defaultImplicitResolvers = true) + { + if(defaultImplicitResolvers){addImplicitResolvers();} + } + + ///Destroy the Resolver. + ~this() + { + clear(yamlImplicitResolvers_); + yamlImplicitResolvers_ = null; + } + + /** + * Add an implicit scalar resolver. + * + * If a scalar matches regexp and starts with one of the characters in first, + * its _tag is set to tag. If the scalar matches more than one resolver + * regular expression, resolvers added _first override those added later. + * Default resolvers override any user specified resolvers. + * + * If a scalar is not resolved to anything, it is assigned the default + * YAML _tag for strings. + * + * Params: tag = Tag to resolve to. + * regexp = Regular expression the scalar must match to have this _tag. + * first = String of possible starting characters of the scalar. + */ + void addImplicitResolver(string tag, Regex!char regexp, in string first) + { + foreach(const dchar c; first) + { + if((c in yamlImplicitResolvers_) is null) + { + yamlImplicitResolvers_[c] = []; + } + yamlImplicitResolvers_[c] ~= tuple(tag, regexp); + } + } + + package: + /* + * Resolve tag of a node. + * + * Params: kind = Type of the node. + * tag = Explicit tag of the node, if any. + * value = Value of the node, if any. + * implicit = Should the node be implicitly resolved? + * + * If the tag is already specified and not non-specific, that tag will + * be returned. + * + * Returns: Resolved tag. + */ + string resolve(NodeID kind, string tag, string value, in bool implicit) + { + if(tag !is null && tag != "!"){return tag;} + + if(kind == NodeID.Scalar) + { + if(implicit) + { + //Get the first char of the value. + size_t dummy; + const dchar first = value.length == 0 ? '\0' : decode(value, dummy); + + auto resolvers = (first in yamlImplicitResolvers_) is null ? + [] : yamlImplicitResolvers_[first]; + + foreach(resolver; resolvers) + { + tag = resolver[0]; + auto regexp = resolver[1]; + if(!(match(value, regexp).empty)){return tag;} + } + } + return defaultScalarTag_; + } + else if(kind == NodeID.Sequence){return defaultSequenceTag_;} + else if(kind == NodeID.Mapping) {return defaultMappingTag_;} + assert(false, "This line of code should never be reached"); + } + unittest + { + writeln("D:YAML Resolver unittest"); + + auto resolver = new Resolver(); + + bool tagMatch(string tag, string[] values) + { + foreach(value; values) + { + if(tag != resolver.resolve(NodeID.Scalar, null, value, true)) + { + return false; + } + } + return true; + } + + assert(tagMatch("tag:yaml.org,2002:bool", + ["yes", "NO", "True", "on"])); + assert(tagMatch("tag:yaml.org,2002:float", + ["6.8523015e+5", "685.230_15e+03", "685_230.15", + "190:20:30.15", "-.inf", ".NaN"])); + assert(tagMatch("tag:yaml.org,2002:int", + ["685230", "+685_230", "02472256", "0x_0A_74_AE", + "0b1010_0111_0100_1010_1110", "190:20:30"])); + assert(tagMatch("tag:yaml.org,2002:merge", ["<<"])); + assert(tagMatch("tag:yaml.org,2002:null", ["~", "null", ""])); + assert(tagMatch("tag:yaml.org,2002:str", + ["abcd", "9a8b", "9.1adsf"])); + assert(tagMatch("tag:yaml.org,2002:timestamp", + ["2001-12-15T02:59:43.1Z", + "2001-12-14t21:59:43.10-05:00", + "2001-12-14 21:59:43.10 -5", + "2001-12-15 2:59:43.10", + "2002-12-14"])); + assert(tagMatch("tag:yaml.org,2002:value", ["="])); + assert(tagMatch("tag:yaml.org,2002:yaml", ["!", "&", "*"])); + } + + private: + ///Add default implicit resolvers. + void addImplicitResolvers() + { + addImplicitResolver("tag:yaml.org,2002:bool", + regex(r"^(?:yes|Yes|YES|no|No|NO|true|True|TRUE" + "|false|False|FALSE|on|On|ON|off|Off|OFF)$"), + "yYnNtTfFoO"); + addImplicitResolver("tag:yaml.org,2002:float", + regex(r"^(?:[-+]?([0-9][0-9_]*)\\.[0-9_]*" + "(?:[eE][-+][0-9]+)?|[-+]?(?:[0-9][0-9_]" + "*)?\\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?" + "[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]" + "*|[-+]?\\.(?:inf|Inf|INF)|\\." + "(?:nan|NaN|NAN))$"), + "-+0123456789."); + addImplicitResolver("tag:yaml.org,2002:int", + regex(r"^(?:[-+]?0b[0-1_]+" + "|[-+]?0[0-7_]+" + "|[-+]?(?:0|[1-9][0-9_]*)" + "|[-+]?0x[0-9a-fA-F_]+" + "|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$"), + "-+0123456789"); + addImplicitResolver("tag:yaml.org,2002:merge", regex(r"^<<$"), "<"); + + addImplicitResolver("tag:yaml.org,2002:null", + regex(r"^(?:~|null|Null|NULL|\0)?$"), "~nN\0"); + addImplicitResolver("tag:yaml.org,2002:timestamp", + regex(r"^[0-9][0-9][0-9][0-9]-[0-9][0-9]-" + "[0-9][0-9]|[0-9][0-9][0-9][0-9]-[0-9]" + "[0-9]?-[0-9][0-9]?[Tt]|[ \t]+[0-9]" + "[0-9]?:[0-9][0-9]:[0-9][0-9]" + "(?:\\.[0-9]*)?(?:[ \t]*Z|[-+][0-9]" + "[0-9]?(?::[0-9][0-9])?)?$"), "0123456789"); + addImplicitResolver("tag:yaml.org,2002:value", regex(r"^=$"), "="); + + + //The following resolver is only for documentation purposes. It cannot work + //because plain scalars cannot start with '!', '&', or '*'. + addImplicitResolver("tag:yaml.org,2002:yaml", regex(r"^(?:!|&|\*)$"), "!&*"); + } +} diff --git a/dyaml/scanner.d b/dyaml/scanner.d new file mode 100644 index 0000000..28e17c3 --- /dev/null +++ b/dyaml/scanner.d @@ -0,0 +1,1632 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * YAML scanner. + * Code based on PyYAML: http://www.pyyaml.org + */ +module dyaml.scanner; + + +import core.stdc.string; + +import std.algorithm; +import std.array; +import std.conv; +import std.ascii : isAlphaNum, isDigit, isHexDigit; +import std.exception; +import std.string; +import std.typecons; +import std.utf; + +import dyaml.exception; +import dyaml.reader; +import dyaml.token; +import dyaml.util; + + +package: +/** + * Scanner produces tokens of the following types: + * STREAM-START + * STREAM-END + * DIRECTIVE(name, value) + * DOCUMENT-START + * DOCUMENT-END + * BLOCK-SEQUENCE-START + * BLOCK-MAPPING-START + * BLOCK-END + * FLOW-SEQUENCE-START + * FLOW-MAPPING-START + * FLOW-SEQUENCE-END + * FLOW-MAPPING-END + * BLOCK-ENTRY + * FLOW-ENTRY + * KEY + * VALUE + * ALIAS(value) + * ANCHOR(value) + * TAG(value) + * SCALAR(value, plain, style) + */ + + +/** + * Marked exception thrown at scanner errors. + * + * See_Also: MarkedYAMLException + */ +class ScannerException : MarkedYAMLException +{ + this(string context, Mark contextMark, string problem, Mark problemMark) + { + super(context, contextMark, problem, problemMark); + } + + this(string problem, Mark problemMark){super(problem, problemMark);} +} + +///Generates tokens from data provided by a Reader. +final class Scanner +{ + private: + /** + * A simple key is a key that is not denoted by the '?' indicator. + * For example: + * --- + * block simple key: value + * ? not a simple key: + * : { flow simple key: value } + * We emit the KEY token before all keys, so when we find a potential + * simple key, we try to locate the corresponding ':' indicator. + * Simple keys should be limited to a single line and 1024 characters. + * + * 24 bytes on 64-bit. + */ + static struct SimpleKey + { + ///Character index in reader where the key starts. + size_t charIndex; + ///Index of the key token from start (first token scanned being 0). + uint tokenIndex; + ///Line the key starts at. + uint line; + ///Column the key starts at. + uint column; + ///Is this required to be a simple key? + bool required; + } + + ///Block chomping types. + enum Chomping + { + ///Strip all trailing line breaks. '-' indicator. + Strip, + ///Line break of the last line is preserved, others discarded. Default. + Clip, + ///All trailing line breaks are preserved. '+' indicator. + Keep + } + + ///Reader used to read from a file/stream. + Reader reader_; + ///Are we done scanning? + bool done_; + + ///Level of nesting in flow context. If 0, we're in block context. + uint flowLevel_; + ///Current indentation level. + int indent_ = -1; + ///Past indentation levels. Used as a stack. + int[] indents_; + + //Should be replaced by a queue or linked list once Phobos has anything usable. + ///Processed tokens not yet emitted. Used as a queue. + Token[] tokens_; + ///Number of tokens emitted through the getToken method. + uint tokensTaken_; + + /** + * Can a simple key start at the current position? A simple key may + * start: + * - at the beginning of the line, not counting indentation spaces + * (in block context), + * - after '{', '[', ',' (in the flow context), + * - after '?', ':', '-' (in the block context). + * In the block context, this flag also signifies if a block collection + * may start at the current position. + */ + bool allowSimpleKey_ = true; + ///Possible simple keys indexed by flow levels. + SimpleKey[uint] possibleSimpleKeys_; + + public: + ///Construct a Scanner using specified Reader. + this(Reader reader) + { + //Return the next token, but do not delete it from the queue + reader_ = reader; + fetchStreamStart(); + } + + ///Destroy the scanner. + ~this() + { + clear(tokens_); + tokens_ = null; + clear(indents_); + indents_ = null; + clear(possibleSimpleKeys_); + possibleSimpleKeys_ = null; + reader_ = null; + } + + /** + * Check if the next token is one of specified types. + * + * If no types are specified, checks if any tokens are left. + * + * Params: ids = Token IDs to check for. + * + * Returns: true if the next token is one of specified types, + * or if there are any tokens left if no types specified. + * false otherwise. + */ + bool checkToken(TokenID[] ids ...) + { + //Check if the next token is one of specified types. + while(needMoreTokens()){fetchToken();} + if(!tokens_.empty) + { + if(ids.length == 0){return true;} + else + { + const nextId = tokens_.front.id; + foreach(id; ids) + { + if(nextId == id){return true;} + } + } + } + return false; + } + + /** + * Return the next token, but keep it in the queue. + * + * Must not be called if there are no tokens left. + */ + ref Token peekToken() + { + while(needMoreTokens){fetchToken();} + if(!tokens_.empty){return tokens_.front;} + assert(false, "No token left to peek"); + } + + /** + * Return the next token, removing it from the queue. + * + * Must not be called if there are no tokens left. + */ + Token getToken() + { + while(needMoreTokens){fetchToken();} + if(!tokens_.empty) + { + ++tokensTaken_; + Token result = tokens_.front; + tokens_.popFront(); + return result; + } + assert(false, "No token left to get"); + } + + private: + ///Determine whether or not we need to fetch more tokens before peeking/getting a token. + bool needMoreTokens() + { + if(done_) {return false;} + if(tokens_.empty){return true;} + + ///The current token may be a potential simple key, so we need to look further. + stalePossibleSimpleKeys(); + return nextPossibleSimpleKey() == tokensTaken_; + } + + ///Fetch at token, adding it to tokens_. + void fetchToken() + { + ///Eat whitespaces and comments until we reach the next token. + scanToNextToken(); + + //Remove obsolete possible simple keys. + stalePossibleSimpleKeys(); + + //Compare current indentation and column. It may add some tokens + //and decrease the current indentation level. + unwindIndent(reader_.column); + + //Get the next character. + dchar c = reader_.peek(); + + //Fetch the token. + if(c == '\0') {return fetchStreamEnd();} + if(checkDirective()) {return fetchDirective();} + if(checkDocumentStart()) {return fetchDocumentStart();} + if(checkDocumentEnd()) {return fetchDocumentEnd();} + //Order of the following checks is NOT significant. + if(c == '[') {return fetchFlowSequenceStart();} + if(c == '{') {return fetchFlowMappingStart();} + if(c == ']') {return fetchFlowSequenceEnd();} + if(c == '}') {return fetchFlowMappingEnd();} + if(c == ',') {return fetchFlowEntry();} + if(checkBlockEntry()) {return fetchBlockEntry();} + if(checkKey()) {return fetchKey();} + if(checkValue()) {return fetchValue();} + if(c == '*') {return fetchAlias();} + if(c == '&') {return fetchAnchor();} + if(c == '!') {return fetchTag();} + if(c == '|' && flowLevel_ == 0){return fetchLiteral();} + if(c == '>' && flowLevel_ == 0){return fetchFolded();} + if(c == '\'') {return fetchSingle();} + if(c == '\"') {return fetchDouble();} + if(checkPlain()) {return fetchPlain();} + + throw new ScannerException(format("While scanning for the next token, found " + "character \'", c, "\', index ",to!int(c), + " that cannot start " "any token"), reader_.mark); + } + + + ///Return the token number of the nearest possible simple key. + uint nextPossibleSimpleKey() + { + uint minTokenNumber = uint.max; + foreach(k, ref simpleKey; possibleSimpleKeys_) + { + minTokenNumber = min(minTokenNumber, simpleKey.tokenIndex); + } + return minTokenNumber; + } + + /** + * Remove entries that are no longer possible simple keys. + * + * According to the YAML specification, simple keys + * - should be limited to a single line, + * - should be no longer than 1024 characters. + * Disabling this will allow simple keys of any length and + * height (may cause problems if indentation is broken though). + */ + void stalePossibleSimpleKeys() + { + uint[] levelsToRemove; + foreach(level, ref key; possibleSimpleKeys_) + { + if(key.line != reader_.line || reader_.charIndex - key.charIndex > 1024) + { + enforce(!key.required, + new ScannerException("While scanning a simple key", + Mark(key.line, key.column), + "could not find expected ':'", reader_.mark)); + levelsToRemove ~= level; + } + } + foreach(level; levelsToRemove){possibleSimpleKeys_.remove(level);} + } + + /** + * Check if the next token starts a possible simple key and if so, save its position. + * + * This function is called for ALIAS, ANCHOR, TAG, SCALAR(flow), '[', and '{'. + */ + void savePossibleSimpleKey() + { + //Check if a simple key is required at the current position. + bool required = (flowLevel_ == 0 && indent_ == reader_.column); + assert(allowSimpleKey_ || !required, "A simple key is required only if it is " + "the first token in the current line. Therefore it is always allowed."); + + if(!allowSimpleKey_){return;} + + //The next token might be a simple key, so save its number and position. + removePossibleSimpleKey(); + uint tokenCount = tokensTaken_ + cast(uint)tokens_.length; + auto key = SimpleKey(reader_.charIndex, tokenCount, reader_.line, + reader_.column, required); + possibleSimpleKeys_[flowLevel_] = key; + } + + ///Remove the saved possible key position at the current flow level. + void removePossibleSimpleKey() + { + if((flowLevel_ in possibleSimpleKeys_) !is null) + { + auto key = possibleSimpleKeys_[flowLevel_]; + enforce(!key.required, + new ScannerException("While scanning a simple key", + Mark(key.line, key.column), + "could not find expected ':'", + reader_.mark)); + possibleSimpleKeys_.remove(flowLevel_); + } + } + + /** + * Decrease indentation, removing entries in indents_. + * + * Params: column = Current column in the file/stream. + */ + void unwindIndent(int column) + { + if(flowLevel_ > 0) + { + //In flow context, tokens should respect indentation. + //The condition should be `indent >= column` according to the spec. + //But this condition will prohibit intuitively correct + //constructions such as + //key : { + //} + + //In the flow context, indentation is ignored. We make the scanner less + //restrictive than what the specification requires. + //if(pedantic_ && flowLevel_ > 0 && indent_ > column) + //{ + // throw new ScannerException("Invalid intendation or unclosed '[' or '{'", + // reader_.mark) + //} + return; + } + + //In block context, we may need to issue the BLOCK-END tokens. + while(indent_ > column) + { + indent_ = indents_.back; + indents_.popBack(); + tokens_ ~= blockEndToken(reader_.mark, reader_.mark); + } + } + + /** + * Increase indentation if needed. + * + * Params: column = Current column in the file/stream. + * + * Returns: true if the indentation was increased, false otherwise. + */ + bool addIndent(int column) + { + if(indent_ >= column){return false;} + indents_ ~= indent_; + indent_ = column; + return true; + } + + + ///Add STREAM-START token. + void fetchStreamStart() + { + tokens_ ~= streamStartToken(reader_.mark, reader_.mark); + } + + ///Add STREAM-END token. + void fetchStreamEnd() + { + //Set intendation to -1 . + unwindIndent(-1); + removePossibleSimpleKey(); + allowSimpleKey_ = false; + //There's probably a saner way to clear an associated array than this. + SimpleKey[uint] empty; + possibleSimpleKeys_ = empty; + + tokens_ ~= streamEndToken(reader_.mark, reader_.mark); + done_ = true; + } + + ///Add DIRECTIVE token. + void fetchDirective() + { + //Set intendation to -1 . + unwindIndent(-1); + //Reset simple keys. + removePossibleSimpleKey(); + allowSimpleKey_ = false; + + tokens_ ~= scanDirective(); + } + + ///Add DOCUMENT-START or DOCUMENT-END token. + void fetchDocumentIndicator(TokenID id)() + if(id == TokenID.DocumentStart || id == TokenID.DocumentEnd) + { + //Set indentation to -1 . + unwindIndent(-1); + //Reset simple keys. Note that there can't be a block collection after '---'. + removePossibleSimpleKey(); + allowSimpleKey_ = false; + + Mark startMark = reader_.mark; + reader_.forward(3); + tokens_ ~= simpleToken!id(startMark, reader_.mark); + } + + ///Aliases to add DOCUMENT-START or DOCUMENT-END token. + alias fetchDocumentIndicator!(TokenID.DocumentStart) fetchDocumentStart; + alias fetchDocumentIndicator!(TokenID.DocumentEnd) fetchDocumentEnd; + + ///Add FLOW-SEQUENCE-START or FLOW-MAPPING-START token. + void fetchFlowCollectionStart(TokenID id)() + { + //'[' and '{' may start a simple key. + savePossibleSimpleKey(); + //Simple keys are allowed after '[' and '{'. + allowSimpleKey_ = true; + ++flowLevel_; + + Mark startMark = reader_.mark; + reader_.forward(); + tokens_ ~= simpleToken!id(startMark, reader_.mark); + } + + ///Aliases to add FLOW-SEQUENCE-START or FLOW-MAPPING-START token. + alias fetchFlowCollectionStart!(TokenID.FlowSequenceStart) fetchFlowSequenceStart; + alias fetchFlowCollectionStart!(TokenID.FlowMappingStart) fetchFlowMappingStart; + + ///Add FLOW-SEQUENCE-START or FLOW-MAPPING-START token. + void fetchFlowCollectionEnd(TokenID id)() + { + //Reset possible simple key on the current level. + removePossibleSimpleKey(); + //No simple keys after ']' and '}'. + allowSimpleKey_ = false; + --flowLevel_; + + Mark startMark = reader_.mark; + reader_.forward(); + tokens_ ~= simpleToken!id(startMark, reader_.mark); + } + + ///Aliases to add FLOW-SEQUENCE-START or FLOW-MAPPING-START token/ + alias fetchFlowCollectionEnd!(TokenID.FlowSequenceEnd) fetchFlowSequenceEnd; + alias fetchFlowCollectionEnd!(TokenID.FlowMappingEnd) fetchFlowMappingEnd; + + ///Add FLOW-ENTRY token; + void fetchFlowEntry() + { + //Reset possible simple key on the current level. + removePossibleSimpleKey(); + //Simple keys are allowed after ','. + allowSimpleKey_ = true; + + Mark startMark = reader_.mark; + reader_.forward(); + tokens_ ~= flowEntryToken(startMark, reader_.mark); + } + + /** + * Additional checks used in block context in fetchBlockEntry and fetchKey. + * + * Params: type = String representing the token type we might need to add. + * id = Token type we might need to add. + */ + void blockChecks(string type, TokenID id)() + { + //Are we allowed to start a key (not neccesarily a simple one)? + enforce(allowSimpleKey_, new ScannerException(type ~ " keys are not allowed here", + reader_.mark)); + + if(addIndent(reader_.column)) + { + tokens_ ~= simpleToken!id(reader_.mark, reader_.mark); + } + } + + ///Add BLOCK-ENTRY token. Might add BLOCK-SEQUENCE-START in the process. + void fetchBlockEntry() + { + if(flowLevel_ == 0){blockChecks!("Sequence", TokenID.BlockSequenceStart)();} + + //It's an error for the block entry to occur in the flow context, + //but we let the parser detect this. + + //Reset possible simple key on the current level. + removePossibleSimpleKey(); + //Simple keys are allowed after '-'. + allowSimpleKey_ = true; + + Mark startMark = reader_.mark; + reader_.forward(); + tokens_ ~= blockEntryToken(startMark, reader_.mark); + } + + ///Add KEY token. Might add BLOCK-MAPPING-START in the process. + void fetchKey() + { + if(flowLevel_ == 0){blockChecks!("Mapping", TokenID.BlockMappingStart)();} + + //Reset possible simple key on the current level. + removePossibleSimpleKey(); + //Simple keys are allowed after '?' in the block context. + allowSimpleKey_ = (flowLevel_ == 0); + + Mark startMark = reader_.mark; + reader_.forward(); + tokens_ ~= keyToken(startMark, reader_.mark); + } + + ///Add VALUE token. Might add KEY and/or BLOCK-MAPPING-START in the process. + void fetchValue() + { + //Do we determine a simple key? + if(canFind(possibleSimpleKeys_.keys, flowLevel_)) + { + auto key = possibleSimpleKeys_[flowLevel_]; + possibleSimpleKeys_.remove(flowLevel_); + Mark keyMark = Mark(key.line, key.column); + auto idx = key.tokenIndex - tokensTaken_; + + assert(idx >= 0); + + //Add KEY. + //Manually inserting since tokens are immutable (need linked list). + tokens_ = tokens_[0 .. idx] ~ keyToken(keyMark, keyMark) ~ + tokens_[idx .. tokens_.length]; + + //If this key starts a new block mapping, we need to add BLOCK-MAPPING-START. + if(flowLevel_ == 0 && addIndent(key.column)) + { + tokens_ = tokens_[0 .. idx] ~ blockMappingStartToken(keyMark, keyMark) ~ + tokens_[idx .. tokens_.length]; + } + + //There cannot be two simple keys in a row. + allowSimpleKey_ = false; + } + //Part of a complex key + else + { + //We can start a complex value if and only if we can start a simple key. + enforce(flowLevel_ > 0 || allowSimpleKey_, + new ScannerException("Mapping values are not allowed here", + reader_.mark)); + + //If this value starts a new block mapping, we need to add + //BLOCK-MAPPING-START. It'll be detected as an error later by the parser. + if(flowLevel_ == 0 && addIndent(reader_.column)) + { + tokens_ ~= blockMappingStartToken(reader_.mark, reader_.mark); + } + + //Reset possible simple key on the current level. + removePossibleSimpleKey(); + //Simple keys are allowed after ':' in the block context. + allowSimpleKey_ = (flowLevel_ == 0); + } + + //Add VALUE. + Mark startMark = reader_.mark; + reader_.forward(); + tokens_ ~= valueToken(startMark, reader_.mark); + } + + ///Add ALIAS or ANCHOR token. + void fetchAnchor_(TokenID id)() + if(id == TokenID.Alias || id == TokenID.Anchor) + { + //ALIAS/ANCHOR could be a simple key. + savePossibleSimpleKey(); + //No simple keys after ALIAS/ANCHOR. + allowSimpleKey_ = false; + + tokens_ ~= scanAnchor(id); + } + + ///Aliases to add ALIAS or ANCHOR token. + alias fetchAnchor_!(TokenID.Alias) fetchAlias; + alias fetchAnchor_!(TokenID.Anchor) fetchAnchor; + + ///Add TAG token. + void fetchTag() + { + //TAG could start a simple key. + savePossibleSimpleKey(); + //No simple keys after TAG. + allowSimpleKey_ = false; + + tokens_ ~= scanTag(); + } + + ///Add block SCALAR token. + void fetchBlockScalar(ScalarStyle style)() + if(style == ScalarStyle.Literal || style == ScalarStyle.Folded) + { + //Reset possible simple key on the current level. + removePossibleSimpleKey(); + //A simple key may follow a block scalar. + allowSimpleKey_ = true; + + tokens_ ~= scanBlockScalar(style); + } + + ///Aliases to add literal or folded block scalar. + alias fetchBlockScalar!(ScalarStyle.Literal) fetchLiteral; + alias fetchBlockScalar!(ScalarStyle.Folded) fetchFolded; + + ///Add quoted flow SCALAR token. + void fetchFlowScalar(ScalarStyle quotes)() + { + //A flow scalar could be a simple key. + savePossibleSimpleKey(); + //No simple keys after flow scalars. + allowSimpleKey_ = false; + + //Scan and add SCALAR. + tokens_ ~= scanFlowScalar(quotes); + } + + ///Aliases to add single or double quoted block scalar. + alias fetchFlowScalar!(ScalarStyle.SingleQuoted) fetchSingle; + alias fetchFlowScalar!(ScalarStyle.DoubleQuoted) fetchDouble; + + ///Add plain SCALAR token. + void fetchPlain() + { + //A plain scalar could be a simple key + savePossibleSimpleKey(); + //No simple keys after plain scalars. But note that scanPlain() will + //change this flag if the scan is finished at the beginning of the line. + allowSimpleKey_ = false; + + //Scan and add SCALAR. May change allowSimpleKey_ + tokens_ ~= scanPlain(); + } + + + ///Check if the next token is DIRECTIVE: ^ '%' ... + bool checkDirective(){return reader_.peek() == '%' && reader_.column == 0;} + + ///Check if the next token is DOCUMENT-START: ^ '---' (' '|'\n') + bool checkDocumentStart() + { + //Check one char first, then all 3, to prevent reading outside stream. + return reader_.column == 0 && + reader_.peek() == '-' && + reader_.prefix(3) == "---" && + or!(isBreakOrZero, isSpace)(reader_.peek(3)); + } + + ///Check if the next token is DOCUMENT-END: ^ '...' (' '|'\n') + bool checkDocumentEnd() + { + //Check one char first, then all 3, to prevent reading outside stream. + return reader_.column == 0 && + reader_.peek() == '.' && + reader_.prefix(3) == "..." && + or!(isBreakOrZero, isSpace)(reader_.peek(3)); + } + + ///Check if the next token is BLOCK-ENTRY: '-' (' '|'\n') + bool checkBlockEntry() + { + return reader_.peek() == '-' && or!(isBreakOrZero, isSpace)(reader_.peek(1)); + } + + /** + * Check if the next token is KEY(flow context): '?' + * + * or KEY(block context): '?' (' '|'\n') + */ + bool checkKey() + { + return reader_.peek() == '?' && + (flowLevel_ > 0 || or!(isBreakOrZero, isSpace)(reader_.peek(1))); + } + + /** + * Check if the next token is VALUE(flow context): ':' + * + * or VALUE(block context): ':' (' '|'\n') + */ + bool checkValue() + { + return reader_.peek() == ':' && + (flowLevel_ > 0 || or!(isBreakOrZero, isSpace)(reader_.peek(1))); + } + + /** + * Check if the next token is a plain scalar. + * + * A plain scalar may start with any non-space character except: + * '-', '?', ':', ',', '[', ']', '{', '}', + * '#', '&', '*', '!', '|', '>', '\'', '\"', + * '%', '@', '`'. + * + * It may also start with + * '-', '?', ':' + * if it is followed by a non-space character. + * + * Note that we limit the last rule to the block context (except the + * '-' character) because we want the flow context to be space + * independent. + */ + bool checkPlain() + { + const c = reader_.peek(); + return !(or!(isBreakOrZero, isSpace)(c) || "-?:,[]{}#&*!|>\'\"%@`".canFind(c)) || + (!or!(isBreakOrZero, isSpace)(reader_.peek(1)) && + (c == '-' || (flowLevel_ == 0 && "?:".canFind(c)))); + } + + + ///Move to the next non-space character. + void findNextNonSpace() + { + while(reader_.peek() == ' '){reader_.forward();} + } + + ///Scan a string of alphanumeric or "-_" characters. + dstring scanAlphaNumeric(string name)(in Mark startMark) + { + uint length = 0; + dchar c = reader_.peek(); + while(isAlphaNum(c) || "-_".canFind(c)) + { + ++length; + c = reader_.peek(length); + } + + enforce(length > 0, + new ScannerException("While scanning " ~ name, startMark, + "expected alphanumeric, - or _, but found " + ~ to!string(c), reader_.mark)); + + return reader_.get(length); + } + + ///Scan all characters until nex line break. + dstring scanToNextBreak() + { + uint length = 0; + while(!isBreakOrZero(reader_.peek(length))){++length;} + return reader_.get(length); + } + + /** + * Move to next token in the file/stream. + * + * We ignore spaces, line breaks and comments. + * If we find a line break in the block context, we set + * allowSimpleKey` on. + * + * We do not yet support BOM inside the stream as the + * specification requires. Any such mark will be considered as a part + * of the document. + */ + void scanToNextToken() + { + //TODO(PyYAML): We need to make tab handling rules more sane. A good rule is: + // Tabs cannot precede tokens + // BLOCK-SEQUENCE-START, BLOCK-MAPPING-START, BLOCK-END, + // KEY(block), VALUE(block), BLOCK-ENTRY + //So the checking code is + // if : + // allowSimpleKey_ = false + //We also need to add the check for `allowSimpleKey_ == true` to + //`unwindIndent` before issuing BLOCK-END. + //Scanners for block, flow, and plain scalars need to be modified. + + for(;;) + { + findNextNonSpace(); + + if(reader_.peek() == '#'){scanToNextBreak();} + if(scanLineBreak() != '\0') + { + if(flowLevel_ == 0){allowSimpleKey_ = true;} + } + else{break;} + } + } + + ///Scan directive token. + Token scanDirective() + { + Mark startMark = reader_.mark; + //Skip the '%'. + reader_.forward(); + + const name = scanDirectiveName(startMark); + const value = name == "YAML" ? scanYAMLDirectiveValue(startMark): + name == "TAG" ? scanTagDirectiveValue(startMark) : ""; + + Mark endMark = reader_.mark; + + if(!["YAML"d, "TAG"d].canFind(name)){scanToNextBreak();} + scanDirectiveIgnoredLine(startMark); + + //Storing directive name and value in a single string, separated by zero. + return directiveToken(startMark, endMark, to!string(name ~ '\0' ~ value)); + } + + ///Scan name of a directive token. + dstring scanDirectiveName(in Mark startMark) + { + //Scan directive name. + const name = scanAlphaNumeric!"a directive"(startMark); + + enforce(or!(isChar!' ', isBreakOrZero)(reader_.peek()), + new ScannerException("While scanning a directive", startMark, + "expected alphanumeric, - or _, but found " + ~ to!string(reader_.peek()), reader_.mark)); + return name; + } + + ///Scan value of a YAML directive token. Returns major, minor version separated by '.'. + dstring scanYAMLDirectiveValue(in Mark startMark) + { + findNextNonSpace(); + + dstring result = scanYAMLDirectiveNumber(startMark); + enforce(reader_.peek() == '.', + new ScannerException("While scanning a directive", startMark, + "expected a digit or '.', but found: " + ~ to!string(reader_.peek()), reader_.mark)); + //Skip the '.'. + reader_.forward(); + + result ~= '.' ~ scanYAMLDirectiveNumber(startMark); + enforce(or!(isChar!' ', isBreakOrZero)(reader_.peek()), + new ScannerException("While scanning a directive", startMark, + "expected a digit or '.', but found: " + ~ to!string(reader_.peek()), reader_.mark)); + return result; + } + + ///Scan a number from a YAML directive. + dstring scanYAMLDirectiveNumber(in Mark startMark) + { + enforce(isDigit(reader_.peek()), + new ScannerException("While scanning a directive", startMark, + "expected a digit, but found: " ~ + to!string(reader_.peek()), reader_.mark)); + + //Already found the first digit in the enforce(), so set length to 1. + uint length = 1; + while(isDigit(reader_.peek(length))){++length;} + + return reader_.get(length); + } + + ///Scan value of a tag directive. + dstring scanTagDirectiveValue(in Mark startMark) + { + findNextNonSpace(); + dstring handle = scanTagDirectiveHandle(startMark); + findNextNonSpace(); + return handle ~ '\0' ~ scanTagDirectivePrefix(startMark); + } + + ///Scan handle of a tag directive. + dstring scanTagDirectiveHandle(in Mark startMark) + { + const value = scanTagHandle("directive", startMark); + enforce(reader_.peek() == ' ', + new ScannerException("While scanning a directive handle", startMark, + "expected ' ', but found: " ~ + to!string(reader_.peek()), reader_.mark)); + return value; + } + + ///Scan prefix of a tag directive. + dstring scanTagDirectivePrefix(in Mark startMark) + { + const value = scanTagURI("directive", startMark); + enforce(or!(isChar!' ', isBreakOrZero)(reader_.peek()), + new ScannerException("While scanning a directive prefix", startMark, + "expected ' ', but found" ~ to!string(reader_.peek()), + reader_.mark)); + + return value; + } + + ///Scan (and ignore) ignored line after a directive. + void scanDirectiveIgnoredLine(in Mark startMark) + { + findNextNonSpace(); + if(reader_.peek() == '#'){scanToNextBreak();} + enforce(isBreakOrZero(reader_.peek()), + new ScannerException("While scanning a directive", startMark, + "expected comment or a line break, but found" + ~ to!string(reader_.peek()), reader_.mark)); + scanLineBreak(); + } + + + /** + * Scan an alias or an anchor. + * + * The specification does not restrict characters for anchors and + * aliases. This may lead to problems, for instance, the document: + * [ *alias, value ] + * can be interpteted in two ways, as + * [ "value" ] + * and + * [ *alias , "value" ] + * Therefore we restrict aliases to ASCII alphanumeric characters. + */ + Token scanAnchor(TokenID id) + { + const startMark = reader_.mark; + + dchar i = reader_.get(); + + dstring value = i == '*' ? scanAlphaNumeric!("an alias")(startMark) + : scanAlphaNumeric!("an anchor")(startMark); + + enforce((or!(isSpace, isBreakOrZero)(reader_.peek()) || + ("?:,]}%@").canFind(reader_.peek())), + new ScannerException("While scanning an " ~ (i == '*') ? "alias" : "anchor", + startMark, "expected alphanumeric, - or _, but found "~ + to!string(reader_.peek()), reader_.mark)); + + if(id == TokenID.Alias) + { + return aliasToken(startMark, reader_.mark, to!string(value)); + } + else if(id == TokenID.Anchor) + { + return anchorToken(startMark, reader_.mark, to!string(value)); + } + assert(false, "This code should never be reached"); + } + + ///Scan a tag token. + Token scanTag() + { + const startMark = reader_.mark; + dchar c = reader_.peek(1); + dstring handle = ""; + dstring suffix; + + if(c == '<') + { + reader_.forward(2); + suffix = scanTagURI("tag", startMark); + enforce(reader_.peek() == '>', + new ScannerException("While scanning a tag", startMark, + "expected '>' but found" ~ + to!string(reader_.peek()), reader_.mark)); + reader_.forward(); + } + else if(or!(isSpace, isBreakOrZero)(c)) + { + suffix = "!"; + reader_.forward(); + } + else + { + uint length = 1; + bool useHandle = false; + + while(!or!(isChar!' ', isBreakOrZero)(c)) + { + if(c == '!') + { + useHandle = true; + break; + } + ++length; + c = reader_.peek(length); + } + + if(useHandle){handle = scanTagHandle("tag", startMark);} + else + { + handle = "!"; + reader_.forward(); + } + + suffix = scanTagURI("tag", startMark); + } + + enforce(or!(isChar!' ', isBreakOrZero)(reader_.peek()), + new ScannerException("While scanning a tag", startMark, + "expected ' ' but found" ~ + to!string(reader_.peek()), reader_.mark)); + return tagToken(startMark, reader_.mark, to!string(handle ~ '\0' ~ suffix)); + } + + + ///Scan a block scalar token with specified style. + Token scanBlockScalar(ScalarStyle style) + { + const startMark = reader_.mark; + + //Scan the header. + reader_.forward(); + + const indicators = scanBlockScalarIndicators(startMark); + const chomping = indicators[0]; + const increment = indicators[1]; + scanBlockScalarIgnoredLine(startMark); + + //Determine the indentation level and go to the first non-empty line. + Mark endMark; + dchar[] breaks; + uint indent = min(1, indent_ + 1); + if(increment == int.min) + { + auto indentation = scanBlockScalarIndentation(); + breaks = indentation[0]; + endMark = indentation[2]; + indent = max(indent, indentation[1]); + } + else + { + indent += increment - 1; + auto scalarBreaks = scanBlockScalarBreaks(indent); + breaks = scalarBreaks[0]; + endMark = scalarBreaks[1]; + } + + dstring lineBreak = ""; + + //Used to construct the result. + auto appender = Appender!string(); + + //Scan the inner part of the block scalar. + while(reader_.column == indent && reader_.peek() != '\0') + { + appender.put(breaks); + const bool leadingNonSpace = !isSpace(reader_.peek()); + appender.put(scanToNextBreak()); + lineBreak = ""d ~ scanLineBreak(); + + auto scalarBreaks = scanBlockScalarBreaks(indent); + breaks = scalarBreaks[0]; + endMark = scalarBreaks[1]; + + if(reader_.column == indent && reader_.peek() != '\0') + { + //Unfortunately, folding rules are ambiguous. + + //This is the folding according to the specification: + if(style == ScalarStyle.Folded && lineBreak == "\n" && + leadingNonSpace && !isSpace(reader_.peek())) + { + if(breaks.length == 0){appender.put(' ');} + } + else{appender.put(lineBreak);} + ////this is Clark Evans's interpretation (also in the spec + ////examples): + // + //if(style == ScalarStyle.Folded && lineBreak == "\n"d) + //{ + // if(breaks.length == 0) + // { + // if(!" \t"d.canFind(reader_.peek())){appender.put(' ');} + // else{chunks ~= lineBreak;} + // } + //} + //else{appender.put(lineBreak);} + } + else{break;} + } + if(chomping != Chomping.Strip){appender.put(lineBreak);} + if(chomping == Chomping.Keep){appender.put(breaks);} + + return scalarToken(startMark, endMark, to!string(appender.data), style); + } + + ///Scan chomping and indentation indicators of a scalar token. + Tuple!(Chomping, int) scanBlockScalarIndicators(in Mark startMark) + { + auto chomping = Chomping.Clip; + int increment = int.min; + dchar c = reader_.peek(); + + ///Get chomping indicator, if detected. Return false otherwise. + bool getChomping() + { + if(!"+-".canFind(c)){return false;} + chomping = c == '+' ? Chomping.Keep : Chomping.Strip; + reader_.forward(); + c = reader_.peek(); + return true; + } + + ///Get increment indicator, if detected. Return false otherwise. + bool getIncrement() + { + if(!isDigit(c)){return false;} + increment = to!int(""d ~ c); + enforce(increment != 0, + new ScannerException("While scanning a block scalar", startMark, + "expected indentation indicator in range 1-9, " + "but found 0", reader_.mark)); + reader_.forward(); + c = reader_.peek(); + return true; + } + + ///Indicators can be in any order. + if(getChomping()) {getIncrement();} + else if(getIncrement()){getChomping();} + + enforce(or!(isBreakOrZero, isChar!' ')(c), + new ScannerException("While scanning a block scalar", startMark, + "expected chomping or indentation indicator, " + "but found " ~ to!string(c), reader_.mark)); + + return tuple(chomping, increment); + } + + ///Scan (and ignore) ignored line in a block scalar. + void scanBlockScalarIgnoredLine(in Mark startMark) + { + findNextNonSpace(); + if(reader_.peek == '#'){scanToNextBreak();} + + enforce(isBreakOrZero(reader_.peek()), + new ScannerException("While scanning a block scalar", startMark, + "expected a comment or a line break, but found " + ~ to!string(reader_.peek()), reader_.mark)); + scanLineBreak(); + } + + ///Scan indentation in a block scalar, returning line breaks, max indent and end mark. + Tuple!(dchar[], uint, Mark) scanBlockScalarIndentation() + { + dchar[] chunks; + uint maxIndent; + Mark endMark = reader_.mark; + + while(or!(isBreak, isChar!' ')(reader_.peek())) + { + if(reader_.peek() != ' ') + { + chunks ~= scanLineBreak(); + endMark = reader_.mark; + continue; + } + reader_.forward(); + maxIndent = max(reader_.column, maxIndent); + } + + return tuple(chunks, maxIndent, endMark); + } + + ///Scan line breaks at lower or specified indentation in a block scalar. + Tuple!(dchar[], Mark) scanBlockScalarBreaks(in uint indent) + { + dchar[] chunks; + Mark endMark = reader_.mark; + + for(;;) + { + while(reader_.column < indent && reader_.peek() == ' '){reader_.forward();} + if(!isBreak(reader_.peek())){break;} + chunks ~= scanLineBreak(); + endMark = reader_.mark; + } + + return tuple(chunks, endMark); + } + + ///Scan a qouted flow scalar token with specified quotes. + Token scanFlowScalar(ScalarStyle quotes) + { + const startMark = reader_.mark; + const quote = reader_.get(); + + auto appender = Appender!dstring(); + appender.put(scanFlowScalarNonSpaces(quotes, startMark)); + while(reader_.peek() != quote) + { + appender.put(scanFlowScalarSpaces(startMark)); + appender.put(scanFlowScalarNonSpaces(quotes, startMark)); + } + reader_.forward(); + + return scalarToken(startMark, reader_.mark, to!string(appender.data), quotes); + } + + ///Scan nonspace characters in a flow scalar. + dstring scanFlowScalarNonSpaces(ScalarStyle quotes, in Mark startMark) + { + dchar[dchar] escapeReplacements = + ['0': '\0', + 'a': '\x07', + 'b': '\x08', + 't': '\x09', + '\t': '\x09', + 'n': '\x0A', + 'v': '\x0B', + 'f': '\x0C', + 'r': '\x0D', + 'e': '\x1B', + ' ': '\x20', + '\"': '\"', + '\\': '\\', + 'N': '\x85', + '_': '\xA0', + 'L': '\u2028', + 'P': '\u2029']; + + uint[dchar] escapeCodes = ['x': 2, 'u': 4, 'U': 8]; + + //Can't use an Appender due to a Phobos bug, so appending to a string. + dstring result; + + for(;;) + { + dchar c = reader_.peek(); + uint length = 0; + while(!(or!(isBreakOrZero, isSpace)(c) || "\'\"\\".canFind(c))) + { + ++length; + c = reader_.peek(length); + } + + if(length > 0){result ~= reader_.get(length);} + + c = reader_.peek(); + if(quotes == ScalarStyle.SingleQuoted && + c == '\'' && reader_.peek(1) == '\'') + { + result ~= '\''; + reader_.forward(2); + } + else if((quotes == ScalarStyle.DoubleQuoted && c == '\'') || + (quotes == ScalarStyle.SingleQuoted && "\"\\".canFind(c))) + { + result ~= c; + reader_.forward(); + } + else if(quotes == ScalarStyle.DoubleQuoted && c == '\\') + { + reader_.forward(); + c = reader_.peek(); + if((c in escapeReplacements) !is null) + { + result ~= escapeReplacements[c]; + reader_.forward(); + } + else if((c in escapeCodes) !is null) + { + length = escapeCodes[c]; + reader_.forward(); + + foreach(i; 0 .. length) + { + enforce(isHexDigit(reader_.peek(i)), + new ScannerException( + "While scanning a double qouted scalar", startMark, + "expected escape sequence of " ~ to!string(length) ~ + " hexadecimal numbers, but found " ~ + to!string(reader_.peek(i)), reader_.mark)); + } + + dstring hex = reader_.get(length); + result ~= cast(dchar)parse!int(hex, 16); + } + else if(isBreak(c)) + { + scanLineBreak(); + result ~= scanFlowScalarBreaks(startMark); + } + else + { + throw new ScannerException("While scanning a double quoted scalar", + startMark, + "found unknown escape character: " ~ + to!string(c), reader_.mark); + } + } + else{return result;} + } + } + + ///Scan space characters in a flow scalar. + dstring scanFlowScalarSpaces(in Mark startMark) + { + uint length = 0; + while(isSpace(reader_.peek(length))){++length;} + const whitespaces = reader_.get(length); + + dchar c = reader_.peek(); + enforce(c != '\0', + new ScannerException("While scanning a quoted scalar", startMark, + "found unexpected end of stream", reader_.mark)); + + auto appender = Appender!dstring(); + if(isBreak(c)) + { + const lineBreak = scanLineBreak(); + const breaks = scanFlowScalarBreaks(startMark); + + if(lineBreak != '\n'){appender.put(lineBreak);} + else if(breaks.length == 0){appender.put(' ');} + appender.put(breaks); + } + else{appender.put(whitespaces);} + return appender.data; + } + + ///Scan line breaks in a flow scalar. + dstring scanFlowScalarBreaks(in Mark startMark) + { + auto appender = Appender!dstring(); + for(;;) + { + //Instead of checking indentation, we check for document separators. + const prefix = reader_.prefix(3); + if((prefix == "---" || prefix == "...") && + or!(isBreakOrZero, isSpace)(reader_.peek(3))) + { + throw new ScannerException("While scanning a quoted scalar", startMark, + "found unexpected document separator", + reader_.mark); + } + + while(isSpace(reader_.peek())){reader_.forward();} + + if(isBreak(reader_.peek())){appender.put(scanLineBreak());} + else{return appender.data;} + } + } + + ///Scan plain scalar token (no block, no quotes). + Token scanPlain() + { + //We keep track of the allowSimpleKey_ flag here. + //Indentation rules are loosed for the flow context + auto appender = Appender!dstring(); + const startMark = reader_.mark; + Mark endMark = startMark; + const indent = indent_ + 1; + + //We allow zero indentation for scalars, but then we need to check for + //document separators at the beginning of the line. + //if(indent == 0){indent = 1;} + dstring spaces; + for(;;) + { + if(reader_.peek() == '#'){break;} + + uint length = 0; + + dchar c; + for(;;) + { + c = reader_.peek(length); + bool done = or!(isBreakOrZero, isSpace)(c) || + (flowLevel_ == 0 && c == ':' && + or!(isBreakOrZero, isSpace)(reader_.peek(length + 1))) || + (flowLevel_ > 0 && ",:?[]{}".canFind(c)); + if(done){break;} + ++length; + } + + //It's not clear what we should do with ':' in the flow context. + if(flowLevel_ > 0 && c == ':' && + !or!(isBreakOrZero, isSpace)(reader_.peek(length + 1)) && + !",[]{}".canFind(reader_.peek(length + 1))) + { + reader_.forward(length); + throw new ScannerException("While scanning a plain scalar", startMark, + "found unexpected ':' . Please check " + "http://pyyaml.org/wiki/YAMLColonInFlowContext " + "for details.", reader_.mark); + } + + if(length == 0){break;} + allowSimpleKey_ = false; + + appender.put(spaces); + appender.put(reader_.get(length)); + + endMark = reader_.mark; + + spaces = scanPlainSpaces(startMark); + if(spaces.length == 0 || reader_.peek() == '#' || + (flowLevel_ == 0 && reader_.column < indent)) + { + break; + } + } + return scalarToken(startMark, endMark, to!string(appender.data), ScalarStyle.Plain); + } + + ///Scan spaces in a plain scalar. + dstring scanPlainSpaces(in Mark startMark) + { + ///The specification is really confusing about tabs in plain scalars. + ///We just forbid them completely. Do not use tabs in YAML! + auto appender = Appender!dstring(); + + uint length = 0; + while(reader_.peek(length) == ' '){++length;} + dstring whitespaces = reader_.get(length); + + dchar c = reader_.peek(); + if(isBreak(c)) + { + const lineBreak = scanLineBreak(); + allowSimpleKey_ = true; + + bool end() + { + return ["---"d, "..."d].canFind(reader_.prefix(3)) && + or!(isBreakOrZero, isSpace)(reader_.peek(3)); + } + + if(end()){return "";} + + dstring breaks; + while(or!(isBreak, isChar!' ')(reader_.peek())) + { + if(reader_.peek() == ' '){reader_.forward();} + else + { + breaks ~= scanLineBreak(); + if(end()){return "";} + } + } + + if(lineBreak != '\n'){appender.put(lineBreak);} + else if(breaks.length == 0){appender.put(' ');} + appender.put(breaks); + } + else if(whitespaces.length > 0) + { + appender.put(whitespaces); + } + + return appender.data; + } + + ///Scan handle of a tag token. + dstring scanTagHandle(string name, in Mark startMark) + { + dchar c = reader_.peek(); + enforce(c == '!', + new ScannerException("While scanning a " ~ name, startMark, + "expected a '!', but found: " ~ to!string(c), + reader_.mark)); + + uint length = 1; + c = reader_.peek(length); + if(c != ' ') + { + while(isAlphaNum(c) || "-_".canFind(c)) + { + ++length; + c = reader_.peek(length); + } + if(c != '!') + { + reader_.forward(length); + throw new ScannerException("While scanning a " ~ name, startMark, + "expected a '!', but found: " ~ to!string(c), + reader_.mark); + } + ++length; + } + return reader_.get(length); + } + + ///Scan URI in a tag token. + dstring scanTagURI(string name, in Mark startMark) + { + //Note: we do not check if URI is well-formed. + auto appender = Appender!dstring(); + uint length = 0; + + dchar c = reader_.peek(); + while(isAlphaNum(c) || "-;/?:@&=+$,_.!~*\'()[]%".canFind(c)) + { + if(c == '%') + { + appender.put(reader_.get(length)); + length = 0; + appender.put(scanURIEscapes(name, startMark)); + } + else{++length;} + c = reader_.peek(length); + } + if(length > 0) + { + appender.put(reader_.get(length)); + length = 0; + } + enforce(appender.data.length > 0, + new ScannerException("While parsing a " ~ name, startMark, + "expected URI, but found: " ~ to!string(c), + reader_.mark)); + + return appender.data; + } + + ///Scan URI escape sequences. + dstring scanURIEscapes(string name, in Mark startMark) + { + ubyte[] bytes; + Mark mark = reader_.mark; + + while(reader_.peek() == '%') + { + reader_.forward(); + + ubyte b = 0; + uint mult = 16; + //Converting 2 hexadecimal digits to a byte. + foreach(k; 0 .. 2) + { + dchar c = reader_.peek(k); + enforce("0123456789ABCDEFabcdef".canFind(c), + new ScannerException("While scanning a " ~ name, startMark, + "expected URI escape sequence of " + "2 hexadecimal numbers, but found: " ~ + to!string(c), reader_.mark)); + + uint digit; + if(c - '0' < 10){digit = c - '0';} + else if(c - 'A' < 6){digit = c - 'A';} + else if(c - 'a' < 6){digit = c - 'a';} + else{assert(false);} + b += mult * digit; + mult /= 16; + } + bytes ~= b; + + reader_.forward(2); + } + + try{return to!dstring(cast(string)bytes);} + catch(ConvException e) + { + throw new ScannerException("While scanning a " ~ name, startMark, e.msg, mark); + } + catch(UtfException e) + { + throw new ScannerException("While scanning a " ~ name, startMark, e.msg, mark); + } + } + + + /** + * Scan a line break, if any. + * + * Transforms: + * '\r\n' : '\n' + * '\r' : '\n' + * '\n' : '\n' + * '\x85' : '\n' + * '\u2028' : '\u2028' + * '\u2029 : '\u2029' + * no break : '\0' + */ + dchar scanLineBreak() + { + const c = reader_.peek(); + + dchar[] plainLineBreaks = ['\r', '\n', '\x85']; + if(plainLineBreaks.canFind(c)) + { + if(reader_.prefix(2) == "\r\n"){reader_.forward(2);} + else{reader_.forward();} + return '\n'; + } + if("\u2028\u2029".canFind(c)) + { + reader_.forward(); + return c; + } + return '\0'; + } +} diff --git a/dyaml/token.d b/dyaml/token.d new file mode 100644 index 0000000..62397c5 --- /dev/null +++ b/dyaml/token.d @@ -0,0 +1,139 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** + * YAML tokens. + * Code based on PyYAML: http://www.pyyaml.org + */ +module dyaml.token; + + +import dyaml.exception; +import dyaml.reader; + + +package: +///Token types. +enum TokenID : ubyte +{ + Invalid = 0, /// Invalid (uninitialized) token + Directive, /// DIRECTIVE + DocumentStart, /// DOCUMENT-START + DocumentEnd, /// DOCUMENT-END + StreamStart, /// STREAM-START + StreamEnd, /// STREAM-END + BlockSequenceStart, /// BLOCK-SEQUENCE-START + BlockMappingStart, /// BLOCK-MAPPING-START + BlockEnd, /// BLOCK-END + FlowSequenceStart, /// FLOW-SEQUENCE-START + FlowMappingStart, /// FLOW-MAPPING-START + FlowSequenceEnd, /// FLOW-SEQUENCE-END + FlowMappingEnd, /// FLOW-MAPPING-END + Key, /// KEY + Value, /// VALUE + BlockEntry, /// BLOCK-ENTRY + FlowEntry, /// FLOW-ENTRY + Alias, /// ALIAS + Anchor, /// ANCHOR + Tag, /// TAG + Scalar /// SCALAR +} + +///Scalar styles. +enum ScalarStyle : ubyte +{ + Invalid = 0, /// Invalid (uninitialized) style + Literal, /// | (Literal block style) + Folded, /// > (Folded block style) + Plain, /// Plain scalar + SingleQuoted, /// Single quoted scalar + DoubleQuoted /// Double quoted scalar +} + +/** + * Token produced by scanner. + * + * 32 bytes on 64-bit. + */ +immutable struct Token +{ + ///Value of the token, if any. + string value; + ///Start position of the token in file/stream. + Mark startMark; + ///End position of the token in file/stream. + Mark endMark; + ///Token type. + TokenID id; + ///Style of scalar token, if this is a scalar token. + ScalarStyle style; +} + +/** + * Construct a directive token. + * + * Params: start = Start position of the token. + * end = End position of the token. + * value = Value of the token. + */ +Token directiveToken(in Mark start, in Mark end, in string value) pure +{ + return Token(value, start, end, TokenID.Directive); +} + +/** + * Construct a simple (no value) token with specified type. + * + * Params: id = Type of the token. + * start = Start position of the token. + * end = End position of the token. + */ +Token simpleToken(TokenID id)(in Mark start, in Mark end) pure +{ + return Token(null, start, end, id); +} + +///Aliases for construction of simple token types. +alias simpleToken!(TokenID.StreamStart) streamStartToken; +alias simpleToken!(TokenID.StreamEnd) streamEndToken; +alias simpleToken!(TokenID.BlockSequenceStart) blockSequenceStartToken; +alias simpleToken!(TokenID.BlockMappingStart) blockMappingStartToken; +alias simpleToken!(TokenID.BlockEnd) blockEndToken; +alias simpleToken!(TokenID.Key) keyToken; +alias simpleToken!(TokenID.Value) valueToken; +alias simpleToken!(TokenID.BlockEntry) blockEntryToken; +alias simpleToken!(TokenID.FlowEntry) flowEntryToken; + +/** + * Construct a simple token with value with specified type. + * + * Params: id = Type of the token. + * start = Start position of the token. + * end = End position of the token. + * value = Value of the token. + */ +Token simpleValueToken(TokenID id)(in Mark start, in Mark end, string value) pure +{ + return Token(value, start, end, id); +} + +///Alias for construction of tag token. +alias simpleValueToken!(TokenID.Tag) tagToken; +alias simpleValueToken!(TokenID.Alias) aliasToken; +alias simpleValueToken!(TokenID.Anchor) anchorToken; + +/** + * Construct a scalar token. + * + * Params: start = Start position of the token. + * end = End position of the token. + * value = Value of the token. + * style = Style of the token. + */ +Token scalarToken(in Mark start, in Mark end, in string value, in ScalarStyle style) pure +{ + return Token(value, start, end, TokenID.Scalar, style); +} diff --git a/dyaml/util.d b/dyaml/util.d new file mode 100644 index 0000000..30befe0 --- /dev/null +++ b/dyaml/util.d @@ -0,0 +1,36 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.util; + +package: + + +///Is given character YAML whitespace (space or tab)? +bool isSpace(in dchar c){return c == ' ' || c == '\t';} + +///Is given character YAML line break? +bool isBreak(in dchar c) +{ + return c == '\n' || c == '\r' || c == '\x85' || c == '\u2028' || c == '\u2029'; +} + +///Is c the checked character? +bool isChar(dchar checked)(in dchar c){return checked == c;} + +///Function that or's specified functions with a character input. +bool or(F ...)(in dchar input) +{ + foreach(f; F) + { + if(f(input)){return true;} + } + return false; +} + +///Convenience aliases. +alias isChar!'\0' isZero; +alias or!(isZero, isBreak) isBreakOrZero; diff --git a/examples/constructor/Makefile b/examples/constructor/Makefile new file mode 100644 index 0000000..55dfe3d --- /dev/null +++ b/examples/constructor/Makefile @@ -0,0 +1,2 @@ +main: + dmd -w -I../../ -L-L../../ -L-ldyaml main.d diff --git a/examples/constructor/input.yaml b/examples/constructor/input.yaml new file mode 100644 index 0000000..8d56926 --- /dev/null +++ b/examples/constructor/input.yaml @@ -0,0 +1,8 @@ +scalar-red: !color FF0000 +scalar-orange: !color FFFF00 +mapping-red: !color-mapping {r: 255, g: 0, b: 0} +mapping-orange: + !color-mapping + r: 255 + g: 255 + b: 0 diff --git a/examples/constructor/main.d b/examples/constructor/main.d new file mode 100644 index 0000000..d5bf39a --- /dev/null +++ b/examples/constructor/main.d @@ -0,0 +1,110 @@ +import std.ascii; +import std.stdio; +import std.string; +import yaml; + +struct Color +{ + ubyte red; + ubyte green; + ubyte blue; +} + +Color constructColorScalar(Mark start, Mark end, string value) +{ + if(value.length != 6) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + //We don't need to check for uppercase chars this way. + value = value.toLower(); + + //Get value of a hex digit. + uint hex(char c) + { + if(!std.ascii.isHexDigit(c)) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + + if(std.ascii.isDigit(c)) + { + return c - '0'; + } + return c - 'a' + 10; + } + + Color result; + result.red = cast(ubyte)(16 * hex(value[0]) + hex(value[1])); + result.green = cast(ubyte)(16 * hex(value[2]) + hex(value[3])); + result.blue = cast(ubyte)(16 * hex(value[4]) + hex(value[5])); + + return result; +} + +Color constructColorMapping(Mark start, Mark end, Node.Pair[] pairs) +{ + int r, g, b; + r = g = b = -1; + bool error = pairs.length != 3; + + foreach(ref pair; pairs) + { + //Key might not be a string, and value might not be an int, + //so we need to check for that + try + { + switch(pair.key.get!string) + { + case "r": r = pair.value.get!int; break; + case "g": g = pair.value.get!int; break; + case "b": b = pair.value.get!int; break; + default: error = true; + } + } + catch(NodeException e) + { + error = true; + } + } + + if(error || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) + { + throw new ConstructorException("Invalid color", start, end); + } + + return Color(cast(ubyte)r, cast(ubyte)g, cast(ubyte)b); +} + +void main() +{ + auto red = Color(255, 0, 0); + auto orange = Color(255, 255, 0); + + try + { + auto constructor = new Constructor; + //both functions handle the same tag, but one handles scalar, one mapping. + constructor.addConstructor("!color", &constructColorScalar); + constructor.addConstructor("!color-mapping", &constructColorMapping); + + auto loader = new Loader("input.yaml", constructor, new Resolver); + + auto root = loader.loadSingleDocument(); + + if(root["scalar-red"].get!Color == red && + root["mapping-red"].get!Color == red && + root["scalar-orange"].get!Color == orange && + root["mapping-orange"].get!Color == orange) + { + writeln("SUCCESS"); + return; + } + } + catch(YAMLException e) + { + writeln(e.msg); + } + + writeln("FAILURE"); +} diff --git a/examples/getting_started/Makefile b/examples/getting_started/Makefile new file mode 100644 index 0000000..55dfe3d --- /dev/null +++ b/examples/getting_started/Makefile @@ -0,0 +1,2 @@ +main: + dmd -w -I../../ -L-L../../ -L-ldyaml main.d diff --git a/examples/getting_started/input.yaml b/examples/getting_started/input.yaml new file mode 100644 index 0000000..38cbcce --- /dev/null +++ b/examples/getting_started/input.yaml @@ -0,0 +1,4 @@ +Hello World : + - Hello + - World +Answer : 42 diff --git a/examples/getting_started/main.d b/examples/getting_started/main.d new file mode 100644 index 0000000..8e4330a --- /dev/null +++ b/examples/getting_started/main.d @@ -0,0 +1,12 @@ +import std.stdio; +import yaml; + +void main() +{ + yaml.Node root = yaml.load("input.yaml"); + foreach(string word; root["Hello World"]) + { + writeln(word); + } + writeln("The answer is ", root["Answer"].get!int); +} diff --git a/examples/resolver/Makefile b/examples/resolver/Makefile new file mode 100644 index 0000000..55dfe3d --- /dev/null +++ b/examples/resolver/Makefile @@ -0,0 +1,2 @@ +main: + dmd -w -I../../ -L-L../../ -L-ldyaml main.d diff --git a/examples/resolver/input.yaml b/examples/resolver/input.yaml new file mode 100644 index 0000000..99b9a5a --- /dev/null +++ b/examples/resolver/input.yaml @@ -0,0 +1,8 @@ +scalar-red: FF0000 +scalar-orange: FFFF00 +mapping-red: !color-mapping {r: 255, g: 0, b: 0} +mapping-orange: + !color-mapping + r: 255 + g: 255 + b: 0 diff --git a/examples/resolver/main.d b/examples/resolver/main.d new file mode 100644 index 0000000..2794f51 --- /dev/null +++ b/examples/resolver/main.d @@ -0,0 +1,114 @@ +import std.ascii; +import std.stdio; +import std.string; +import yaml; + +struct Color +{ + ubyte red; + ubyte green; + ubyte blue; +} + +Color constructColorScalar(Mark start, Mark end, string value) +{ + if(value.length != 6) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + //We don't need to check for uppercase chars this way. + value = value.toLower(); + + //Get value of a hex digit. + uint hex(char c) + { + if(!std.ascii.isHexDigit(c)) + { + throw new ConstructorException("Invalid color: " ~ value, start, end); + } + + if(std.ascii.isDigit(c)) + { + return c - '0'; + } + return c - 'a' + 10; + } + + Color result; + result.red = cast(ubyte)(16 * hex(value[0]) + hex(value[1])); + result.green = cast(ubyte)(16 * hex(value[2]) + hex(value[3])); + result.blue = cast(ubyte)(16 * hex(value[4]) + hex(value[5])); + + return result; +} + +Color constructColorMapping(Mark start, Mark end, Node.Pair[] pairs) +{ + int r, g, b; + r = g = b = -1; + bool error = pairs.length != 3; + + foreach(ref pair; pairs) + { + //Key might not be a string, and value might not be an int, + //so we need to check for that + try + { + switch(pair.key.get!string) + { + case "r": r = pair.value.get!int; break; + case "g": g = pair.value.get!int; break; + case "b": b = pair.value.get!int; break; + default: error = true; + } + } + catch(NodeException e) + { + error = true; + } + } + + if(error || r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) + { + throw new ConstructorException("Invalid color", start, end); + } + + return Color(cast(ubyte)r, cast(ubyte)g, cast(ubyte)b); +} + +void main() +{ + auto red = Color(255, 0, 0); + auto orange = Color(255, 255, 0); + + try + { + auto constructor = new Constructor; + //both functions handle the same tag, but one handles scalar, one mapping. + constructor.addConstructor("!color", &constructColorScalar); + constructor.addConstructor("!color-mapping", &constructColorMapping); + + auto resolver = new Resolver; + resolver.addImplicitResolver("!color", std.regex.regex("[0-9a-fA-F]{6}"), + "0123456789abcdefABCDEF"); + + auto loader = new Loader("input.yaml", constructor, resolver); + + auto root = loader.loadSingleDocument(); + + if(root["scalar-red"].get!Color == red && + root["mapping-red"].get!Color == red && + root["scalar-orange"].get!Color == orange && + root["mapping-orange"].get!Color == orange) + { + writeln("SUCCESS"); + return; + } + } + catch(YAMLException e) + { + writeln(e.msg); + } + + writeln("FAILURE"); +} diff --git a/test/data/a-nasty-libyaml-bug.loader-error b/test/data/a-nasty-libyaml-bug.loader-error new file mode 100644 index 0000000..f97d49f --- /dev/null +++ b/test/data/a-nasty-libyaml-bug.loader-error @@ -0,0 +1 @@ +[ [ \ No newline at end of file diff --git a/test/data/aliases-cdumper-bug.code b/test/data/aliases-cdumper-bug.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/aliases-cdumper-bug.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/aliases.events b/test/data/aliases.events new file mode 100644 index 0000000..9139b51 --- /dev/null +++ b/test/data/aliases.events @@ -0,0 +1,8 @@ +- !StreamStart +- !DocumentStart +- !SequenceStart +- !Scalar { anchor: 'myanchor', tag: '!mytag', value: 'data' } +- !Alias { anchor: 'myanchor' } +- !SequenceEnd +- !DocumentEnd +- !StreamEnd diff --git a/test/data/bool.data b/test/data/bool.data new file mode 100644 index 0000000..0988b63 --- /dev/null +++ b/test/data/bool.data @@ -0,0 +1,4 @@ +- yes +- NO +- True +- on diff --git a/test/data/bool.detect b/test/data/bool.detect new file mode 100644 index 0000000..947ebbb --- /dev/null +++ b/test/data/bool.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:bool diff --git a/test/data/colon-in-flow-context.loader-error b/test/data/colon-in-flow-context.loader-error new file mode 100644 index 0000000..13d5087 --- /dev/null +++ b/test/data/colon-in-flow-context.loader-error @@ -0,0 +1 @@ +{ foo:bar } diff --git a/test/data/construct-binary.code b/test/data/construct-binary.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-binary.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-binary.data b/test/data/construct-binary.data new file mode 100644 index 0000000..dcdb16f --- /dev/null +++ b/test/data/construct-binary.data @@ -0,0 +1,12 @@ +canonical: !!binary "\ + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\ + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\ + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" +generic: !!binary | + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= +description: + The binary value above is a tiny arrow encoded as a gif image. diff --git a/test/data/construct-bool.code b/test/data/construct-bool.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-bool.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-bool.data b/test/data/construct-bool.data new file mode 100644 index 0000000..36d6519 --- /dev/null +++ b/test/data/construct-bool.data @@ -0,0 +1,9 @@ +canonical: yes +answer: NO +logical: True +option: on + + +but: + y: is a string + n: is a string diff --git a/test/data/construct-custom.code b/test/data/construct-custom.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-custom.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-custom.data b/test/data/construct-custom.data new file mode 100644 index 0000000..4729be9 --- /dev/null +++ b/test/data/construct-custom.data @@ -0,0 +1,9 @@ +--- +- !tag1 + x: 1 +- !tag1 + x: 1 + 'y': 2 + z: 3 +- !tag2 + 10 diff --git a/test/data/construct-float.code b/test/data/construct-float.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-float.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-float.data b/test/data/construct-float.data new file mode 100644 index 0000000..b662c62 --- /dev/null +++ b/test/data/construct-float.data @@ -0,0 +1,6 @@ +canonical: 6.8523015e+5 +exponential: 685.230_15e+03 +fixed: 685_230.15 +sexagesimal: 190:20:30.15 +negative infinity: -.inf +not a number: .NaN diff --git a/test/data/construct-int.code b/test/data/construct-int.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-int.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-int.data b/test/data/construct-int.data new file mode 100644 index 0000000..852c314 --- /dev/null +++ b/test/data/construct-int.data @@ -0,0 +1,6 @@ +canonical: 685230 +decimal: +685_230 +octal: 02472256 +hexadecimal: 0x_0A_74_AE +binary: 0b1010_0111_0100_1010_1110 +sexagesimal: 190:20:30 diff --git a/test/data/construct-map.code b/test/data/construct-map.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-map.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-map.data b/test/data/construct-map.data new file mode 100644 index 0000000..022446d --- /dev/null +++ b/test/data/construct-map.data @@ -0,0 +1,6 @@ +# Unordered set of key: value pairs. +Block style: !!map + Clark : Evans + Brian : Ingerson + Oren : Ben-Kiki +Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki } diff --git a/test/data/construct-merge.code b/test/data/construct-merge.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-merge.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-merge.data b/test/data/construct-merge.data new file mode 100644 index 0000000..3fdb2e2 --- /dev/null +++ b/test/data/construct-merge.data @@ -0,0 +1,27 @@ +--- +- &CENTER { x: 1, 'y': 2 } +- &LEFT { x: 0, 'y': 2 } +- &BIG { r: 10 } +- &SMALL { r: 1 } + +# All the following maps are equal: + +- # Explicit keys + x: 1 + 'y': 2 + r: 10 + label: center/big + +- # Merge one map + << : *CENTER + r: 10 + label: center/big + +- # Merge multiple maps + << : [ *CENTER, *BIG ] + label: center/big + +- # Override + << : [ *BIG, *LEFT, *SMALL ] + x: 1 + label: center/big diff --git a/test/data/construct-null.code b/test/data/construct-null.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-null.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-null.data b/test/data/construct-null.data new file mode 100644 index 0000000..9ad0344 --- /dev/null +++ b/test/data/construct-null.data @@ -0,0 +1,18 @@ +# A document may be null. +--- +--- +# This mapping has four keys, +# one has a value. +empty: +canonical: ~ +english: null +~: null key +--- +# This sequence has five +# entries, two have values. +sparse: + - ~ + - 2nd entry + - + - 4th entry + - Null diff --git a/test/data/construct-omap.code b/test/data/construct-omap.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-omap.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-omap.data b/test/data/construct-omap.data new file mode 100644 index 0000000..4fa0f45 --- /dev/null +++ b/test/data/construct-omap.data @@ -0,0 +1,8 @@ +# Explicitly typed ordered map (dictionary). +Bestiary: !!omap + - aardvark: African pig-like ant eater. Ugly. + - anteater: South-American ant eater. Two species. + - anaconda: South-American constrictor snake. Scaly. + # Etc. +# Flow style +Numbers: !!omap [ one: 1, two: 2, three : 3 ] diff --git a/test/data/construct-pairs.code b/test/data/construct-pairs.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-pairs.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-pairs.data b/test/data/construct-pairs.data new file mode 100644 index 0000000..05f55b9 --- /dev/null +++ b/test/data/construct-pairs.data @@ -0,0 +1,7 @@ +# Explicitly typed pairs. +Block tasks: !!pairs + - meeting: with team. + - meeting: with boss. + - break: lunch. + - meeting: with client. +Flow tasks: !!pairs [ meeting: with team, meeting: with boss ] diff --git a/test/data/construct-seq.code b/test/data/construct-seq.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-seq.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-seq.data b/test/data/construct-seq.data new file mode 100644 index 0000000..bb92fd1 --- /dev/null +++ b/test/data/construct-seq.data @@ -0,0 +1,15 @@ +# Ordered sequence of nodes +Block style: !!seq +- Mercury # Rotates - no light/dark sides. +- Venus # Deadliest. Aptly named. +- Earth # Mostly dirt. +- Mars # Seems empty. +- Jupiter # The king. +- Saturn # Pretty. +- Uranus # Where the sun hardly shines. +- Neptune # Boring. No rings. +- Pluto # You call this a planet? +Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks + Jupiter, Saturn, Uranus, Neptune, # Gas + Pluto ] # Overrated + diff --git a/test/data/construct-set.code b/test/data/construct-set.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-set.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-set.data b/test/data/construct-set.data new file mode 100644 index 0000000..e05dc88 --- /dev/null +++ b/test/data/construct-set.data @@ -0,0 +1,7 @@ +# Explicitly typed set. +baseball players: !!set + ? Mark McGwire + ? Sammy Sosa + ? Ken Griffey +# Flow style +baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees } diff --git a/test/data/construct-str-ascii.code b/test/data/construct-str-ascii.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-str-ascii.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-str-ascii.data b/test/data/construct-str-ascii.data new file mode 100644 index 0000000..0d93013 --- /dev/null +++ b/test/data/construct-str-ascii.data @@ -0,0 +1 @@ +--- !!str "ascii string" diff --git a/test/data/construct-str-utf8.code b/test/data/construct-str-utf8.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-str-utf8.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-str-utf8.data b/test/data/construct-str-utf8.data new file mode 100644 index 0000000..e355f18 --- /dev/null +++ b/test/data/construct-str-utf8.data @@ -0,0 +1 @@ +--- !!str "Это уникодная строка" diff --git a/test/data/construct-str.code b/test/data/construct-str.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-str.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-str.data b/test/data/construct-str.data new file mode 100644 index 0000000..606ac6b --- /dev/null +++ b/test/data/construct-str.data @@ -0,0 +1 @@ +string: abcd diff --git a/test/data/construct-timestamp.code b/test/data/construct-timestamp.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-timestamp.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-timestamp.data b/test/data/construct-timestamp.data new file mode 100644 index 0000000..840273b --- /dev/null +++ b/test/data/construct-timestamp.data @@ -0,0 +1,5 @@ +canonical: 2001-12-15T02:59:43.1Z +valid iso8601: 2001-12-14t21:59:43.1-05:00 +space separated: 2001-12-14 21:59:43.1 -5 +no time zone (Z): 2001-12-15 2:59:43.1 +date (00:00:00Z): 2002-12-14 diff --git a/test/data/construct-value.code b/test/data/construct-value.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/construct-value.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/construct-value.data b/test/data/construct-value.data new file mode 100644 index 0000000..3eb7919 --- /dev/null +++ b/test/data/construct-value.data @@ -0,0 +1,10 @@ +--- # Old schema +link with: + - library1.dll + - library2.dll +--- # New schema +link with: + - = : library1.dll + version: 1.2 + - = : library2.dll + version: 2.3 diff --git a/test/data/document-separator-in-quoted-scalar.loader-error b/test/data/document-separator-in-quoted-scalar.loader-error new file mode 100644 index 0000000..9eeb0d6 --- /dev/null +++ b/test/data/document-separator-in-quoted-scalar.loader-error @@ -0,0 +1,11 @@ +--- +"this --- is correct" +--- +"this +...is also +correct" +--- +"a quoted scalar +cannot contain +--- +document separators" diff --git a/test/data/documents.events b/test/data/documents.events new file mode 100644 index 0000000..775a51a --- /dev/null +++ b/test/data/documents.events @@ -0,0 +1,11 @@ +- !StreamStart +- !DocumentStart { explicit: false } +- !Scalar { implicit: [true,false], value: 'data' } +- !DocumentEnd +- !DocumentStart +- !Scalar { implicit: [true,false] } +- !DocumentEnd +- !DocumentStart { version: [1,1], tags: { '!': '!foo', '!yaml!': 'tag:yaml.org,2002:', '!ugly!': '!!!!!!!' } } +- !Scalar { implicit: [true,false] } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/duplicate-anchor-1.loader-error b/test/data/duplicate-anchor-1.loader-error new file mode 100644 index 0000000..906cf29 --- /dev/null +++ b/test/data/duplicate-anchor-1.loader-error @@ -0,0 +1,3 @@ +- &foo bar +- &bar bar +- &foo bar diff --git a/test/data/duplicate-anchor-2.loader-error b/test/data/duplicate-anchor-2.loader-error new file mode 100644 index 0000000..62b4389 --- /dev/null +++ b/test/data/duplicate-anchor-2.loader-error @@ -0,0 +1 @@ +&foo [1, 2, 3, &foo 4] diff --git a/test/data/duplicate-merge-key.code b/test/data/duplicate-merge-key.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/duplicate-merge-key.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/duplicate-merge-key.data b/test/data/duplicate-merge-key.data new file mode 100644 index 0000000..cebc3a1 --- /dev/null +++ b/test/data/duplicate-merge-key.data @@ -0,0 +1,4 @@ +--- +<<: {x: 1, y: 2} +foo: bar +<<: {z: 3, t: 4} diff --git a/test/data/duplicate-tag-directive.loader-error b/test/data/duplicate-tag-directive.loader-error new file mode 100644 index 0000000..50c81a0 --- /dev/null +++ b/test/data/duplicate-tag-directive.loader-error @@ -0,0 +1,3 @@ +%TAG !foo! bar +%TAG !foo! baz +--- foo diff --git a/test/data/duplicate-yaml-directive.loader-error b/test/data/duplicate-yaml-directive.loader-error new file mode 100644 index 0000000..9b72390 --- /dev/null +++ b/test/data/duplicate-yaml-directive.loader-error @@ -0,0 +1,3 @@ +%YAML 1.1 +%YAML 1.1 +--- foo diff --git a/test/data/emit-block-scalar-in-simple-key-context-bug.canonical b/test/data/emit-block-scalar-in-simple-key-context-bug.canonical new file mode 100644 index 0000000..473bed5 --- /dev/null +++ b/test/data/emit-block-scalar-in-simple-key-context-bug.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- !!map +{ + ? !!str "foo" + : !!str "bar" +} diff --git a/test/data/emit-block-scalar-in-simple-key-context-bug.data b/test/data/emit-block-scalar-in-simple-key-context-bug.data new file mode 100644 index 0000000..b6b42ba --- /dev/null +++ b/test/data/emit-block-scalar-in-simple-key-context-bug.data @@ -0,0 +1,4 @@ +? |- + foo +: |- + bar diff --git a/test/data/empty-anchor.emitter-error b/test/data/empty-anchor.emitter-error new file mode 100644 index 0000000..ce663b6 --- /dev/null +++ b/test/data/empty-anchor.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart +- !Scalar { anchor: '', value: 'foo' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/empty-document-bug.canonical b/test/data/empty-document-bug.canonical new file mode 100644 index 0000000..28a6cf1 --- /dev/null +++ b/test/data/empty-document-bug.canonical @@ -0,0 +1 @@ +# This YAML stream contains no YAML documents. diff --git a/test/data/empty-document-bug.data b/test/data/empty-document-bug.data new file mode 100644 index 0000000..e69de29 diff --git a/test/data/empty-document-bug.empty b/test/data/empty-document-bug.empty new file mode 100644 index 0000000..e69de29 diff --git a/test/data/empty-documents.single-loader-error b/test/data/empty-documents.single-loader-error new file mode 100644 index 0000000..f8dba8d --- /dev/null +++ b/test/data/empty-documents.single-loader-error @@ -0,0 +1,2 @@ +--- # first document +--- # second document diff --git a/test/data/empty-python-module.loader-error b/test/data/empty-python-module.loader-error new file mode 100644 index 0000000..83d3232 --- /dev/null +++ b/test/data/empty-python-module.loader-error @@ -0,0 +1 @@ +--- !!python:module: diff --git a/test/data/empty-python-name.loader-error b/test/data/empty-python-name.loader-error new file mode 100644 index 0000000..6162957 --- /dev/null +++ b/test/data/empty-python-name.loader-error @@ -0,0 +1 @@ +--- !!python/name: empty diff --git a/test/data/empty-tag-handle.emitter-error b/test/data/empty-tag-handle.emitter-error new file mode 100644 index 0000000..235c899 --- /dev/null +++ b/test/data/empty-tag-handle.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart { tags: { '': 'bar' } } +- !Scalar { value: 'foo' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/empty-tag-prefix.emitter-error b/test/data/empty-tag-prefix.emitter-error new file mode 100644 index 0000000..c6c0e95 --- /dev/null +++ b/test/data/empty-tag-prefix.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart { tags: { '!': '' } } +- !Scalar { value: 'foo' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/empty-tag.emitter-error b/test/data/empty-tag.emitter-error new file mode 100644 index 0000000..b7ca593 --- /dev/null +++ b/test/data/empty-tag.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart +- !Scalar { tag: '', value: 'key', implicit: [false,false] } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/expected-document-end.emitter-error b/test/data/expected-document-end.emitter-error new file mode 100644 index 0000000..0cbab89 --- /dev/null +++ b/test/data/expected-document-end.emitter-error @@ -0,0 +1,6 @@ +- !StreamStart +- !DocumentStart +- !Scalar { value: 'data 1' } +- !Scalar { value: 'data 2' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/expected-document-start.emitter-error b/test/data/expected-document-start.emitter-error new file mode 100644 index 0000000..8ce575e --- /dev/null +++ b/test/data/expected-document-start.emitter-error @@ -0,0 +1,4 @@ +- !StreamStart +- !MappingStart +- !MappingEnd +- !StreamEnd diff --git a/test/data/expected-mapping.loader-error b/test/data/expected-mapping.loader-error new file mode 100644 index 0000000..82aed98 --- /dev/null +++ b/test/data/expected-mapping.loader-error @@ -0,0 +1 @@ +--- !!map [not, a, map] diff --git a/test/data/expected-node-1.emitter-error b/test/data/expected-node-1.emitter-error new file mode 100644 index 0000000..36ceca3 --- /dev/null +++ b/test/data/expected-node-1.emitter-error @@ -0,0 +1,4 @@ +- !StreamStart +- !DocumentStart +- !DocumentEnd +- !StreamEnd diff --git a/test/data/expected-node-2.emitter-error b/test/data/expected-node-2.emitter-error new file mode 100644 index 0000000..891ee37 --- /dev/null +++ b/test/data/expected-node-2.emitter-error @@ -0,0 +1,7 @@ +- !StreamStart +- !DocumentStart +- !MappingStart +- !Scalar { value: 'key' } +- !MappingEnd +- !DocumentEnd +- !StreamEnd diff --git a/test/data/expected-nothing.emitter-error b/test/data/expected-nothing.emitter-error new file mode 100644 index 0000000..62c54d3 --- /dev/null +++ b/test/data/expected-nothing.emitter-error @@ -0,0 +1,4 @@ +- !StreamStart +- !StreamEnd +- !StreamStart +- !StreamEnd diff --git a/test/data/expected-scalar.loader-error b/test/data/expected-scalar.loader-error new file mode 100644 index 0000000..7b3171e --- /dev/null +++ b/test/data/expected-scalar.loader-error @@ -0,0 +1 @@ +--- !!str [not a scalar] diff --git a/test/data/expected-sequence.loader-error b/test/data/expected-sequence.loader-error new file mode 100644 index 0000000..08074ea --- /dev/null +++ b/test/data/expected-sequence.loader-error @@ -0,0 +1 @@ +--- !!seq {foo, bar, baz} diff --git a/test/data/expected-stream-start.emitter-error b/test/data/expected-stream-start.emitter-error new file mode 100644 index 0000000..480dc2e --- /dev/null +++ b/test/data/expected-stream-start.emitter-error @@ -0,0 +1,2 @@ +- !DocumentStart +- !DocumentEnd diff --git a/test/data/explicit-document.single-loader-error b/test/data/explicit-document.single-loader-error new file mode 100644 index 0000000..46c6f8b --- /dev/null +++ b/test/data/explicit-document.single-loader-error @@ -0,0 +1,4 @@ +--- +foo: bar +--- +foo: bar diff --git a/test/data/fetch-complex-value-bug.loader-error b/test/data/fetch-complex-value-bug.loader-error new file mode 100644 index 0000000..25fac24 --- /dev/null +++ b/test/data/fetch-complex-value-bug.loader-error @@ -0,0 +1,2 @@ +? "foo" + : "bar" diff --git a/test/data/float-representer-2.3-bug.code b/test/data/float-representer-2.3-bug.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/float-representer-2.3-bug.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/float-representer-2.3-bug.data b/test/data/float-representer-2.3-bug.data new file mode 100644 index 0000000..efd1716 --- /dev/null +++ b/test/data/float-representer-2.3-bug.data @@ -0,0 +1,5 @@ +#0.0: # hash(0) == hash(nan) and 0 == nan in Python 2.3 +1.0: 1 ++.inf: 10 +-.inf: -10 +.nan: 100 diff --git a/test/data/float.data b/test/data/float.data new file mode 100644 index 0000000..524d5db --- /dev/null +++ b/test/data/float.data @@ -0,0 +1,6 @@ +- 6.8523015e+5 +- 685.230_15e+03 +- 685_230.15 +- 190:20:30.15 +- -.inf +- .NaN diff --git a/test/data/float.detect b/test/data/float.detect new file mode 100644 index 0000000..1e12343 --- /dev/null +++ b/test/data/float.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:float diff --git a/test/data/forbidden-entry.loader-error b/test/data/forbidden-entry.loader-error new file mode 100644 index 0000000..f2e3079 --- /dev/null +++ b/test/data/forbidden-entry.loader-error @@ -0,0 +1,2 @@ +test: - foo + - bar diff --git a/test/data/forbidden-key.loader-error b/test/data/forbidden-key.loader-error new file mode 100644 index 0000000..da9b471 --- /dev/null +++ b/test/data/forbidden-key.loader-error @@ -0,0 +1,2 @@ +test: ? foo + : bar diff --git a/test/data/forbidden-value.loader-error b/test/data/forbidden-value.loader-error new file mode 100644 index 0000000..efd7ce5 --- /dev/null +++ b/test/data/forbidden-value.loader-error @@ -0,0 +1 @@ +test: key: value diff --git a/test/data/implicit-document.single-loader-error b/test/data/implicit-document.single-loader-error new file mode 100644 index 0000000..f8c9a5c --- /dev/null +++ b/test/data/implicit-document.single-loader-error @@ -0,0 +1,3 @@ +foo: bar +--- +foo: bar diff --git a/test/data/int.data b/test/data/int.data new file mode 100644 index 0000000..d44d376 --- /dev/null +++ b/test/data/int.data @@ -0,0 +1,6 @@ +- 685230 +- +685_230 +- 02472256 +- 0x_0A_74_AE +- 0b1010_0111_0100_1010_1110 +- 190:20:30 diff --git a/test/data/int.detect b/test/data/int.detect new file mode 100644 index 0000000..575c9eb --- /dev/null +++ b/test/data/int.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:int diff --git a/test/data/invalid-anchor-1.loader-error b/test/data/invalid-anchor-1.loader-error new file mode 100644 index 0000000..fcf7d0f --- /dev/null +++ b/test/data/invalid-anchor-1.loader-error @@ -0,0 +1 @@ +--- &? foo # we allow only ascii and numeric characters in anchor names. diff --git a/test/data/invalid-anchor-2.loader-error b/test/data/invalid-anchor-2.loader-error new file mode 100644 index 0000000..bfc4ff0 --- /dev/null +++ b/test/data/invalid-anchor-2.loader-error @@ -0,0 +1,8 @@ +--- +- [ + &correct foo, + *correct, + *correct] # still correct +- *correct: still correct +- &correct-or-not[foo, bar] + diff --git a/test/data/invalid-anchor.emitter-error b/test/data/invalid-anchor.emitter-error new file mode 100644 index 0000000..3d2a814 --- /dev/null +++ b/test/data/invalid-anchor.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart +- !Scalar { anchor: '5*5=25', value: 'foo' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/invalid-base64-data-2.loader-error b/test/data/invalid-base64-data-2.loader-error new file mode 100644 index 0000000..2553a4f --- /dev/null +++ b/test/data/invalid-base64-data-2.loader-error @@ -0,0 +1,2 @@ +--- !!binary + двоичные данные в base64 diff --git a/test/data/invalid-base64-data.loader-error b/test/data/invalid-base64-data.loader-error new file mode 100644 index 0000000..798abba --- /dev/null +++ b/test/data/invalid-base64-data.loader-error @@ -0,0 +1,2 @@ +--- !!binary + binary data encoded in base64 should be here. diff --git a/test/data/invalid-block-scalar-indicator.loader-error b/test/data/invalid-block-scalar-indicator.loader-error new file mode 100644 index 0000000..16a6db1 --- /dev/null +++ b/test/data/invalid-block-scalar-indicator.loader-error @@ -0,0 +1,2 @@ +--- > what is this? # a comment +data diff --git a/test/data/invalid-character.loader-error b/test/data/invalid-character.loader-error new file mode 100644 index 0000000000000000000000000000000000000000..03687b02d41c39b85d8911fd94d80d891aa1b2c2 GIT binary patch literal 2209 zcmdPZ9ZM<1t>Y7#x3<@@bAc6oPr-jG> literal 0 HcmV?d00001 diff --git a/test/data/invalid-character.stream-error b/test/data/invalid-character.stream-error new file mode 100644 index 0000000000000000000000000000000000000000..171facec1f7d4e9d1f3c06bb453b241fba6238a5 GIT binary patch literal 4193 zcmY#ZrU-CRq+3~eR6k__I2wMV;YUdbjHVw-LT|ME8cjc=>4%aK7)?Kvgx+ZRGn#%z z(+?#fFq(cS3BA$sXUL}?=lr~qqWm0%0 # not valid +data diff --git a/test/data/invalid-indentation-indicator-2.loader-error b/test/data/invalid-indentation-indicator-2.loader-error new file mode 100644 index 0000000..eefb6ec --- /dev/null +++ b/test/data/invalid-indentation-indicator-2.loader-error @@ -0,0 +1,2 @@ +--- >-0 +data diff --git a/test/data/invalid-item-without-trailing-break.loader-error b/test/data/invalid-item-without-trailing-break.loader-error new file mode 100644 index 0000000..fdcf6c6 --- /dev/null +++ b/test/data/invalid-item-without-trailing-break.loader-error @@ -0,0 +1,2 @@ +- +-0 \ No newline at end of file diff --git a/test/data/invalid-merge-1.loader-error b/test/data/invalid-merge-1.loader-error new file mode 100644 index 0000000..fc3c284 --- /dev/null +++ b/test/data/invalid-merge-1.loader-error @@ -0,0 +1,2 @@ +foo: bar +<<: baz diff --git a/test/data/invalid-merge-2.loader-error b/test/data/invalid-merge-2.loader-error new file mode 100644 index 0000000..8e88615 --- /dev/null +++ b/test/data/invalid-merge-2.loader-error @@ -0,0 +1,2 @@ +foo: bar +<<: [x: 1, y: 2, z, t: 4] diff --git a/test/data/invalid-omap-1.loader-error b/test/data/invalid-omap-1.loader-error new file mode 100644 index 0000000..2863392 --- /dev/null +++ b/test/data/invalid-omap-1.loader-error @@ -0,0 +1,3 @@ +--- !!omap +foo: bar +baz: bat diff --git a/test/data/invalid-omap-2.loader-error b/test/data/invalid-omap-2.loader-error new file mode 100644 index 0000000..c377dfb --- /dev/null +++ b/test/data/invalid-omap-2.loader-error @@ -0,0 +1,3 @@ +--- !!omap +- foo: bar +- baz diff --git a/test/data/invalid-omap-3.loader-error b/test/data/invalid-omap-3.loader-error new file mode 100644 index 0000000..2a4f50d --- /dev/null +++ b/test/data/invalid-omap-3.loader-error @@ -0,0 +1,4 @@ +--- !!omap +- foo: bar +- baz: bar + bar: bar diff --git a/test/data/invalid-pairs-1.loader-error b/test/data/invalid-pairs-1.loader-error new file mode 100644 index 0000000..42d19ae --- /dev/null +++ b/test/data/invalid-pairs-1.loader-error @@ -0,0 +1,3 @@ +--- !!pairs +foo: bar +baz: bat diff --git a/test/data/invalid-pairs-2.loader-error b/test/data/invalid-pairs-2.loader-error new file mode 100644 index 0000000..31389ea --- /dev/null +++ b/test/data/invalid-pairs-2.loader-error @@ -0,0 +1,3 @@ +--- !!pairs +- foo: bar +- baz diff --git a/test/data/invalid-pairs-3.loader-error b/test/data/invalid-pairs-3.loader-error new file mode 100644 index 0000000..f8d7704 --- /dev/null +++ b/test/data/invalid-pairs-3.loader-error @@ -0,0 +1,4 @@ +--- !!pairs +- foo: bar +- baz: bar + bar: bar diff --git a/test/data/invalid-simple-key.loader-error b/test/data/invalid-simple-key.loader-error new file mode 100644 index 0000000..a58deec --- /dev/null +++ b/test/data/invalid-simple-key.loader-error @@ -0,0 +1,3 @@ +key: value +invalid simple key +next key: next value diff --git a/test/data/invalid-single-quote-bug.code b/test/data/invalid-single-quote-bug.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/invalid-single-quote-bug.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/invalid-single-quote-bug.data b/test/data/invalid-single-quote-bug.data new file mode 100644 index 0000000..76ef7ae --- /dev/null +++ b/test/data/invalid-single-quote-bug.data @@ -0,0 +1,2 @@ +- "foo 'bar'" +- "foo\n'bar'" diff --git a/test/data/invalid-starting-character.loader-error b/test/data/invalid-starting-character.loader-error new file mode 100644 index 0000000..bb81c60 --- /dev/null +++ b/test/data/invalid-starting-character.loader-error @@ -0,0 +1 @@ +@@@@@@@@@@@@@@@@@@@ diff --git a/test/data/invalid-tag-1.loader-error b/test/data/invalid-tag-1.loader-error new file mode 100644 index 0000000..a68cd38 --- /dev/null +++ b/test/data/invalid-tag-1.loader-error @@ -0,0 +1 @@ +- ! baz diff --git a/test/data/invalid-tag-2.loader-error b/test/data/invalid-tag-2.loader-error new file mode 100644 index 0000000..3a36700 --- /dev/null +++ b/test/data/invalid-tag-2.loader-error @@ -0,0 +1 @@ +- !prefix!foo#bar baz diff --git a/test/data/invalid-tag-directive-handle.loader-error b/test/data/invalid-tag-directive-handle.loader-error new file mode 100644 index 0000000..42b5d7e --- /dev/null +++ b/test/data/invalid-tag-directive-handle.loader-error @@ -0,0 +1,2 @@ +%TAG !!! !!! +--- diff --git a/test/data/invalid-tag-directive-prefix.loader-error b/test/data/invalid-tag-directive-prefix.loader-error new file mode 100644 index 0000000..0cb482c --- /dev/null +++ b/test/data/invalid-tag-directive-prefix.loader-error @@ -0,0 +1,2 @@ +%TAG ! tag:zz.com/foo#bar # '#' is not allowed in URLs +--- diff --git a/test/data/invalid-tag-handle-1.emitter-error b/test/data/invalid-tag-handle-1.emitter-error new file mode 100644 index 0000000..d5df9a2 --- /dev/null +++ b/test/data/invalid-tag-handle-1.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart { tags: { '!foo': 'bar' } } +- !Scalar { value: 'foo' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/invalid-tag-handle-1.loader-error b/test/data/invalid-tag-handle-1.loader-error new file mode 100644 index 0000000..ef0d143 --- /dev/null +++ b/test/data/invalid-tag-handle-1.loader-error @@ -0,0 +1,2 @@ +%TAG foo bar +--- diff --git a/test/data/invalid-tag-handle-2.emitter-error b/test/data/invalid-tag-handle-2.emitter-error new file mode 100644 index 0000000..d1831d5 --- /dev/null +++ b/test/data/invalid-tag-handle-2.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart { tags: { '!!!': 'bar' } } +- !Scalar { value: 'foo' } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/invalid-tag-handle-2.loader-error b/test/data/invalid-tag-handle-2.loader-error new file mode 100644 index 0000000..06c7f0e --- /dev/null +++ b/test/data/invalid-tag-handle-2.loader-error @@ -0,0 +1,2 @@ +%TAG !foo bar +--- diff --git a/test/data/invalid-uri-escapes-1.loader-error b/test/data/invalid-uri-escapes-1.loader-error new file mode 100644 index 0000000..a6ecb36 --- /dev/null +++ b/test/data/invalid-uri-escapes-1.loader-error @@ -0,0 +1 @@ +--- ! foo diff --git a/test/data/invalid-uri-escapes-2.loader-error b/test/data/invalid-uri-escapes-2.loader-error new file mode 100644 index 0000000..b89e8f6 --- /dev/null +++ b/test/data/invalid-uri-escapes-2.loader-error @@ -0,0 +1 @@ +--- !<%FF> foo diff --git a/test/data/invalid-uri-escapes-3.loader-error b/test/data/invalid-uri-escapes-3.loader-error new file mode 100644 index 0000000..f2e4cb8 --- /dev/null +++ b/test/data/invalid-uri-escapes-3.loader-error @@ -0,0 +1 @@ +--- ! baz diff --git a/test/data/invalid-uri.loader-error b/test/data/invalid-uri.loader-error new file mode 100644 index 0000000..06307e0 --- /dev/null +++ b/test/data/invalid-uri.loader-error @@ -0,0 +1 @@ +--- !foo! bar diff --git a/test/data/invalid-utf8-byte.loader-error b/test/data/invalid-utf8-byte.loader-error new file mode 100644 index 0000000..0a58c70 --- /dev/null +++ b/test/data/invalid-utf8-byte.loader-error @@ -0,0 +1,66 @@ +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +Invalid byte ('\xFF'): <-- +############################################################### diff --git a/test/data/invalid-utf8-byte.stream-error b/test/data/invalid-utf8-byte.stream-error new file mode 100644 index 0000000..0a58c70 --- /dev/null +++ b/test/data/invalid-utf8-byte.stream-error @@ -0,0 +1,66 @@ +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +Invalid byte ('\xFF'): <-- +############################################################### diff --git a/test/data/invalid-yaml-directive-version-1.loader-error b/test/data/invalid-yaml-directive-version-1.loader-error new file mode 100644 index 0000000..e9b4e3a --- /dev/null +++ b/test/data/invalid-yaml-directive-version-1.loader-error @@ -0,0 +1,3 @@ +# No version at all. +%YAML +--- diff --git a/test/data/invalid-yaml-directive-version-2.loader-error b/test/data/invalid-yaml-directive-version-2.loader-error new file mode 100644 index 0000000..6aa7740 --- /dev/null +++ b/test/data/invalid-yaml-directive-version-2.loader-error @@ -0,0 +1,2 @@ +%YAML 1e-5 +--- diff --git a/test/data/invalid-yaml-directive-version-3.loader-error b/test/data/invalid-yaml-directive-version-3.loader-error new file mode 100644 index 0000000..345e784 --- /dev/null +++ b/test/data/invalid-yaml-directive-version-3.loader-error @@ -0,0 +1,2 @@ +%YAML 1. +--- diff --git a/test/data/invalid-yaml-directive-version-4.loader-error b/test/data/invalid-yaml-directive-version-4.loader-error new file mode 100644 index 0000000..b35ca82 --- /dev/null +++ b/test/data/invalid-yaml-directive-version-4.loader-error @@ -0,0 +1,2 @@ +%YAML 1.132.435 +--- diff --git a/test/data/invalid-yaml-directive-version-5.loader-error b/test/data/invalid-yaml-directive-version-5.loader-error new file mode 100644 index 0000000..7c2b49f --- /dev/null +++ b/test/data/invalid-yaml-directive-version-5.loader-error @@ -0,0 +1,2 @@ +%YAML A.0 +--- diff --git a/test/data/invalid-yaml-directive-version-6.loader-error b/test/data/invalid-yaml-directive-version-6.loader-error new file mode 100644 index 0000000..bae714f --- /dev/null +++ b/test/data/invalid-yaml-directive-version-6.loader-error @@ -0,0 +1,2 @@ +%YAML 123.C +--- diff --git a/test/data/invalid-yaml-version.loader-error b/test/data/invalid-yaml-version.loader-error new file mode 100644 index 0000000..dd01948 --- /dev/null +++ b/test/data/invalid-yaml-version.loader-error @@ -0,0 +1,2 @@ +%YAML 2.0 +--- foo diff --git a/test/data/latin.unicode b/test/data/latin.unicode new file mode 100644 index 0000000..4fb799c --- /dev/null +++ b/test/data/latin.unicode @@ -0,0 +1,384 @@ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊ +ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎ +ďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐ +őŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒ +ƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƼƽƾƿDŽdžLJljNJnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜ +ǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ +ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯ +ɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯΆΈ +ΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύ +ώϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБ +ВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓ +єѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝ +ҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠ +ӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉ +ՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևႠႡႢႣႤႥႦႧႨႩႪႫႬႭ +ႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅᴀᴁᴂᴃᴄᴅᴆᴇᴈᴉᴊᴋᴌᴍᴎᴏᴐᴑᴒᴓᴔᴕᴖᴗᴘᴙᴚᴛᴜᴝᴞᴟᴠᴡᴢᴣᴤᴥᴦᴧᴨᴩ +ᴪᴫᵢᵣᵤᵥᵦᵧᵨᵩᵪᵫᵬᵭᵮᵯᵰᵱᵲᵳᵴᵵᵶᵷᵹᵺᵻᵼᵽᵾᵿᶀᶁᶂᶃᶄᶅᶆᶇᶈᶉᶊᶋᶌᶍᶎᶏᶐᶑᶒᶓᶔᶕᶖᶗᶘᶙᶚḀḁḂḃḄḅḆḇ +ḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉ +ṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋ +ẌẍẎẏẐẑẒẓẔẕẖẗẘẙẚẛẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐố +ỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛ +ἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧ +ὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆιῂῃῄῆῇῈΈῊ +ΉῐῑῒΐῖῗῘῙῚΊῠῡῢΰῤῥῦῧῨῩῪΎῬῲῳῴῶῷῸΌῺΏⁱⁿℂℇℊℋℌℍℎℏℐℑℒℓℕℙℚℛℜℝℤΩℨKÅℬℭℯℰℱℳℴℹ diff --git a/test/data/mappings.events b/test/data/mappings.events new file mode 100644 index 0000000..3cb5579 --- /dev/null +++ b/test/data/mappings.events @@ -0,0 +1,44 @@ +- !StreamStart + +- !DocumentStart +- !MappingStart +- !Scalar { implicit: [true,true], value: 'key' } +- !Scalar { implicit: [true,true], value: 'value' } +- !Scalar { implicit: [true,true], value: 'empty mapping' } +- !MappingStart +- !MappingEnd +- !Scalar { implicit: [true,true], value: 'empty mapping with tag' } +- !MappingStart { tag: '!mytag', implicit: false } +- !MappingEnd +- !Scalar { implicit: [true,true], value: 'block mapping' } +- !MappingStart +- !MappingStart +- !Scalar { implicit: [true,true], value: 'complex' } +- !Scalar { implicit: [true,true], value: 'key' } +- !Scalar { implicit: [true,true], value: 'complex' } +- !Scalar { implicit: [true,true], value: 'key' } +- !MappingEnd +- !MappingStart +- !Scalar { implicit: [true,true], value: 'complex' } +- !Scalar { implicit: [true,true], value: 'key' } +- !MappingEnd +- !MappingEnd +- !Scalar { implicit: [true,true], value: 'flow mapping' } +- !MappingStart { flow_style: true } +- !Scalar { implicit: [true,true], value: 'key' } +- !Scalar { implicit: [true,true], value: 'value' } +- !MappingStart +- !Scalar { implicit: [true,true], value: 'complex' } +- !Scalar { implicit: [true,true], value: 'key' } +- !Scalar { implicit: [true,true], value: 'complex' } +- !Scalar { implicit: [true,true], value: 'key' } +- !MappingEnd +- !MappingStart +- !Scalar { implicit: [true,true], value: 'complex' } +- !Scalar { implicit: [true,true], value: 'key' } +- !MappingEnd +- !MappingEnd +- !MappingEnd +- !DocumentEnd + +- !StreamEnd diff --git a/test/data/merge.data b/test/data/merge.data new file mode 100644 index 0000000..e455bbc --- /dev/null +++ b/test/data/merge.data @@ -0,0 +1 @@ +- << diff --git a/test/data/merge.detect b/test/data/merge.detect new file mode 100644 index 0000000..1672d0d --- /dev/null +++ b/test/data/merge.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:merge diff --git a/test/data/more-floats.code b/test/data/more-floats.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/more-floats.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/more-floats.data b/test/data/more-floats.data new file mode 100644 index 0000000..399eb17 --- /dev/null +++ b/test/data/more-floats.data @@ -0,0 +1 @@ +[0.0, +1.0, -1.0, +.inf, -.inf, .nan, .nan] diff --git a/test/data/negative-float-bug.code b/test/data/negative-float-bug.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/negative-float-bug.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/negative-float-bug.data b/test/data/negative-float-bug.data new file mode 100644 index 0000000..18e16e3 --- /dev/null +++ b/test/data/negative-float-bug.data @@ -0,0 +1 @@ +-1.0 diff --git a/test/data/no-alias-anchor.emitter-error b/test/data/no-alias-anchor.emitter-error new file mode 100644 index 0000000..5ff065c --- /dev/null +++ b/test/data/no-alias-anchor.emitter-error @@ -0,0 +1,8 @@ +- !StreamStart +- !DocumentStart +- !SequenceStart +- !Scalar { anchor: A, value: data } +- !Alias { } +- !SequenceEnd +- !DocumentEnd +- !StreamEnd diff --git a/test/data/no-alias-anchor.skip-ext b/test/data/no-alias-anchor.skip-ext new file mode 100644 index 0000000..e69de29 diff --git a/test/data/no-block-collection-end.loader-error b/test/data/no-block-collection-end.loader-error new file mode 100644 index 0000000..02d4d37 --- /dev/null +++ b/test/data/no-block-collection-end.loader-error @@ -0,0 +1,3 @@ +- foo +- bar +baz: bar diff --git a/test/data/no-block-mapping-end-2.loader-error b/test/data/no-block-mapping-end-2.loader-error new file mode 100644 index 0000000..be63571 --- /dev/null +++ b/test/data/no-block-mapping-end-2.loader-error @@ -0,0 +1,3 @@ +? foo +: bar +: baz diff --git a/test/data/no-block-mapping-end.loader-error b/test/data/no-block-mapping-end.loader-error new file mode 100644 index 0000000..1ea921c --- /dev/null +++ b/test/data/no-block-mapping-end.loader-error @@ -0,0 +1 @@ +foo: "bar" "baz" diff --git a/test/data/no-document-start.loader-error b/test/data/no-document-start.loader-error new file mode 100644 index 0000000..c725ec8 --- /dev/null +++ b/test/data/no-document-start.loader-error @@ -0,0 +1,3 @@ +%YAML 1.1 +# no --- +foo: bar diff --git a/test/data/no-flow-mapping-end.loader-error b/test/data/no-flow-mapping-end.loader-error new file mode 100644 index 0000000..8bd1403 --- /dev/null +++ b/test/data/no-flow-mapping-end.loader-error @@ -0,0 +1 @@ +{ foo: bar ] diff --git a/test/data/no-flow-sequence-end.loader-error b/test/data/no-flow-sequence-end.loader-error new file mode 100644 index 0000000..750d973 --- /dev/null +++ b/test/data/no-flow-sequence-end.loader-error @@ -0,0 +1 @@ +[foo, bar} diff --git a/test/data/no-node-1.loader-error b/test/data/no-node-1.loader-error new file mode 100644 index 0000000..07b1500 --- /dev/null +++ b/test/data/no-node-1.loader-error @@ -0,0 +1 @@ +- !foo ] diff --git a/test/data/no-node-2.loader-error b/test/data/no-node-2.loader-error new file mode 100644 index 0000000..563e3b3 --- /dev/null +++ b/test/data/no-node-2.loader-error @@ -0,0 +1 @@ +- [ !foo } ] diff --git a/test/data/no-tag.emitter-error b/test/data/no-tag.emitter-error new file mode 100644 index 0000000..384c62f --- /dev/null +++ b/test/data/no-tag.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart +- !Scalar { value: 'foo', implicit: [false,false] } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/null.data b/test/data/null.data new file mode 100644 index 0000000..ad12528 --- /dev/null +++ b/test/data/null.data @@ -0,0 +1,3 @@ +- +- ~ +- null diff --git a/test/data/null.detect b/test/data/null.detect new file mode 100644 index 0000000..19110c7 --- /dev/null +++ b/test/data/null.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:null diff --git a/test/data/odd-utf16.stream-error b/test/data/odd-utf16.stream-error new file mode 100644 index 0000000000000000000000000000000000000000..b59e43449b1c25d5728f38bf124a59e2b882ada1 GIT binary patch literal 1311 zcmeH`OA5k35JcbFQ#53&f*X(E3E}}_j3~qzNTT57)t6jiHld-XtEQ?O=JWkg6^%{N z=@skz_5MqqK>7DqbLYWGaC7bHtXeXOiAE+Zdzq^dq8Cptss>Tk6QYmWPTf{C%7(tl k+}a@-c|o%)WP-Q3S2K4!Q*&a+fum?tIjC!#vM>HS|1HgG(*OVf literal 0 HcmV?d00001 diff --git a/test/data/recursive.former-dumper-error b/test/data/recursive.former-dumper-error new file mode 100644 index 0000000..3c7cc2f --- /dev/null +++ b/test/data/recursive.former-dumper-error @@ -0,0 +1,3 @@ +data = [] +data.append(data) +dump(data) diff --git a/test/data/remove-possible-simple-key-bug.loader-error b/test/data/remove-possible-simple-key-bug.loader-error new file mode 100644 index 0000000..fe1bc6c --- /dev/null +++ b/test/data/remove-possible-simple-key-bug.loader-error @@ -0,0 +1,3 @@ +foo: &A bar +*A ] # The ']' indicator triggers remove_possible_simple_key, + # which should raise an error. diff --git a/test/data/resolver.data b/test/data/resolver.data new file mode 100644 index 0000000..a296404 --- /dev/null +++ b/test/data/resolver.data @@ -0,0 +1,30 @@ +--- +"this scalar should be selected" +--- +key11: !foo + key12: + is: [selected] + key22: + key13: [not, selected] + key23: [not, selected] + key32: + key31: [not, selected] + key32: [not, selected] + key33: {not: selected} +key21: !bar + - not selected + - selected + - not selected +key31: !baz + key12: + key13: + key14: {selected} + key23: + key14: [not, selected] + key33: + key14: {selected} + key24: {not: selected} + key22: + - key14: {selected} + key24: {not: selected} + - key14: {selected} diff --git a/test/data/resolver.path b/test/data/resolver.path new file mode 100644 index 0000000..ec677d2 --- /dev/null +++ b/test/data/resolver.path @@ -0,0 +1,30 @@ +--- !root/scalar +"this scalar should be selected" +--- !root +key11: !foo + key12: !root/key11/key12/* + is: [selected] + key22: + key13: [not, selected] + key23: [not, selected] + key32: + key31: [not, selected] + key32: [not, selected] + key33: {not: selected} +key21: !bar + - not selected + - !root/key21/1/* selected + - not selected +key31: !baz + key12: + key13: + key14: !root/key31/*/*/key14/map {selected} + key23: + key14: [not, selected] + key33: + key14: !root/key31/*/*/key14/map {selected} + key24: {not: selected} + key22: + - key14: !root/key31/*/*/key14/map {selected} + key24: {not: selected} + - key14: !root/key31/*/*/key14/map {selected} diff --git a/test/data/run-parser-crash-bug.data b/test/data/run-parser-crash-bug.data new file mode 100644 index 0000000..fe01734 --- /dev/null +++ b/test/data/run-parser-crash-bug.data @@ -0,0 +1,8 @@ +--- +- Harry Potter and the Prisoner of Azkaban +- Harry Potter and the Goblet of Fire +- Harry Potter and the Order of the Phoenix +--- +- Memoirs Found in a Bathtub +- Snow Crash +- Ghost World diff --git a/test/data/scalars.events b/test/data/scalars.events new file mode 100644 index 0000000..32c40f4 --- /dev/null +++ b/test/data/scalars.events @@ -0,0 +1,28 @@ +- !StreamStart + +- !DocumentStart +- !MappingStart +- !Scalar { implicit: [true,true], value: 'empty scalar' } +- !Scalar { implicit: [true,false], value: '' } +- !Scalar { implicit: [true,true], value: 'implicit scalar' } +- !Scalar { implicit: [true,true], value: 'data' } +- !Scalar { implicit: [true,true], value: 'quoted scalar' } +- !Scalar { value: 'data', style: '"' } +- !Scalar { implicit: [true,true], value: 'block scalar' } +- !Scalar { value: 'data', style: '|' } +- !Scalar { implicit: [true,true], value: 'empty scalar with tag' } +- !Scalar { implicit: [false,false], tag: '!mytag', value: '' } +- !Scalar { implicit: [true,true], value: 'implicit scalar with tag' } +- !Scalar { implicit: [false,false], tag: '!mytag', value: 'data' } +- !Scalar { implicit: [true,true], value: 'quoted scalar with tag' } +- !Scalar { value: 'data', style: '"', tag: '!mytag', implicit: [false,false] } +- !Scalar { implicit: [true,true], value: 'block scalar with tag' } +- !Scalar { value: 'data', style: '|', tag: '!mytag', implicit: [false,false] } +- !Scalar { implicit: [true,true], value: 'single character' } +- !Scalar { value: 'a', implicit: [true,true] } +- !Scalar { implicit: [true,true], value: 'single digit' } +- !Scalar { value: '1', implicit: [true,false] } +- !MappingEnd +- !DocumentEnd + +- !StreamEnd diff --git a/test/data/scan-document-end-bug.canonical b/test/data/scan-document-end-bug.canonical new file mode 100644 index 0000000..4a0e8a8 --- /dev/null +++ b/test/data/scan-document-end-bug.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!null "" diff --git a/test/data/scan-document-end-bug.data b/test/data/scan-document-end-bug.data new file mode 100644 index 0000000..3c70543 --- /dev/null +++ b/test/data/scan-document-end-bug.data @@ -0,0 +1,3 @@ +# Ticket #4 +--- +... \ No newline at end of file diff --git a/test/data/scan-line-break-bug.canonical b/test/data/scan-line-break-bug.canonical new file mode 100644 index 0000000..79f08b7 --- /dev/null +++ b/test/data/scan-line-break-bug.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!map { ? !!str "foo" : !!str "bar baz" } diff --git a/test/data/scan-line-break-bug.data b/test/data/scan-line-break-bug.data new file mode 100644 index 0000000..c974fab --- /dev/null +++ b/test/data/scan-line-break-bug.data @@ -0,0 +1,3 @@ +foo: + bar + baz diff --git a/test/data/sequences.events b/test/data/sequences.events new file mode 100644 index 0000000..692a329 --- /dev/null +++ b/test/data/sequences.events @@ -0,0 +1,81 @@ +- !StreamStart + +- !DocumentStart +- !SequenceStart +- !SequenceEnd +- !DocumentEnd + +- !DocumentStart +- !SequenceStart { tag: '!mytag', implicit: false } +- !SequenceEnd +- !DocumentEnd + +- !DocumentStart +- !SequenceStart +- !SequenceStart +- !SequenceEnd +- !SequenceStart { tag: '!mytag', implicit: false } +- !SequenceEnd +- !SequenceStart +- !Scalar +- !Scalar { value: 'data' } +- !Scalar { tag: '!mytag', implicit: [false,false], value: 'data' } +- !SequenceEnd +- !SequenceStart +- !SequenceStart +- !SequenceStart +- !Scalar +- !SequenceEnd +- !SequenceEnd +- !SequenceEnd +- !SequenceStart +- !SequenceStart { tag: '!mytag', implicit: false } +- !SequenceStart +- !Scalar { value: 'data' } +- !SequenceEnd +- !SequenceEnd +- !SequenceEnd +- !SequenceEnd +- !DocumentEnd + +- !DocumentStart +- !SequenceStart +- !MappingStart +- !Scalar { value: 'key1' } +- !SequenceStart +- !Scalar { value: 'data1' } +- !Scalar { value: 'data2' } +- !SequenceEnd +- !Scalar { value: 'key2' } +- !SequenceStart { tag: '!mytag1', implicit: false } +- !Scalar { value: 'data3' } +- !SequenceStart +- !Scalar { value: 'data4' } +- !Scalar { value: 'data5' } +- !SequenceEnd +- !SequenceStart { tag: '!mytag2', implicit: false } +- !Scalar { value: 'data6' } +- !Scalar { value: 'data7' } +- !SequenceEnd +- !SequenceEnd +- !MappingEnd +- !SequenceEnd +- !DocumentEnd + +- !DocumentStart +- !SequenceStart +- !SequenceStart { flow_style: true } +- !SequenceStart +- !SequenceEnd +- !Scalar +- !Scalar { value: 'data' } +- !Scalar { tag: '!mytag', implicit: [false,false], value: 'data' } +- !SequenceStart { tag: '!mytag', implicit: false } +- !Scalar { value: 'data' } +- !Scalar { value: 'data' } +- !SequenceEnd +- !SequenceEnd +- !SequenceEnd +- !DocumentEnd + +- !StreamEnd diff --git a/test/data/serializer-is-already-opened.dumper-error b/test/data/serializer-is-already-opened.dumper-error new file mode 100644 index 0000000..9a23525 --- /dev/null +++ b/test/data/serializer-is-already-opened.dumper-error @@ -0,0 +1,3 @@ +dumper = yaml.Dumper(StringIO()) +dumper.open() +dumper.open() diff --git a/test/data/serializer-is-closed-1.dumper-error b/test/data/serializer-is-closed-1.dumper-error new file mode 100644 index 0000000..8e7e600 --- /dev/null +++ b/test/data/serializer-is-closed-1.dumper-error @@ -0,0 +1,4 @@ +dumper = yaml.Dumper(StringIO()) +dumper.open() +dumper.close() +dumper.open() diff --git a/test/data/serializer-is-closed-2.dumper-error b/test/data/serializer-is-closed-2.dumper-error new file mode 100644 index 0000000..89aef7e --- /dev/null +++ b/test/data/serializer-is-closed-2.dumper-error @@ -0,0 +1,4 @@ +dumper = yaml.Dumper(StringIO()) +dumper.open() +dumper.close() +dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar')) diff --git a/test/data/serializer-is-not-opened-1.dumper-error b/test/data/serializer-is-not-opened-1.dumper-error new file mode 100644 index 0000000..8f22e73 --- /dev/null +++ b/test/data/serializer-is-not-opened-1.dumper-error @@ -0,0 +1,2 @@ +dumper = yaml.Dumper(StringIO()) +dumper.close() diff --git a/test/data/serializer-is-not-opened-2.dumper-error b/test/data/serializer-is-not-opened-2.dumper-error new file mode 100644 index 0000000..ebd9df1 --- /dev/null +++ b/test/data/serializer-is-not-opened-2.dumper-error @@ -0,0 +1,2 @@ +dumper = yaml.Dumper(StringIO()) +dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar')) diff --git a/test/data/single-dot-is-not-float-bug.code b/test/data/single-dot-is-not-float-bug.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/single-dot-is-not-float-bug.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/single-dot-is-not-float-bug.data b/test/data/single-dot-is-not-float-bug.data new file mode 100644 index 0000000..9c558e3 --- /dev/null +++ b/test/data/single-dot-is-not-float-bug.data @@ -0,0 +1 @@ +. diff --git a/test/data/sloppy-indentation.canonical b/test/data/sloppy-indentation.canonical new file mode 100644 index 0000000..438bc04 --- /dev/null +++ b/test/data/sloppy-indentation.canonical @@ -0,0 +1,18 @@ +%YAML 1.1 +--- +!!map { + ? !!str "in the block context" + : !!map { + ? !!str "indentation should be kept" + : !!map { + ? !!str "but in the flow context" + : !!seq [ !!str "it may be violated" ] + } + } +} +--- !!str +"the parser does not require scalars to be indented with at least one space" +--- !!str +"the parser does not require scalars to be indented with at least one space" +--- !!map +{ ? !!str "foo": { ? !!str "bar" : !!str "quoted scalars may not adhere indentation" } } diff --git a/test/data/sloppy-indentation.data b/test/data/sloppy-indentation.data new file mode 100644 index 0000000..2eb4f5a --- /dev/null +++ b/test/data/sloppy-indentation.data @@ -0,0 +1,17 @@ +--- +in the block context: + indentation should be kept: { + but in the flow context: [ +it may be violated] +} +--- +the parser does not require scalars +to be indented with at least one space +... +--- +"the parser does not require scalars +to be indented with at least one space" +--- +foo: + bar: 'quoted scalars +may not adhere indentation' diff --git a/test/data/spec-02-01.data b/test/data/spec-02-01.data new file mode 100644 index 0000000..d12e671 --- /dev/null +++ b/test/data/spec-02-01.data @@ -0,0 +1,3 @@ +- Mark McGwire +- Sammy Sosa +- Ken Griffey diff --git a/test/data/spec-02-01.structure b/test/data/spec-02-01.structure new file mode 100644 index 0000000..f532f4a --- /dev/null +++ b/test/data/spec-02-01.structure @@ -0,0 +1 @@ +[True, True, True] diff --git a/test/data/spec-02-01.tokens b/test/data/spec-02-01.tokens new file mode 100644 index 0000000..ce44cac --- /dev/null +++ b/test/data/spec-02-01.tokens @@ -0,0 +1 @@ +[[ , _ , _ , _ ]} diff --git a/test/data/spec-02-02.data b/test/data/spec-02-02.data new file mode 100644 index 0000000..7b7ec94 --- /dev/null +++ b/test/data/spec-02-02.data @@ -0,0 +1,3 @@ +hr: 65 # Home runs +avg: 0.278 # Batting average +rbi: 147 # Runs Batted In diff --git a/test/data/spec-02-02.structure b/test/data/spec-02-02.structure new file mode 100644 index 0000000..aba1ced --- /dev/null +++ b/test/data/spec-02-02.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-02.tokens b/test/data/spec-02-02.tokens new file mode 100644 index 0000000..e4e381b --- /dev/null +++ b/test/data/spec-02-02.tokens @@ -0,0 +1,5 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-03.data b/test/data/spec-02-03.data new file mode 100644 index 0000000..656d628 --- /dev/null +++ b/test/data/spec-02-03.data @@ -0,0 +1,8 @@ +american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees +national: + - New York Mets + - Chicago Cubs + - Atlanta Braves diff --git a/test/data/spec-02-03.structure b/test/data/spec-02-03.structure new file mode 100644 index 0000000..25de5d2 --- /dev/null +++ b/test/data/spec-02-03.structure @@ -0,0 +1 @@ +[(True, [True, True, True]), (True, [True, True, True])] diff --git a/test/data/spec-02-03.tokens b/test/data/spec-02-03.tokens new file mode 100644 index 0000000..89815f2 --- /dev/null +++ b/test/data/spec-02-03.tokens @@ -0,0 +1,4 @@ +{{ +? _ : [[ , _ , _ , _ ]} +? _ : [[ , _ , _ , _ ]} +]} diff --git a/test/data/spec-02-04.data b/test/data/spec-02-04.data new file mode 100644 index 0000000..430f6b3 --- /dev/null +++ b/test/data/spec-02-04.data @@ -0,0 +1,8 @@ +- + name: Mark McGwire + hr: 65 + avg: 0.278 +- + name: Sammy Sosa + hr: 63 + avg: 0.288 diff --git a/test/data/spec-02-04.structure b/test/data/spec-02-04.structure new file mode 100644 index 0000000..e7b526c --- /dev/null +++ b/test/data/spec-02-04.structure @@ -0,0 +1,4 @@ +[ + [(True, True), (True, True), (True, True)], + [(True, True), (True, True), (True, True)], +] diff --git a/test/data/spec-02-04.tokens b/test/data/spec-02-04.tokens new file mode 100644 index 0000000..9cb9815 --- /dev/null +++ b/test/data/spec-02-04.tokens @@ -0,0 +1,4 @@ +[[ +, {{ ? _ : _ ? _ : _ ? _ : _ ]} +, {{ ? _ : _ ? _ : _ ? _ : _ ]} +]} diff --git a/test/data/spec-02-05.data b/test/data/spec-02-05.data new file mode 100644 index 0000000..cdd7770 --- /dev/null +++ b/test/data/spec-02-05.data @@ -0,0 +1,3 @@ +- [name , hr, avg ] +- [Mark McGwire, 65, 0.278] +- [Sammy Sosa , 63, 0.288] diff --git a/test/data/spec-02-05.structure b/test/data/spec-02-05.structure new file mode 100644 index 0000000..e06b75a --- /dev/null +++ b/test/data/spec-02-05.structure @@ -0,0 +1,5 @@ +[ + [True, True, True], + [True, True, True], + [True, True, True], +] diff --git a/test/data/spec-02-05.tokens b/test/data/spec-02-05.tokens new file mode 100644 index 0000000..3f6f1ab --- /dev/null +++ b/test/data/spec-02-05.tokens @@ -0,0 +1,5 @@ +[[ +, [ _ , _ , _ ] +, [ _ , _ , _ ] +, [ _ , _ , _ ] +]} diff --git a/test/data/spec-02-06.data b/test/data/spec-02-06.data new file mode 100644 index 0000000..7a957b2 --- /dev/null +++ b/test/data/spec-02-06.data @@ -0,0 +1,5 @@ +Mark McGwire: {hr: 65, avg: 0.278} +Sammy Sosa: { + hr: 63, + avg: 0.288 + } diff --git a/test/data/spec-02-06.structure b/test/data/spec-02-06.structure new file mode 100644 index 0000000..3ef0f4b --- /dev/null +++ b/test/data/spec-02-06.structure @@ -0,0 +1,4 @@ +[ + (True, [(True, True), (True, True)]), + (True, [(True, True), (True, True)]), +] diff --git a/test/data/spec-02-06.tokens b/test/data/spec-02-06.tokens new file mode 100644 index 0000000..a1a5eef --- /dev/null +++ b/test/data/spec-02-06.tokens @@ -0,0 +1,4 @@ +{{ +? _ : { ? _ : _ , ? _ : _ } +? _ : { ? _ : _ , ? _ : _ } +]} diff --git a/test/data/spec-02-07.data b/test/data/spec-02-07.data new file mode 100644 index 0000000..bc711d5 --- /dev/null +++ b/test/data/spec-02-07.data @@ -0,0 +1,10 @@ +# Ranking of 1998 home runs +--- +- Mark McGwire +- Sammy Sosa +- Ken Griffey + +# Team ranking +--- +- Chicago Cubs +- St Louis Cardinals diff --git a/test/data/spec-02-07.structure b/test/data/spec-02-07.structure new file mode 100644 index 0000000..c5d72a3 --- /dev/null +++ b/test/data/spec-02-07.structure @@ -0,0 +1,4 @@ +[ +[True, True, True], +[True, True], +] diff --git a/test/data/spec-02-07.tokens b/test/data/spec-02-07.tokens new file mode 100644 index 0000000..ed48883 --- /dev/null +++ b/test/data/spec-02-07.tokens @@ -0,0 +1,12 @@ +--- +[[ +, _ +, _ +, _ +]} + +--- +[[ +, _ +, _ +]} diff --git a/test/data/spec-02-08.data b/test/data/spec-02-08.data new file mode 100644 index 0000000..05e102d --- /dev/null +++ b/test/data/spec-02-08.data @@ -0,0 +1,10 @@ +--- +time: 20:03:20 +player: Sammy Sosa +action: strike (miss) +... +--- +time: 20:03:47 +player: Sammy Sosa +action: grand slam +... diff --git a/test/data/spec-02-08.structure b/test/data/spec-02-08.structure new file mode 100644 index 0000000..24cff73 --- /dev/null +++ b/test/data/spec-02-08.structure @@ -0,0 +1,4 @@ +[ +[(True, True), (True, True), (True, True)], +[(True, True), (True, True), (True, True)], +] diff --git a/test/data/spec-02-08.tokens b/test/data/spec-02-08.tokens new file mode 100644 index 0000000..7d2c03d --- /dev/null +++ b/test/data/spec-02-08.tokens @@ -0,0 +1,15 @@ +--- +{{ +? _ : _ +? _ : _ +? _ : _ +]} +... + +--- +{{ +? _ : _ +? _ : _ +? _ : _ +]} +... diff --git a/test/data/spec-02-09.data b/test/data/spec-02-09.data new file mode 100644 index 0000000..e264180 --- /dev/null +++ b/test/data/spec-02-09.data @@ -0,0 +1,8 @@ +--- +hr: # 1998 hr ranking + - Mark McGwire + - Sammy Sosa +rbi: + # 1998 rbi ranking + - Sammy Sosa + - Ken Griffey diff --git a/test/data/spec-02-09.structure b/test/data/spec-02-09.structure new file mode 100644 index 0000000..b4c9914 --- /dev/null +++ b/test/data/spec-02-09.structure @@ -0,0 +1 @@ +[(True, [True, True]), (True, [True, True])] diff --git a/test/data/spec-02-09.tokens b/test/data/spec-02-09.tokens new file mode 100644 index 0000000..b2ec10e --- /dev/null +++ b/test/data/spec-02-09.tokens @@ -0,0 +1,5 @@ +--- +{{ +? _ : [[ , _ , _ ]} +? _ : [[ , _ , _ ]} +]} diff --git a/test/data/spec-02-10.data b/test/data/spec-02-10.data new file mode 100644 index 0000000..61808f6 --- /dev/null +++ b/test/data/spec-02-10.data @@ -0,0 +1,8 @@ +--- +hr: + - Mark McGwire + # Following node labeled SS + - &SS Sammy Sosa +rbi: + - *SS # Subsequent occurrence + - Ken Griffey diff --git a/test/data/spec-02-10.structure b/test/data/spec-02-10.structure new file mode 100644 index 0000000..ff8f4c3 --- /dev/null +++ b/test/data/spec-02-10.structure @@ -0,0 +1 @@ +[(True, [True, True]), (True, ['*', True])] diff --git a/test/data/spec-02-10.tokens b/test/data/spec-02-10.tokens new file mode 100644 index 0000000..26caa2b --- /dev/null +++ b/test/data/spec-02-10.tokens @@ -0,0 +1,5 @@ +--- +{{ +? _ : [[ , _ , & _ ]} +? _ : [[ , * , _ ]} +]} diff --git a/test/data/spec-02-11.data b/test/data/spec-02-11.data new file mode 100644 index 0000000..9123ce2 --- /dev/null +++ b/test/data/spec-02-11.data @@ -0,0 +1,9 @@ +? - Detroit Tigers + - Chicago cubs +: + - 2001-07-23 + +? [ New York Yankees, + Atlanta Braves ] +: [ 2001-07-02, 2001-08-12, + 2001-08-14 ] diff --git a/test/data/spec-02-11.structure b/test/data/spec-02-11.structure new file mode 100644 index 0000000..3d8f1ff --- /dev/null +++ b/test/data/spec-02-11.structure @@ -0,0 +1,4 @@ +[ +([True, True], [True]), +([True, True], [True, True, True]), +] diff --git a/test/data/spec-02-11.tokens b/test/data/spec-02-11.tokens new file mode 100644 index 0000000..fe24203 --- /dev/null +++ b/test/data/spec-02-11.tokens @@ -0,0 +1,6 @@ +{{ +? [[ , _ , _ ]} +: [[ , _ ]} +? [ _ , _ ] +: [ _ , _ , _ ] +]} diff --git a/test/data/spec-02-12.data b/test/data/spec-02-12.data new file mode 100644 index 0000000..1fc33f9 --- /dev/null +++ b/test/data/spec-02-12.data @@ -0,0 +1,8 @@ +--- +# products purchased +- item : Super Hoop + quantity: 1 +- item : Basketball + quantity: 4 +- item : Big Shoes + quantity: 1 diff --git a/test/data/spec-02-12.structure b/test/data/spec-02-12.structure new file mode 100644 index 0000000..e9c5359 --- /dev/null +++ b/test/data/spec-02-12.structure @@ -0,0 +1,5 @@ +[ +[(True, True), (True, True)], +[(True, True), (True, True)], +[(True, True), (True, True)], +] diff --git a/test/data/spec-02-12.tokens b/test/data/spec-02-12.tokens new file mode 100644 index 0000000..ea21e50 --- /dev/null +++ b/test/data/spec-02-12.tokens @@ -0,0 +1,6 @@ +--- +[[ +, {{ ? _ : _ ? _ : _ ]} +, {{ ? _ : _ ? _ : _ ]} +, {{ ? _ : _ ? _ : _ ]} +]} diff --git a/test/data/spec-02-13.data b/test/data/spec-02-13.data new file mode 100644 index 0000000..13fb656 --- /dev/null +++ b/test/data/spec-02-13.data @@ -0,0 +1,4 @@ +# ASCII Art +--- | + \//||\/|| + // || ||__ diff --git a/test/data/spec-02-13.structure b/test/data/spec-02-13.structure new file mode 100644 index 0000000..0ca9514 --- /dev/null +++ b/test/data/spec-02-13.structure @@ -0,0 +1 @@ +True diff --git a/test/data/spec-02-13.tokens b/test/data/spec-02-13.tokens new file mode 100644 index 0000000..7456c05 --- /dev/null +++ b/test/data/spec-02-13.tokens @@ -0,0 +1 @@ +--- _ diff --git a/test/data/spec-02-14.data b/test/data/spec-02-14.data new file mode 100644 index 0000000..59943de --- /dev/null +++ b/test/data/spec-02-14.data @@ -0,0 +1,4 @@ +--- + Mark McGwire's + year was crippled + by a knee injury. diff --git a/test/data/spec-02-14.structure b/test/data/spec-02-14.structure new file mode 100644 index 0000000..0ca9514 --- /dev/null +++ b/test/data/spec-02-14.structure @@ -0,0 +1 @@ +True diff --git a/test/data/spec-02-14.tokens b/test/data/spec-02-14.tokens new file mode 100644 index 0000000..7456c05 --- /dev/null +++ b/test/data/spec-02-14.tokens @@ -0,0 +1 @@ +--- _ diff --git a/test/data/spec-02-15.data b/test/data/spec-02-15.data new file mode 100644 index 0000000..80b89a6 --- /dev/null +++ b/test/data/spec-02-15.data @@ -0,0 +1,8 @@ +> + Sammy Sosa completed another + fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! diff --git a/test/data/spec-02-15.structure b/test/data/spec-02-15.structure new file mode 100644 index 0000000..0ca9514 --- /dev/null +++ b/test/data/spec-02-15.structure @@ -0,0 +1 @@ +True diff --git a/test/data/spec-02-15.tokens b/test/data/spec-02-15.tokens new file mode 100644 index 0000000..31354ec --- /dev/null +++ b/test/data/spec-02-15.tokens @@ -0,0 +1 @@ +_ diff --git a/test/data/spec-02-16.data b/test/data/spec-02-16.data new file mode 100644 index 0000000..9f66d88 --- /dev/null +++ b/test/data/spec-02-16.data @@ -0,0 +1,7 @@ +name: Mark McGwire +accomplishment: > + Mark set a major league + home run record in 1998. +stats: | + 65 Home Runs + 0.278 Batting Average diff --git a/test/data/spec-02-16.structure b/test/data/spec-02-16.structure new file mode 100644 index 0000000..aba1ced --- /dev/null +++ b/test/data/spec-02-16.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-16.tokens b/test/data/spec-02-16.tokens new file mode 100644 index 0000000..e4e381b --- /dev/null +++ b/test/data/spec-02-16.tokens @@ -0,0 +1,5 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-17.data b/test/data/spec-02-17.data new file mode 100644 index 0000000..b2870c5 --- /dev/null +++ b/test/data/spec-02-17.data @@ -0,0 +1,7 @@ +unicode: "Sosa did fine.\u263A" +control: "\b1998\t1999\t2000\n" +hexesc: "\x13\x10 is \r\n" + +single: '"Howdy!" he cried.' +quoted: ' # not a ''comment''.' +tie-fighter: '|\-*-/|' diff --git a/test/data/spec-02-17.structure b/test/data/spec-02-17.structure new file mode 100644 index 0000000..933646d --- /dev/null +++ b/test/data/spec-02-17.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True), (True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-17.tokens b/test/data/spec-02-17.tokens new file mode 100644 index 0000000..db65540 --- /dev/null +++ b/test/data/spec-02-17.tokens @@ -0,0 +1,8 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-18.data b/test/data/spec-02-18.data new file mode 100644 index 0000000..e0a8bfa --- /dev/null +++ b/test/data/spec-02-18.data @@ -0,0 +1,6 @@ +plain: + This unquoted scalar + spans many lines. + +quoted: "So does this + quoted scalar.\n" diff --git a/test/data/spec-02-18.structure b/test/data/spec-02-18.structure new file mode 100644 index 0000000..0ca4991 --- /dev/null +++ b/test/data/spec-02-18.structure @@ -0,0 +1 @@ +[(True, True), (True, True)] diff --git a/test/data/spec-02-18.tokens b/test/data/spec-02-18.tokens new file mode 100644 index 0000000..83b31dc --- /dev/null +++ b/test/data/spec-02-18.tokens @@ -0,0 +1,4 @@ +{{ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-19.data b/test/data/spec-02-19.data new file mode 100644 index 0000000..bf69de6 --- /dev/null +++ b/test/data/spec-02-19.data @@ -0,0 +1,5 @@ +canonical: 12345 +decimal: +12,345 +sexagesimal: 3:25:45 +octal: 014 +hexadecimal: 0xC diff --git a/test/data/spec-02-19.structure b/test/data/spec-02-19.structure new file mode 100644 index 0000000..48ca99d --- /dev/null +++ b/test/data/spec-02-19.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-19.tokens b/test/data/spec-02-19.tokens new file mode 100644 index 0000000..5bda68f --- /dev/null +++ b/test/data/spec-02-19.tokens @@ -0,0 +1,7 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-20.data b/test/data/spec-02-20.data new file mode 100644 index 0000000..1d4897f --- /dev/null +++ b/test/data/spec-02-20.data @@ -0,0 +1,6 @@ +canonical: 1.23015e+3 +exponential: 12.3015e+02 +sexagesimal: 20:30.15 +fixed: 1,230.15 +negative infinity: -.inf +not a number: .NaN diff --git a/test/data/spec-02-20.structure b/test/data/spec-02-20.structure new file mode 100644 index 0000000..933646d --- /dev/null +++ b/test/data/spec-02-20.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True), (True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-20.tokens b/test/data/spec-02-20.tokens new file mode 100644 index 0000000..db65540 --- /dev/null +++ b/test/data/spec-02-20.tokens @@ -0,0 +1,8 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-21.data b/test/data/spec-02-21.data new file mode 100644 index 0000000..dec6a56 --- /dev/null +++ b/test/data/spec-02-21.data @@ -0,0 +1,4 @@ +null: ~ +true: y +false: n +string: '12345' diff --git a/test/data/spec-02-21.structure b/test/data/spec-02-21.structure new file mode 100644 index 0000000..021635f --- /dev/null +++ b/test/data/spec-02-21.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-21.tokens b/test/data/spec-02-21.tokens new file mode 100644 index 0000000..aeccbaf --- /dev/null +++ b/test/data/spec-02-21.tokens @@ -0,0 +1,6 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-22.data b/test/data/spec-02-22.data new file mode 100644 index 0000000..aaac185 --- /dev/null +++ b/test/data/spec-02-22.data @@ -0,0 +1,4 @@ +canonical: 2001-12-15T02:59:43.1Z +iso8601: 2001-12-14t21:59:43.10-05:00 +spaced: 2001-12-14 21:59:43.10 -5 +date: 2002-12-14 diff --git a/test/data/spec-02-22.structure b/test/data/spec-02-22.structure new file mode 100644 index 0000000..021635f --- /dev/null +++ b/test/data/spec-02-22.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-22.tokens b/test/data/spec-02-22.tokens new file mode 100644 index 0000000..aeccbaf --- /dev/null +++ b/test/data/spec-02-22.tokens @@ -0,0 +1,6 @@ +{{ +? _ : _ +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-23.data b/test/data/spec-02-23.data new file mode 100644 index 0000000..5dbd992 --- /dev/null +++ b/test/data/spec-02-23.data @@ -0,0 +1,13 @@ +--- +not-date: !!str 2002-04-28 + +picture: !!binary | + R0lGODlhDAAMAIQAAP//9/X + 17unp5WZmZgAAAOfn515eXv + Pz7Y6OjuDg4J+fn5OTk6enp + 56enmleECcgggoBADs= + +application specific tag: !something | + The semantics of the tag + above may be different for + different documents. diff --git a/test/data/spec-02-23.structure b/test/data/spec-02-23.structure new file mode 100644 index 0000000..aba1ced --- /dev/null +++ b/test/data/spec-02-23.structure @@ -0,0 +1 @@ +[(True, True), (True, True), (True, True)] diff --git a/test/data/spec-02-23.tokens b/test/data/spec-02-23.tokens new file mode 100644 index 0000000..9ac54aa --- /dev/null +++ b/test/data/spec-02-23.tokens @@ -0,0 +1,6 @@ +--- +{{ +? _ : ! _ +? _ : ! _ +? _ : ! _ +]} diff --git a/test/data/spec-02-24.data b/test/data/spec-02-24.data new file mode 100644 index 0000000..1180757 --- /dev/null +++ b/test/data/spec-02-24.data @@ -0,0 +1,14 @@ +%TAG ! tag:clarkevans.com,2002: +--- !shape + # Use the ! handle for presenting + # tag:clarkevans.com,2002:circle +- !circle + center: &ORIGIN {x: 73, y: 129} + radius: 7 +- !line + start: *ORIGIN + finish: { x: 89, y: 102 } +- !label + start: *ORIGIN + color: 0xFFEEBB + text: Pretty vector drawing. diff --git a/test/data/spec-02-24.structure b/test/data/spec-02-24.structure new file mode 100644 index 0000000..a800729 --- /dev/null +++ b/test/data/spec-02-24.structure @@ -0,0 +1,5 @@ +[ +[(True, [(True, True), (True, True)]), (True, True)], +[(True, '*'), (True, [(True, True), (True, True)])], +[(True, '*'), (True, True), (True, True)], +] diff --git a/test/data/spec-02-24.tokens b/test/data/spec-02-24.tokens new file mode 100644 index 0000000..039c385 --- /dev/null +++ b/test/data/spec-02-24.tokens @@ -0,0 +1,20 @@ +% +--- ! +[[ +, ! + {{ + ? _ : & { ? _ : _ , ? _ : _ } + ? _ : _ + ]} +, ! + {{ + ? _ : * + ? _ : { ? _ : _ , ? _ : _ } + ]} +, ! + {{ + ? _ : * + ? _ : _ + ? _ : _ + ]} +]} diff --git a/test/data/spec-02-25.data b/test/data/spec-02-25.data new file mode 100644 index 0000000..769ac31 --- /dev/null +++ b/test/data/spec-02-25.data @@ -0,0 +1,7 @@ +# sets are represented as a +# mapping where each key is +# associated with the empty string +--- !!set +? Mark McGwire +? Sammy Sosa +? Ken Griff diff --git a/test/data/spec-02-25.structure b/test/data/spec-02-25.structure new file mode 100644 index 0000000..0b40e61 --- /dev/null +++ b/test/data/spec-02-25.structure @@ -0,0 +1 @@ +[(True, None), (True, None), (True, None)] diff --git a/test/data/spec-02-25.tokens b/test/data/spec-02-25.tokens new file mode 100644 index 0000000..b700236 --- /dev/null +++ b/test/data/spec-02-25.tokens @@ -0,0 +1,6 @@ +--- ! +{{ +? _ +? _ +? _ +]} diff --git a/test/data/spec-02-26.data b/test/data/spec-02-26.data new file mode 100644 index 0000000..3143763 --- /dev/null +++ b/test/data/spec-02-26.data @@ -0,0 +1,7 @@ +# ordered maps are represented as +# a sequence of mappings, with +# each mapping having one key +--- !!omap +- Mark McGwire: 65 +- Sammy Sosa: 63 +- Ken Griffy: 58 diff --git a/test/data/spec-02-26.structure b/test/data/spec-02-26.structure new file mode 100644 index 0000000..cf429b9 --- /dev/null +++ b/test/data/spec-02-26.structure @@ -0,0 +1,5 @@ +[ +[(True, True)], +[(True, True)], +[(True, True)], +] diff --git a/test/data/spec-02-26.tokens b/test/data/spec-02-26.tokens new file mode 100644 index 0000000..7bee492 --- /dev/null +++ b/test/data/spec-02-26.tokens @@ -0,0 +1,6 @@ +--- ! +[[ +, {{ ? _ : _ ]} +, {{ ? _ : _ ]} +, {{ ? _ : _ ]} +]} diff --git a/test/data/spec-02-27.data b/test/data/spec-02-27.data new file mode 100644 index 0000000..4625739 --- /dev/null +++ b/test/data/spec-02-27.data @@ -0,0 +1,29 @@ +--- ! +invoice: 34843 +date : 2001-01-23 +bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 +ship-to: *id001 +product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 +tax : 251.42 +total: 4443.52 +comments: + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338. diff --git a/test/data/spec-02-27.structure b/test/data/spec-02-27.structure new file mode 100644 index 0000000..a2113b9 --- /dev/null +++ b/test/data/spec-02-27.structure @@ -0,0 +1,17 @@ +[ +(True, True), +(True, True), +(True, [ + (True, True), + (True, True), + (True, [(True, True), (True, True), (True, True), (True, True)]), + ]), +(True, '*'), +(True, [ + [(True, True), (True, True), (True, True), (True, True)], + [(True, True), (True, True), (True, True), (True, True)], + ]), +(True, True), +(True, True), +(True, True), +] diff --git a/test/data/spec-02-27.tokens b/test/data/spec-02-27.tokens new file mode 100644 index 0000000..2dc1c25 --- /dev/null +++ b/test/data/spec-02-27.tokens @@ -0,0 +1,20 @@ +--- ! +{{ +? _ : _ +? _ : _ +? _ : & + {{ + ? _ : _ + ? _ : _ + ? _ : {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} + ]} +? _ : * +? _ : + [[ + , {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} + , {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} + ]} +? _ : _ +? _ : _ +? _ : _ +]} diff --git a/test/data/spec-02-28.data b/test/data/spec-02-28.data new file mode 100644 index 0000000..a5c8dc8 --- /dev/null +++ b/test/data/spec-02-28.data @@ -0,0 +1,26 @@ +--- +Time: 2001-11-23 15:01:42 -5 +User: ed +Warning: + This is an error message + for the log file +--- +Time: 2001-11-23 15:02:31 -5 +User: ed +Warning: + A slightly different error + message. +--- +Date: 2001-11-23 15:03:17 -5 +User: ed +Fatal: + Unknown variable "bar" +Stack: + - file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") + - file: MoreClass.py + line: 58 + code: |- + foo = bar diff --git a/test/data/spec-02-28.structure b/test/data/spec-02-28.structure new file mode 100644 index 0000000..8ec0b56 --- /dev/null +++ b/test/data/spec-02-28.structure @@ -0,0 +1,10 @@ +[ +[(True, True), (True, True), (True, True)], +[(True, True), (True, True), (True, True)], +[(True, True), (True, True), (True, True), +(True, [ + [(True, True), (True, True), (True, True)], + [(True, True), (True, True), (True, True)], + ]), +] +] diff --git a/test/data/spec-02-28.tokens b/test/data/spec-02-28.tokens new file mode 100644 index 0000000..8d5e1bc --- /dev/null +++ b/test/data/spec-02-28.tokens @@ -0,0 +1,23 @@ +--- +{{ +? _ : _ +? _ : _ +? _ : _ +]} +--- +{{ +? _ : _ +? _ : _ +? _ : _ +]} +--- +{{ +? _ : _ +? _ : _ +? _ : _ +? _ : + [[ + , {{ ? _ : _ ? _ : _ ? _ : _ ]} + , {{ ? _ : _ ? _ : _ ? _ : _ ]} + ]} +]} diff --git a/test/data/spec-05-01-utf16be.data b/test/data/spec-05-01-utf16be.data new file mode 100644 index 0000000000000000000000000000000000000000..35250629082adcbcf3224ca03148eec3f599f222 GIT binary patch literal 34 lcmezOpFx>Hfx(#}pCK0rQyKCYN`U-)Af3Zd$)Lx;1pt))2QB~r literal 0 HcmV?d00001 diff --git a/test/data/spec-05-01-utf16be.empty b/test/data/spec-05-01-utf16be.empty new file mode 100644 index 0000000..bfffa8b --- /dev/null +++ b/test/data/spec-05-01-utf16be.empty @@ -0,0 +1,2 @@ +# This stream contains no +# documents, only comments. diff --git a/test/data/spec-05-01-utf16le.data b/test/data/spec-05-01-utf16le.data new file mode 100644 index 0000000000000000000000000000000000000000..0823f7494bea13b6e939fd3ee694374f532828b8 GIT binary patch literal 34 lcmezWPnki1!I>eSAr}Z!8S)rPfc$(Qox@PcpvS<)005dW2QB~r literal 0 HcmV?d00001 diff --git a/test/data/spec-05-01-utf16le.empty b/test/data/spec-05-01-utf16le.empty new file mode 100644 index 0000000..bfffa8b --- /dev/null +++ b/test/data/spec-05-01-utf16le.empty @@ -0,0 +1,2 @@ +# This stream contains no +# documents, only comments. diff --git a/test/data/spec-05-01-utf8.data b/test/data/spec-05-01-utf8.data new file mode 100644 index 0000000..780d25b --- /dev/null +++ b/test/data/spec-05-01-utf8.data @@ -0,0 +1 @@ +# Comment only. diff --git a/test/data/spec-05-01-utf8.empty b/test/data/spec-05-01-utf8.empty new file mode 100644 index 0000000..bfffa8b --- /dev/null +++ b/test/data/spec-05-01-utf8.empty @@ -0,0 +1,2 @@ +# This stream contains no +# documents, only comments. diff --git a/test/data/spec-05-02-utf16be.data b/test/data/spec-05-02-utf16be.data new file mode 100644 index 0000000000000000000000000000000000000000..5ebbb04e6552a9f86935d32920530fb5a1c0bd3b GIT binary patch literal 90 zcmZQjW>8@8WXNMEV@PDkVaQ}i0rE>3iWyRYbUs5GkaS}3XYgg<`uCp!q&5?%wiv7q bq#}`l3oM!fRGSRcmkZRF$56tc$G`;u#5E6= literal 0 HcmV?d00001 diff --git a/test/data/spec-05-02-utf16be.error b/test/data/spec-05-02-utf16be.error new file mode 100644 index 0000000..1df3616 --- /dev/null +++ b/test/data/spec-05-02-utf16be.error @@ -0,0 +1,3 @@ +ERROR: + A BOM must not appear + inside a document. diff --git a/test/data/spec-05-02-utf16le.data b/test/data/spec-05-02-utf16le.data new file mode 100644 index 0000000000000000000000000000000000000000..0cd90a2bd15bbc378bc6e99d60621ac9d55cf7a7 GIT binary patch literal 90 zcmW-YF%Ezr00VFK6(;OHg3W>O1|pb{C=8&_SBp!VUap3jmBLNnAQQDO8cAK*l@^a< Z;(d%(mfL=B7(sl{D0kEE)UVK4#6Qu_50(G` literal 0 HcmV?d00001 diff --git a/test/data/spec-05-02-utf16le.error b/test/data/spec-05-02-utf16le.error new file mode 100644 index 0000000..1df3616 --- /dev/null +++ b/test/data/spec-05-02-utf16le.error @@ -0,0 +1,3 @@ +ERROR: + A BOM must not appear + inside a document. diff --git a/test/data/spec-05-02-utf8.data b/test/data/spec-05-02-utf8.data new file mode 100644 index 0000000..fb74866 --- /dev/null +++ b/test/data/spec-05-02-utf8.data @@ -0,0 +1,3 @@ +# Invalid use of BOM +# inside a +# document. diff --git a/test/data/spec-05-02-utf8.error b/test/data/spec-05-02-utf8.error new file mode 100644 index 0000000..1df3616 --- /dev/null +++ b/test/data/spec-05-02-utf8.error @@ -0,0 +1,3 @@ +ERROR: + A BOM must not appear + inside a document. diff --git a/test/data/spec-05-03.canonical b/test/data/spec-05-03.canonical new file mode 100644 index 0000000..a143a73 --- /dev/null +++ b/test/data/spec-05-03.canonical @@ -0,0 +1,14 @@ +%YAML 1.1 +--- +!!map { + ? !!str "sequence" + : !!seq [ + !!str "one", !!str "two" + ], + ? !!str "mapping" + : !!map { + ? !!str "sky" : !!str "blue", +# ? !!str "sea" : !!str "green", + ? !!map { ? !!str "sea" : !!str "green" } : !!null "", + } +} diff --git a/test/data/spec-05-03.data b/test/data/spec-05-03.data new file mode 100644 index 0000000..4661f33 --- /dev/null +++ b/test/data/spec-05-03.data @@ -0,0 +1,7 @@ +sequence: +- one +- two +mapping: + ? sky + : blue + ? sea : green diff --git a/test/data/spec-05-04.canonical b/test/data/spec-05-04.canonical new file mode 100644 index 0000000..00c9723 --- /dev/null +++ b/test/data/spec-05-04.canonical @@ -0,0 +1,13 @@ +%YAML 1.1 +--- +!!map { + ? !!str "sequence" + : !!seq [ + !!str "one", !!str "two" + ], + ? !!str "mapping" + : !!map { + ? !!str "sky" : !!str "blue", + ? !!str "sea" : !!str "green", + } +} diff --git a/test/data/spec-05-04.data b/test/data/spec-05-04.data new file mode 100644 index 0000000..df33847 --- /dev/null +++ b/test/data/spec-05-04.data @@ -0,0 +1,2 @@ +sequence: [ one, two, ] +mapping: { sky: blue, sea: green } diff --git a/test/data/spec-05-05.data b/test/data/spec-05-05.data new file mode 100644 index 0000000..62524c0 --- /dev/null +++ b/test/data/spec-05-05.data @@ -0,0 +1 @@ +# Comment only. diff --git a/test/data/spec-05-05.empty b/test/data/spec-05-05.empty new file mode 100644 index 0000000..bfffa8b --- /dev/null +++ b/test/data/spec-05-05.empty @@ -0,0 +1,2 @@ +# This stream contains no +# documents, only comments. diff --git a/test/data/spec-05-06.canonical b/test/data/spec-05-06.canonical new file mode 100644 index 0000000..4f30c11 --- /dev/null +++ b/test/data/spec-05-06.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? !!str "anchored" + : &A1 !local "value", + ? !!str "alias" + : *A1, +} diff --git a/test/data/spec-05-06.data b/test/data/spec-05-06.data new file mode 100644 index 0000000..7a1f9b3 --- /dev/null +++ b/test/data/spec-05-06.data @@ -0,0 +1,2 @@ +anchored: !local &anchor value +alias: *anchor diff --git a/test/data/spec-05-06.test_loader_skip b/test/data/spec-05-06.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-05-07.canonical b/test/data/spec-05-07.canonical new file mode 100644 index 0000000..dc3732a --- /dev/null +++ b/test/data/spec-05-07.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? !!str "literal" + : !!str "text\n", + ? !!str "folded" + : !!str "text\n", +} diff --git a/test/data/spec-05-07.data b/test/data/spec-05-07.data new file mode 100644 index 0000000..97eb3a3 --- /dev/null +++ b/test/data/spec-05-07.data @@ -0,0 +1,4 @@ +literal: | + text +folded: > + text diff --git a/test/data/spec-05-08.canonical b/test/data/spec-05-08.canonical new file mode 100644 index 0000000..610bd68 --- /dev/null +++ b/test/data/spec-05-08.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? !!str "single" + : !!str "text", + ? !!str "double" + : !!str "text", +} diff --git a/test/data/spec-05-08.data b/test/data/spec-05-08.data new file mode 100644 index 0000000..04ebf69 --- /dev/null +++ b/test/data/spec-05-08.data @@ -0,0 +1,2 @@ +single: 'text' +double: "text" diff --git a/test/data/spec-05-09.canonical b/test/data/spec-05-09.canonical new file mode 100644 index 0000000..597e3de --- /dev/null +++ b/test/data/spec-05-09.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "text" diff --git a/test/data/spec-05-09.data b/test/data/spec-05-09.data new file mode 100644 index 0000000..a43431b --- /dev/null +++ b/test/data/spec-05-09.data @@ -0,0 +1,2 @@ +%YAML 1.1 +--- text diff --git a/test/data/spec-05-10.data b/test/data/spec-05-10.data new file mode 100644 index 0000000..a4caf91 --- /dev/null +++ b/test/data/spec-05-10.data @@ -0,0 +1,2 @@ +commercial-at: @text +grave-accent: `text diff --git a/test/data/spec-05-10.error b/test/data/spec-05-10.error new file mode 100644 index 0000000..46f776e --- /dev/null +++ b/test/data/spec-05-10.error @@ -0,0 +1,3 @@ +ERROR: + Reserved indicators can't + start a plain scalar. diff --git a/test/data/spec-05-11.canonical b/test/data/spec-05-11.canonical new file mode 100644 index 0000000..fc25bef --- /dev/null +++ b/test/data/spec-05-11.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- !!str +"Generic line break (no glyph)\n\ + Generic line break (glyphed)\n\ + Line separator\u2028\ + Paragraph separator\u2029" diff --git a/test/data/spec-05-11.data b/test/data/spec-05-11.data new file mode 100644 index 0000000..b448b75 --- /dev/null +++ b/test/data/spec-05-11.data @@ -0,0 +1,3 @@ +| + Generic line break (no glyph) + Generic line break (glyphed)… Line separator
 Paragraph separator
 \ No newline at end of file diff --git a/test/data/spec-05-12.data b/test/data/spec-05-12.data new file mode 100644 index 0000000..7c3ad7f --- /dev/null +++ b/test/data/spec-05-12.data @@ -0,0 +1,9 @@ +# Tabs do's and don'ts: +# comment: +quoted: "Quoted " +block: | + void main() { + printf("Hello, world!\n"); + } +elsewhere: # separation + indentation, in plain scalar diff --git a/test/data/spec-05-12.error b/test/data/spec-05-12.error new file mode 100644 index 0000000..8aad4c8 --- /dev/null +++ b/test/data/spec-05-12.error @@ -0,0 +1,8 @@ +ERROR: + Tabs may appear inside + comments and quoted or + block scalar content. + Tabs must not appear + elsewhere, such as + in indentation and + separation spaces. diff --git a/test/data/spec-05-13.canonical b/test/data/spec-05-13.canonical new file mode 100644 index 0000000..90c1c5c --- /dev/null +++ b/test/data/spec-05-13.canonical @@ -0,0 +1,5 @@ +%YAML 1.1 +--- !!str +"Text containing \ + both space and \ + tab characters" diff --git a/test/data/spec-05-13.data b/test/data/spec-05-13.data new file mode 100644 index 0000000..fce7951 --- /dev/null +++ b/test/data/spec-05-13.data @@ -0,0 +1,3 @@ + "Text containing + both space and + tab characters" diff --git a/test/data/spec-05-14.canonical b/test/data/spec-05-14.canonical new file mode 100644 index 0000000..4bff01c --- /dev/null +++ b/test/data/spec-05-14.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +"Fun with \x5C + \x22 \x07 \x08 \x1B \x0C + \x0A \x0D \x09 \x0B \x00 + \x20 \xA0 \x85 \u2028 \u2029 + A A A" diff --git a/test/data/spec-05-14.data b/test/data/spec-05-14.data new file mode 100644 index 0000000..d6e8ce4 --- /dev/null +++ b/test/data/spec-05-14.data @@ -0,0 +1,2 @@ +"Fun with \\ + \" \a \b \e \f \… \n \r \t \v \0 \
 \ \_ \N \L \P \
 \x41 \u0041 \U00000041" diff --git a/test/data/spec-05-15.data b/test/data/spec-05-15.data new file mode 100644 index 0000000..7bf12b6 --- /dev/null +++ b/test/data/spec-05-15.data @@ -0,0 +1,3 @@ +Bad escapes: + "\c + \xq-" diff --git a/test/data/spec-05-15.error b/test/data/spec-05-15.error new file mode 100644 index 0000000..71ffbd9 --- /dev/null +++ b/test/data/spec-05-15.error @@ -0,0 +1,3 @@ +ERROR: +- c is an invalid escaped character. +- q and - are invalid hex digits. diff --git a/test/data/spec-06-01.canonical b/test/data/spec-06-01.canonical new file mode 100644 index 0000000..f17ec92 --- /dev/null +++ b/test/data/spec-06-01.canonical @@ -0,0 +1,15 @@ +%YAML 1.1 +--- +!!map { + ? !!str "Not indented" + : !!map { + ? !!str "By one space" + : !!str "By four\n spaces\n", + ? !!str "Flow style" + : !!seq [ + !!str "By two", + !!str "Also by two", + !!str "Still by two", + ] + } +} diff --git a/test/data/spec-06-01.data b/test/data/spec-06-01.data new file mode 100644 index 0000000..6134ba1 --- /dev/null +++ b/test/data/spec-06-01.data @@ -0,0 +1,14 @@ + # Leading comment line spaces are + # neither content nor indentation. + +Not indented: + By one space: | + By four + spaces + Flow style: [ # Leading spaces + By two, # in flow style + Also by two, # are neither +# Tabs are not allowed: +# Still by two # content nor + Still by two # content nor + ] # indentation. diff --git a/test/data/spec-06-02.data b/test/data/spec-06-02.data new file mode 100644 index 0000000..ff741e5 --- /dev/null +++ b/test/data/spec-06-02.data @@ -0,0 +1,3 @@ + # Comment + + diff --git a/test/data/spec-06-02.empty b/test/data/spec-06-02.empty new file mode 100644 index 0000000..bfffa8b --- /dev/null +++ b/test/data/spec-06-02.empty @@ -0,0 +1,2 @@ +# This stream contains no +# documents, only comments. diff --git a/test/data/spec-06-03.canonical b/test/data/spec-06-03.canonical new file mode 100644 index 0000000..ec26902 --- /dev/null +++ b/test/data/spec-06-03.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!map { + ? !!str "key" + : !!str "value" +} diff --git a/test/data/spec-06-03.data b/test/data/spec-06-03.data new file mode 100644 index 0000000..9db0912 --- /dev/null +++ b/test/data/spec-06-03.data @@ -0,0 +1,2 @@ +key: # Comment + value diff --git a/test/data/spec-06-04.canonical b/test/data/spec-06-04.canonical new file mode 100644 index 0000000..ec26902 --- /dev/null +++ b/test/data/spec-06-04.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!map { + ? !!str "key" + : !!str "value" +} diff --git a/test/data/spec-06-04.data b/test/data/spec-06-04.data new file mode 100644 index 0000000..86308dd --- /dev/null +++ b/test/data/spec-06-04.data @@ -0,0 +1,4 @@ +key: # Comment + # lines + value + diff --git a/test/data/spec-06-05.canonical b/test/data/spec-06-05.canonical new file mode 100644 index 0000000..8da431d --- /dev/null +++ b/test/data/spec-06-05.canonical @@ -0,0 +1,16 @@ +%YAML 1.1 +--- +!!map { + ? !!map { + ? !!str "first" + : !!str "Sammy", + ? !!str "last" + : !!str "Sosa" + } + : !!map { + ? !!str "hr" + : !!int "65", + ? !!str "avg" + : !!float "0.278" + } +} diff --git a/test/data/spec-06-05.data b/test/data/spec-06-05.data new file mode 100644 index 0000000..37613f5 --- /dev/null +++ b/test/data/spec-06-05.data @@ -0,0 +1,6 @@ +{ first: Sammy, last: Sosa }: +# Statistics: + hr: # Home runs + 65 + avg: # Average + 0.278 diff --git a/test/data/spec-06-06.canonical b/test/data/spec-06-06.canonical new file mode 100644 index 0000000..513d07a --- /dev/null +++ b/test/data/spec-06-06.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!map { + ? !!str "plain" + : !!str "text lines", + ? !!str "quoted" + : !!str "text lines", + ? !!str "block" + : !!str "text\n lines\n" +} diff --git a/test/data/spec-06-06.data b/test/data/spec-06-06.data new file mode 100644 index 0000000..2f62d08 --- /dev/null +++ b/test/data/spec-06-06.data @@ -0,0 +1,7 @@ +plain: text + lines +quoted: "text + lines" +block: | + text + lines diff --git a/test/data/spec-06-07.canonical b/test/data/spec-06-07.canonical new file mode 100644 index 0000000..11357e4 --- /dev/null +++ b/test/data/spec-06-07.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!seq [ + !!str "foo\nbar", + !!str "foo\n\nbar" +] diff --git a/test/data/spec-06-07.data b/test/data/spec-06-07.data new file mode 100644 index 0000000..130cfa7 --- /dev/null +++ b/test/data/spec-06-07.data @@ -0,0 +1,8 @@ +- foo + + bar +- |- + foo + + bar + diff --git a/test/data/spec-06-08.canonical b/test/data/spec-06-08.canonical new file mode 100644 index 0000000..cc72bc8 --- /dev/null +++ b/test/data/spec-06-08.canonical @@ -0,0 +1,5 @@ +%YAML 1.1 +--- !!str +"specific\L\ + trimmed\n\n\n\ + as space" diff --git a/test/data/spec-06-08.data b/test/data/spec-06-08.data new file mode 100644 index 0000000..f2896ed --- /dev/null +++ b/test/data/spec-06-08.data @@ -0,0 +1,2 @@ +>- + specific
 trimmed… … …… as… space diff --git a/test/data/spec-07-01.canonical b/test/data/spec-07-01.canonical new file mode 100644 index 0000000..8c8c48d --- /dev/null +++ b/test/data/spec-07-01.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- !!str +"foo" diff --git a/test/data/spec-07-01.data b/test/data/spec-07-01.data new file mode 100644 index 0000000..2113eb6 --- /dev/null +++ b/test/data/spec-07-01.data @@ -0,0 +1,3 @@ +%FOO bar baz # Should be ignored + # with a warning. +--- "foo" diff --git a/test/data/spec-07-01.skip-ext b/test/data/spec-07-01.skip-ext new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-07-02.canonical b/test/data/spec-07-02.canonical new file mode 100644 index 0000000..cb7dd1c --- /dev/null +++ b/test/data/spec-07-02.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "foo" diff --git a/test/data/spec-07-02.data b/test/data/spec-07-02.data new file mode 100644 index 0000000..c8b7322 --- /dev/null +++ b/test/data/spec-07-02.data @@ -0,0 +1,4 @@ +%YAML 1.2 # Attempt parsing + # with a warning +--- +"foo" diff --git a/test/data/spec-07-02.skip-ext b/test/data/spec-07-02.skip-ext new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-07-03.data b/test/data/spec-07-03.data new file mode 100644 index 0000000..4bfa07a --- /dev/null +++ b/test/data/spec-07-03.data @@ -0,0 +1,3 @@ +%YAML 1.1 +%YAML 1.1 +foo diff --git a/test/data/spec-07-03.error b/test/data/spec-07-03.error new file mode 100644 index 0000000..b0ac446 --- /dev/null +++ b/test/data/spec-07-03.error @@ -0,0 +1,3 @@ +ERROR: +The YAML directive must only be +given at most once per document. diff --git a/test/data/spec-07-04.canonical b/test/data/spec-07-04.canonical new file mode 100644 index 0000000..cb7dd1c --- /dev/null +++ b/test/data/spec-07-04.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "foo" diff --git a/test/data/spec-07-04.data b/test/data/spec-07-04.data new file mode 100644 index 0000000..50f5ab9 --- /dev/null +++ b/test/data/spec-07-04.data @@ -0,0 +1,3 @@ +%TAG !yaml! tag:yaml.org,2002: +--- +!yaml!str "foo" diff --git a/test/data/spec-07-05.data b/test/data/spec-07-05.data new file mode 100644 index 0000000..7276eae --- /dev/null +++ b/test/data/spec-07-05.data @@ -0,0 +1,3 @@ +%TAG ! !foo +%TAG ! !foo +bar diff --git a/test/data/spec-07-05.error b/test/data/spec-07-05.error new file mode 100644 index 0000000..5601b19 --- /dev/null +++ b/test/data/spec-07-05.error @@ -0,0 +1,4 @@ +ERROR: +The TAG directive must only +be given at most once per +handle in the same document. diff --git a/test/data/spec-07-06.canonical b/test/data/spec-07-06.canonical new file mode 100644 index 0000000..bddf616 --- /dev/null +++ b/test/data/spec-07-06.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!seq [ + ! "baz", + ! "string" +] diff --git a/test/data/spec-07-06.data b/test/data/spec-07-06.data new file mode 100644 index 0000000..d9854cb --- /dev/null +++ b/test/data/spec-07-06.data @@ -0,0 +1,5 @@ +%TAG ! !foo +%TAG !yaml! tag:yaml.org,2002: +--- +- !bar "baz" +- !yaml!str "string" diff --git a/test/data/spec-07-06.test_loader_skip b/test/data/spec-07-06.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-07-07a.canonical b/test/data/spec-07-07a.canonical new file mode 100644 index 0000000..fa086df --- /dev/null +++ b/test/data/spec-07-07a.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +! "bar" diff --git a/test/data/spec-07-07a.data b/test/data/spec-07-07a.data new file mode 100644 index 0000000..9d42ec3 --- /dev/null +++ b/test/data/spec-07-07a.data @@ -0,0 +1,2 @@ +# Private application: +!foo "bar" diff --git a/test/data/spec-07-07a.test_loader_skip b/test/data/spec-07-07a.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-07-07b.canonical b/test/data/spec-07-07b.canonical new file mode 100644 index 0000000..fe917d8 --- /dev/null +++ b/test/data/spec-07-07b.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +! "bar" diff --git a/test/data/spec-07-07b.data b/test/data/spec-07-07b.data new file mode 100644 index 0000000..2d36d0e --- /dev/null +++ b/test/data/spec-07-07b.data @@ -0,0 +1,4 @@ +# Migrated to global: +%TAG ! tag:ben-kiki.org,2000:app/ +--- +!foo "bar" diff --git a/test/data/spec-07-07b.test_loader_skip b/test/data/spec-07-07b.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-07-08.canonical b/test/data/spec-07-08.canonical new file mode 100644 index 0000000..703aa7b --- /dev/null +++ b/test/data/spec-07-08.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!seq [ + ! "bar", + ! "string", + ! "baz" +] diff --git a/test/data/spec-07-08.data b/test/data/spec-07-08.data new file mode 100644 index 0000000..e2c6d9e --- /dev/null +++ b/test/data/spec-07-08.data @@ -0,0 +1,9 @@ +# Explicitly specify default settings: +%TAG ! ! +%TAG !! tag:yaml.org,2002: +# Named handles have no default: +%TAG !o! tag:ben-kiki.org,2000: +--- +- !foo "bar" +- !!str "string" +- !o!type "baz" diff --git a/test/data/spec-07-08.test_loader_skip b/test/data/spec-07-08.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-07-09.canonical b/test/data/spec-07-09.canonical new file mode 100644 index 0000000..32d9e94 --- /dev/null +++ b/test/data/spec-07-09.canonical @@ -0,0 +1,9 @@ +%YAML 1.1 +--- +!!str "foo" +%YAML 1.1 +--- +!!str "bar" +%YAML 1.1 +--- +!!str "baz" diff --git a/test/data/spec-07-09.data b/test/data/spec-07-09.data new file mode 100644 index 0000000..1209d47 --- /dev/null +++ b/test/data/spec-07-09.data @@ -0,0 +1,11 @@ +--- +foo +... +# Repeated end marker. +... +--- +bar +# No end marker. +--- +baz +... diff --git a/test/data/spec-07-10.canonical b/test/data/spec-07-10.canonical new file mode 100644 index 0000000..1db650a --- /dev/null +++ b/test/data/spec-07-10.canonical @@ -0,0 +1,15 @@ +%YAML 1.1 +--- +!!str "Root flow scalar" +%YAML 1.1 +--- +!!str "Root block scalar\n" +%YAML 1.1 +--- +!!map { + ? !!str "foo" + : !!str "bar" +} +--- +#!!str "" +!!null "" diff --git a/test/data/spec-07-10.data b/test/data/spec-07-10.data new file mode 100644 index 0000000..6939b39 --- /dev/null +++ b/test/data/spec-07-10.data @@ -0,0 +1,11 @@ +"Root flow + scalar" +--- !!str > + Root block + scalar +--- +# Root collection: +foo : bar +... # Is optional. +--- +# Explicit document may be empty. diff --git a/test/data/spec-07-11.data b/test/data/spec-07-11.data new file mode 100644 index 0000000..d11302d --- /dev/null +++ b/test/data/spec-07-11.data @@ -0,0 +1,2 @@ +# A stream may contain +# no documents. diff --git a/test/data/spec-07-11.empty b/test/data/spec-07-11.empty new file mode 100644 index 0000000..bfffa8b --- /dev/null +++ b/test/data/spec-07-11.empty @@ -0,0 +1,2 @@ +# This stream contains no +# documents, only comments. diff --git a/test/data/spec-07-12a.canonical b/test/data/spec-07-12a.canonical new file mode 100644 index 0000000..efc116f --- /dev/null +++ b/test/data/spec-07-12a.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!map { + ? !!str "foo" + : !!str "bar" +} diff --git a/test/data/spec-07-12a.data b/test/data/spec-07-12a.data new file mode 100644 index 0000000..3807d57 --- /dev/null +++ b/test/data/spec-07-12a.data @@ -0,0 +1,3 @@ +# Implicit document. Root +# collection (mapping) node. +foo : bar diff --git a/test/data/spec-07-12b.canonical b/test/data/spec-07-12b.canonical new file mode 100644 index 0000000..04bcffc --- /dev/null +++ b/test/data/spec-07-12b.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "Text content\n" diff --git a/test/data/spec-07-12b.data b/test/data/spec-07-12b.data new file mode 100644 index 0000000..43250db --- /dev/null +++ b/test/data/spec-07-12b.data @@ -0,0 +1,4 @@ +# Explicit document. Root +# scalar (literal) node. +--- | + Text content diff --git a/test/data/spec-07-13.canonical b/test/data/spec-07-13.canonical new file mode 100644 index 0000000..5af71e9 --- /dev/null +++ b/test/data/spec-07-13.canonical @@ -0,0 +1,9 @@ +%YAML 1.1 +--- +!!str "First document" +--- +! "No directives" +--- +! "With directives" +--- +! "Reset settings" diff --git a/test/data/spec-07-13.data b/test/data/spec-07-13.data new file mode 100644 index 0000000..ba7ec63 --- /dev/null +++ b/test/data/spec-07-13.data @@ -0,0 +1,9 @@ +! "First document" +--- +!foo "No directives" +%TAG ! !foo +--- +!bar "With directives" +%YAML 1.1 +--- +!baz "Reset settings" diff --git a/test/data/spec-07-13.test_loader_skip b/test/data/spec-07-13.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-08-01.canonical b/test/data/spec-08-01.canonical new file mode 100644 index 0000000..69e4161 --- /dev/null +++ b/test/data/spec-08-01.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? &A1 !!str "foo" + : !!str "bar", + ? &A2 !!str "baz" + : *A1 +} diff --git a/test/data/spec-08-01.data b/test/data/spec-08-01.data new file mode 100644 index 0000000..48986ec --- /dev/null +++ b/test/data/spec-08-01.data @@ -0,0 +1,2 @@ +!!str &a1 "foo" : !!str bar +&a2 baz : *a1 diff --git a/test/data/spec-08-02.canonical b/test/data/spec-08-02.canonical new file mode 100644 index 0000000..dd6f76e --- /dev/null +++ b/test/data/spec-08-02.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? !!str "First occurrence" + : &A !!str "Value", + ? !!str "Second occurrence" + : *A +} diff --git a/test/data/spec-08-02.data b/test/data/spec-08-02.data new file mode 100644 index 0000000..600d179 --- /dev/null +++ b/test/data/spec-08-02.data @@ -0,0 +1,2 @@ +First occurrence: &anchor Value +Second occurrence: *anchor diff --git a/test/data/spec-08-03.canonical b/test/data/spec-08-03.canonical new file mode 100644 index 0000000..be7ea8f --- /dev/null +++ b/test/data/spec-08-03.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!map { + ? ! "foo" + : ! "baz" +} diff --git a/test/data/spec-08-03.data b/test/data/spec-08-03.data new file mode 100644 index 0000000..8e51f52 --- /dev/null +++ b/test/data/spec-08-03.data @@ -0,0 +1,2 @@ +! foo : + ! baz diff --git a/test/data/spec-08-03.test_loader_skip b/test/data/spec-08-03.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-08-04.data b/test/data/spec-08-04.data new file mode 100644 index 0000000..f7d1b01 --- /dev/null +++ b/test/data/spec-08-04.data @@ -0,0 +1,2 @@ +- ! foo +- !<$:?> bar diff --git a/test/data/spec-08-04.error b/test/data/spec-08-04.error new file mode 100644 index 0000000..6066375 --- /dev/null +++ b/test/data/spec-08-04.error @@ -0,0 +1,6 @@ +ERROR: +- Verbatim tags aren't resolved, + so ! is invalid. +- The $:? tag is neither a global + URI tag nor a local tag starting + with “!”. diff --git a/test/data/spec-08-05.canonical b/test/data/spec-08-05.canonical new file mode 100644 index 0000000..a5c710a --- /dev/null +++ b/test/data/spec-08-05.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!seq [ + ! "foo", + ! "bar", + ! "baz", +] diff --git a/test/data/spec-08-05.data b/test/data/spec-08-05.data new file mode 100644 index 0000000..93576ed --- /dev/null +++ b/test/data/spec-08-05.data @@ -0,0 +1,5 @@ +%TAG !o! tag:ben-kiki.org,2000: +--- +- !local foo +- !!str bar +- !o!type baz diff --git a/test/data/spec-08-05.test_loader_skip b/test/data/spec-08-05.test_loader_skip new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-08-06.data b/test/data/spec-08-06.data new file mode 100644 index 0000000..8580010 --- /dev/null +++ b/test/data/spec-08-06.data @@ -0,0 +1,5 @@ +%TAG !o! tag:ben-kiki.org,2000: +--- +- !$a!b foo +- !o! bar +- !h!type baz diff --git a/test/data/spec-08-06.error b/test/data/spec-08-06.error new file mode 100644 index 0000000..fb76f42 --- /dev/null +++ b/test/data/spec-08-06.error @@ -0,0 +1,4 @@ +ERROR: +- The !$a! looks like a handle. +- The !o! handle has no suffix. +- The !h! handle wasn't declared. diff --git a/test/data/spec-08-07.canonical b/test/data/spec-08-07.canonical new file mode 100644 index 0000000..e2f43d9 --- /dev/null +++ b/test/data/spec-08-07.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!seq [ + ! "12", + ! "12", +# ! "12", + ! "12", +] diff --git a/test/data/spec-08-07.data b/test/data/spec-08-07.data new file mode 100644 index 0000000..98aa565 --- /dev/null +++ b/test/data/spec-08-07.data @@ -0,0 +1,4 @@ +# Assuming conventional resolution: +- "12" +- 12 +- ! 12 diff --git a/test/data/spec-08-08.canonical b/test/data/spec-08-08.canonical new file mode 100644 index 0000000..d3f8b1a --- /dev/null +++ b/test/data/spec-08-08.canonical @@ -0,0 +1,15 @@ +%YAML 1.1 +--- +!!map { + ? !!str "foo" + : !!str "bar baz" +} +%YAML 1.1 +--- +!!str "foo bar" +%YAML 1.1 +--- +!!str "foo bar" +%YAML 1.1 +--- +!!str "foo\n" diff --git a/test/data/spec-08-08.data b/test/data/spec-08-08.data new file mode 100644 index 0000000..757a93d --- /dev/null +++ b/test/data/spec-08-08.data @@ -0,0 +1,13 @@ +--- +foo: + "bar + baz" +--- +"foo + bar" +--- +foo + bar +--- | + foo +... diff --git a/test/data/spec-08-09.canonical b/test/data/spec-08-09.canonical new file mode 100644 index 0000000..3805daf --- /dev/null +++ b/test/data/spec-08-09.canonical @@ -0,0 +1,21 @@ +%YAML 1.1 +--- !!map { + ? !!str "scalars" : !!map { + ? !!str "plain" + : !!str "some text", + ? !!str "quoted" + : !!map { + ? !!str "single" + : !!str "some text", + ? !!str "double" + : !!str "some text" + } }, + ? !!str "collections" : !!map { + ? !!str "sequence" : !!seq [ + !!str "entry", + !!map { + ? !!str "key" : !!str "value" + } ], + ? !!str "mapping" : !!map { + ? !!str "key" : !!str "value" +} } } diff --git a/test/data/spec-08-09.data b/test/data/spec-08-09.data new file mode 100644 index 0000000..69da042 --- /dev/null +++ b/test/data/spec-08-09.data @@ -0,0 +1,11 @@ +--- +scalars: + plain: !!str some text + quoted: + single: 'some text' + double: "some text" +collections: + sequence: !!seq [ !!str entry, + # Mapping entry: + key: value ] + mapping: { key: value } diff --git a/test/data/spec-08-10.canonical b/test/data/spec-08-10.canonical new file mode 100644 index 0000000..8281c5e --- /dev/null +++ b/test/data/spec-08-10.canonical @@ -0,0 +1,23 @@ +%YAML 1.1 +--- +!!map { + ? !!str "block styles" : !!map { + ? !!str "scalars" : !!map { + ? !!str "literal" + : !!str "#!/usr/bin/perl\n\ + print \"Hello, + world!\\n\";\n", + ? !!str "folded" + : !!str "This sentence + is false.\n" + }, + ? !!str "collections" : !!map { + ? !!str "sequence" : !!seq [ + !!str "entry", + !!map { + ? !!str "key" : !!str "value" + } + ], + ? !!str "mapping" : !!map { + ? !!str "key" : !!str "value" +} } } } diff --git a/test/data/spec-08-10.data b/test/data/spec-08-10.data new file mode 100644 index 0000000..72acc56 --- /dev/null +++ b/test/data/spec-08-10.data @@ -0,0 +1,15 @@ +block styles: + scalars: + literal: !!str | + #!/usr/bin/perl + print "Hello, world!\n"; + folded: > + This sentence + is false. + collections: !!map + sequence: !!seq # Entry: + - entry # Plain + # Mapping entry: + - key: value + mapping: + key: value diff --git a/test/data/spec-08-11.canonical b/test/data/spec-08-11.canonical new file mode 100644 index 0000000..dd6f76e --- /dev/null +++ b/test/data/spec-08-11.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? !!str "First occurrence" + : &A !!str "Value", + ? !!str "Second occurrence" + : *A +} diff --git a/test/data/spec-08-11.data b/test/data/spec-08-11.data new file mode 100644 index 0000000..600d179 --- /dev/null +++ b/test/data/spec-08-11.data @@ -0,0 +1,2 @@ +First occurrence: &anchor Value +Second occurrence: *anchor diff --git a/test/data/spec-08-12.canonical b/test/data/spec-08-12.canonical new file mode 100644 index 0000000..93899f4 --- /dev/null +++ b/test/data/spec-08-12.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!seq [ + !!str "Without properties", + &A !!str "Anchored", + !!str "Tagged", + *A, + !!str "", + !!str "", +] diff --git a/test/data/spec-08-12.data b/test/data/spec-08-12.data new file mode 100644 index 0000000..3d4c6b7 --- /dev/null +++ b/test/data/spec-08-12.data @@ -0,0 +1,8 @@ +[ + Without properties, + &anchor "Anchored", + !!str 'Tagged', + *anchor, # Alias node + !!str , # Empty plain scalar + '', # Empty plain scalar +] diff --git a/test/data/spec-08-13.canonical b/test/data/spec-08-13.canonical new file mode 100644 index 0000000..618bb7b --- /dev/null +++ b/test/data/spec-08-13.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!map { + ? !!str "foo" +# : !!str "", +# ? !!str "" + : !!null "", + ? !!null "" + : !!str "bar", +} diff --git a/test/data/spec-08-13.data b/test/data/spec-08-13.data new file mode 100644 index 0000000..ebe663a --- /dev/null +++ b/test/data/spec-08-13.data @@ -0,0 +1,4 @@ +{ + ? foo :, + ? : bar, +} diff --git a/test/data/spec-08-13.skip-ext b/test/data/spec-08-13.skip-ext new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-08-14.canonical b/test/data/spec-08-14.canonical new file mode 100644 index 0000000..11db439 --- /dev/null +++ b/test/data/spec-08-14.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!seq [ + !!str "flow in block", + !!str "Block scalar\n", + !!map { + ? !!str "foo" + : !!str "bar" + } +] diff --git a/test/data/spec-08-14.data b/test/data/spec-08-14.data new file mode 100644 index 0000000..2fbb1f7 --- /dev/null +++ b/test/data/spec-08-14.data @@ -0,0 +1,5 @@ +- "flow in block" +- > + Block scalar +- !!map # Block collection + foo : bar diff --git a/test/data/spec-08-15.canonical b/test/data/spec-08-15.canonical new file mode 100644 index 0000000..76f028e --- /dev/null +++ b/test/data/spec-08-15.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!seq [ + !!null "", + !!map { + ? !!str "foo" + : !!null "", + ? !!null "" + : !!str "bar", + } +] diff --git a/test/data/spec-08-15.data b/test/data/spec-08-15.data new file mode 100644 index 0000000..7c86bcf --- /dev/null +++ b/test/data/spec-08-15.data @@ -0,0 +1,5 @@ +- # Empty plain scalar +- ? foo + : + ? + : bar diff --git a/test/data/spec-09-01.canonical b/test/data/spec-09-01.canonical new file mode 100644 index 0000000..e71a548 --- /dev/null +++ b/test/data/spec-09-01.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!map { + ? !!str "simple key" + : !!map { + ? !!str "also simple" + : !!str "value", + ? !!str "not a simple key" + : !!str "any value" + } +} diff --git a/test/data/spec-09-01.data b/test/data/spec-09-01.data new file mode 100644 index 0000000..9e83eaf --- /dev/null +++ b/test/data/spec-09-01.data @@ -0,0 +1,6 @@ +"simple key" : { + "also simple" : value, + ? "not a + simple key" : "any + value" +} diff --git a/test/data/spec-09-02.canonical b/test/data/spec-09-02.canonical new file mode 100644 index 0000000..6f8f41a --- /dev/null +++ b/test/data/spec-09-02.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!str "as space \ + trimmed\n\ + specific\L\n\ + escaped\t\n\ + none" diff --git a/test/data/spec-09-02.data b/test/data/spec-09-02.data new file mode 100644 index 0000000..d84883d --- /dev/null +++ b/test/data/spec-09-02.data @@ -0,0 +1,6 @@ + "as space + trimmed + + specific
 + escaped \
 + none" diff --git a/test/data/spec-09-03.canonical b/test/data/spec-09-03.canonical new file mode 100644 index 0000000..658c6df --- /dev/null +++ b/test/data/spec-09-03.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!seq [ + !!str " last", + !!str " last", + !!str " \tfirst last", +] diff --git a/test/data/spec-09-03.data b/test/data/spec-09-03.data new file mode 100644 index 0000000..e0b914d --- /dev/null +++ b/test/data/spec-09-03.data @@ -0,0 +1,6 @@ +- " + last" +- " + last" +- " first + last" diff --git a/test/data/spec-09-04.canonical b/test/data/spec-09-04.canonical new file mode 100644 index 0000000..fa46632 --- /dev/null +++ b/test/data/spec-09-04.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!str "first \ + inner 1 \ + inner 2 \ + last" diff --git a/test/data/spec-09-04.data b/test/data/spec-09-04.data new file mode 100644 index 0000000..313a91b --- /dev/null +++ b/test/data/spec-09-04.data @@ -0,0 +1,4 @@ + "first + inner 1 + \ inner 2 \ + last" diff --git a/test/data/spec-09-05.canonical b/test/data/spec-09-05.canonical new file mode 100644 index 0000000..24d1052 --- /dev/null +++ b/test/data/spec-09-05.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!seq [ + !!str "first ", + !!str "first\nlast", + !!str "first inner \tlast", +] diff --git a/test/data/spec-09-05.data b/test/data/spec-09-05.data new file mode 100644 index 0000000..624c30e --- /dev/null +++ b/test/data/spec-09-05.data @@ -0,0 +1,8 @@ +- "first + " +- "first + + last" +- "first + inner + \ last" diff --git a/test/data/spec-09-06.canonical b/test/data/spec-09-06.canonical new file mode 100644 index 0000000..5028772 --- /dev/null +++ b/test/data/spec-09-06.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "here's to \"quotes\"" diff --git a/test/data/spec-09-06.data b/test/data/spec-09-06.data new file mode 100644 index 0000000..b038078 --- /dev/null +++ b/test/data/spec-09-06.data @@ -0,0 +1 @@ + 'here''s to "quotes"' diff --git a/test/data/spec-09-07.canonical b/test/data/spec-09-07.canonical new file mode 100644 index 0000000..e71a548 --- /dev/null +++ b/test/data/spec-09-07.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!map { + ? !!str "simple key" + : !!map { + ? !!str "also simple" + : !!str "value", + ? !!str "not a simple key" + : !!str "any value" + } +} diff --git a/test/data/spec-09-07.data b/test/data/spec-09-07.data new file mode 100644 index 0000000..755b54a --- /dev/null +++ b/test/data/spec-09-07.data @@ -0,0 +1,6 @@ +'simple key' : { + 'also simple' : value, + ? 'not a + simple key' : 'any + value' +} diff --git a/test/data/spec-09-08.canonical b/test/data/spec-09-08.canonical new file mode 100644 index 0000000..06abdb5 --- /dev/null +++ b/test/data/spec-09-08.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!str "as space \ + trimmed\n\ + specific\L\n\ + none" diff --git a/test/data/spec-09-08.data b/test/data/spec-09-08.data new file mode 100644 index 0000000..aa4d458 --- /dev/null +++ b/test/data/spec-09-08.data @@ -0,0 +1 @@ + 'as space … trimmed …… specific
… none' diff --git a/test/data/spec-09-09.canonical b/test/data/spec-09-09.canonical new file mode 100644 index 0000000..658c6df --- /dev/null +++ b/test/data/spec-09-09.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!seq [ + !!str " last", + !!str " last", + !!str " \tfirst last", +] diff --git a/test/data/spec-09-09.data b/test/data/spec-09-09.data new file mode 100644 index 0000000..52171df --- /dev/null +++ b/test/data/spec-09-09.data @@ -0,0 +1,6 @@ +- ' + last' +- ' + last' +- ' first + last' diff --git a/test/data/spec-09-10.canonical b/test/data/spec-09-10.canonical new file mode 100644 index 0000000..2028d04 --- /dev/null +++ b/test/data/spec-09-10.canonical @@ -0,0 +1,5 @@ +%YAML 1.1 +--- +!!str "first \ + inner \ + last" diff --git a/test/data/spec-09-10.data b/test/data/spec-09-10.data new file mode 100644 index 0000000..0e41449 --- /dev/null +++ b/test/data/spec-09-10.data @@ -0,0 +1,3 @@ + 'first + inner + last' diff --git a/test/data/spec-09-11.canonical b/test/data/spec-09-11.canonical new file mode 100644 index 0000000..4eb222c --- /dev/null +++ b/test/data/spec-09-11.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!seq [ + !!str "first ", + !!str "first\nlast", +] diff --git a/test/data/spec-09-11.data b/test/data/spec-09-11.data new file mode 100644 index 0000000..5efa873 --- /dev/null +++ b/test/data/spec-09-11.data @@ -0,0 +1,5 @@ +- 'first + ' +- 'first + + last' diff --git a/test/data/spec-09-12.canonical b/test/data/spec-09-12.canonical new file mode 100644 index 0000000..d8e6dce --- /dev/null +++ b/test/data/spec-09-12.canonical @@ -0,0 +1,12 @@ +%YAML 1.1 +--- +!!seq [ + !!str "::std::vector", + !!str "Up, up, and away!", + !!int "-123", + !!seq [ + !!str "::std::vector", + !!str "Up, up, and away!", + !!int "-123", + ] +] diff --git a/test/data/spec-09-12.data b/test/data/spec-09-12.data new file mode 100644 index 0000000..b9a3ac5 --- /dev/null +++ b/test/data/spec-09-12.data @@ -0,0 +1,8 @@ +# Outside flow collection: +- ::std::vector +- Up, up, and away! +- -123 +# Inside flow collection: +- [ '::std::vector', + "Up, up, and away!", + -123 ] diff --git a/test/data/spec-09-13.canonical b/test/data/spec-09-13.canonical new file mode 100644 index 0000000..e71a548 --- /dev/null +++ b/test/data/spec-09-13.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!map { + ? !!str "simple key" + : !!map { + ? !!str "also simple" + : !!str "value", + ? !!str "not a simple key" + : !!str "any value" + } +} diff --git a/test/data/spec-09-13.data b/test/data/spec-09-13.data new file mode 100644 index 0000000..b156386 --- /dev/null +++ b/test/data/spec-09-13.data @@ -0,0 +1,6 @@ +simple key : { + also simple : value, + ? not a + simple key : any + value +} diff --git a/test/data/spec-09-14.data b/test/data/spec-09-14.data new file mode 100644 index 0000000..97f2316 --- /dev/null +++ b/test/data/spec-09-14.data @@ -0,0 +1,14 @@ +--- +--- ||| : foo +... >>>: bar +--- +[ +--- +, +... , +{ +--- : +... # Nested +} +] +... diff --git a/test/data/spec-09-14.error b/test/data/spec-09-14.error new file mode 100644 index 0000000..9f3db7b --- /dev/null +++ b/test/data/spec-09-14.error @@ -0,0 +1,6 @@ +ERROR: + The --- and ... document + start and end markers must + not be specified as the + first content line of a + non-indented plain scalar. diff --git a/test/data/spec-09-15.canonical b/test/data/spec-09-15.canonical new file mode 100644 index 0000000..df02040 --- /dev/null +++ b/test/data/spec-09-15.canonical @@ -0,0 +1,18 @@ +%YAML 1.1 +--- +!!map { + ? !!str "---" + : !!str "foo", + ? !!str "..." + : !!str "bar" +} +%YAML 1.1 +--- +!!seq [ + !!str "---", + !!str "...", + !!map { + ? !!str "---" + : !!str "..." + } +] diff --git a/test/data/spec-09-15.data b/test/data/spec-09-15.data new file mode 100644 index 0000000..e6863b0 --- /dev/null +++ b/test/data/spec-09-15.data @@ -0,0 +1,13 @@ +--- +"---" : foo +...: bar +--- +[ +---, +..., +{ +? --- +: ... +} +] +... diff --git a/test/data/spec-09-16.canonical b/test/data/spec-09-16.canonical new file mode 100644 index 0000000..06abdb5 --- /dev/null +++ b/test/data/spec-09-16.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!str "as space \ + trimmed\n\ + specific\L\n\ + none" diff --git a/test/data/spec-09-16.data b/test/data/spec-09-16.data new file mode 100644 index 0000000..473beb9 --- /dev/null +++ b/test/data/spec-09-16.data @@ -0,0 +1,3 @@ +# Tabs are confusing: +# as space/trimmed/specific/none + as space … trimmed …… specific
… none diff --git a/test/data/spec-09-17.canonical b/test/data/spec-09-17.canonical new file mode 100644 index 0000000..68cb70d --- /dev/null +++ b/test/data/spec-09-17.canonical @@ -0,0 +1,4 @@ +%YAML 1.1 +--- +!!str "first line\n\ + more line" diff --git a/test/data/spec-09-17.data b/test/data/spec-09-17.data new file mode 100644 index 0000000..97bc46c --- /dev/null +++ b/test/data/spec-09-17.data @@ -0,0 +1,3 @@ + first line + + more line diff --git a/test/data/spec-09-18.canonical b/test/data/spec-09-18.canonical new file mode 100644 index 0000000..f21428f --- /dev/null +++ b/test/data/spec-09-18.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!seq [ + !!str "literal\n", + !!str " folded\n", + !!str "keep\n\n", + !!str " strip", +] diff --git a/test/data/spec-09-18.data b/test/data/spec-09-18.data new file mode 100644 index 0000000..68c5d7c --- /dev/null +++ b/test/data/spec-09-18.data @@ -0,0 +1,9 @@ +- | # Just the style + literal +- >1 # Indentation indicator + folded +- |+ # Chomping indicator + keep + +- >-1 # Both indicators + strip diff --git a/test/data/spec-09-19.canonical b/test/data/spec-09-19.canonical new file mode 100644 index 0000000..3e828d7 --- /dev/null +++ b/test/data/spec-09-19.canonical @@ -0,0 +1,6 @@ +%YAML 1.1 +--- +!!seq [ + !!str "literal\n", + !!str "folded\n", +] diff --git a/test/data/spec-09-19.data b/test/data/spec-09-19.data new file mode 100644 index 0000000..f0e589d --- /dev/null +++ b/test/data/spec-09-19.data @@ -0,0 +1,4 @@ +- | + literal +- > + folded diff --git a/test/data/spec-09-20.canonical b/test/data/spec-09-20.canonical new file mode 100644 index 0000000..d03bef5 --- /dev/null +++ b/test/data/spec-09-20.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!seq [ + !!str "detected\n", + !!str "\n\n# detected\n", + !!str " explicit\n", + !!str "\t\ndetected\n", +] diff --git a/test/data/spec-09-20.data b/test/data/spec-09-20.data new file mode 100644 index 0000000..39bee04 --- /dev/null +++ b/test/data/spec-09-20.data @@ -0,0 +1,11 @@ +- | + detected +- > + + + # detected +- |1 + explicit +- > + + detected diff --git a/test/data/spec-09-20.skip-ext b/test/data/spec-09-20.skip-ext new file mode 100644 index 0000000..e69de29 diff --git a/test/data/spec-09-21.data b/test/data/spec-09-21.data new file mode 100644 index 0000000..0fdd14f --- /dev/null +++ b/test/data/spec-09-21.data @@ -0,0 +1,8 @@ +- | + + text +- > + text + text +- |1 + text diff --git a/test/data/spec-09-21.error b/test/data/spec-09-21.error new file mode 100644 index 0000000..1379ca5 --- /dev/null +++ b/test/data/spec-09-21.error @@ -0,0 +1,7 @@ +ERROR: +- A leading all-space line must + not have too many spaces. +- A following text line must + not be less indented. +- The text is less indented + than the indicated level. diff --git a/test/data/spec-09-22.canonical b/test/data/spec-09-22.canonical new file mode 100644 index 0000000..c1bbcd2 --- /dev/null +++ b/test/data/spec-09-22.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!map { + ? !!str "strip" + : !!str "text", + ? !!str "clip" + : !!str "text\n", + ? !!str "keep" + : !!str "text\L", +} diff --git a/test/data/spec-09-22.data b/test/data/spec-09-22.data new file mode 100644 index 0000000..0dd51eb --- /dev/null +++ b/test/data/spec-09-22.data @@ -0,0 +1,4 @@ +strip: |- + text
clip: | + text…keep: |+ + text
 \ No newline at end of file diff --git a/test/data/spec-09-23.canonical b/test/data/spec-09-23.canonical new file mode 100644 index 0000000..c4444ca --- /dev/null +++ b/test/data/spec-09-23.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!map { + ? !!str "strip" + : !!str "# text", + ? !!str "clip" + : !!str "# text\n", + ? !!str "keep" + : !!str "# text\L\n", +} diff --git a/test/data/spec-09-23.data b/test/data/spec-09-23.data new file mode 100644 index 0000000..8972d2b --- /dev/null +++ b/test/data/spec-09-23.data @@ -0,0 +1,11 @@ + # Strip + # Comments: +strip: |- + # text
 
 # Clip + # comments: +…clip: | + # text… 
 # Keep + # comments: +…keep: |+ + # text
… # Trail + # comments. diff --git a/test/data/spec-09-24.canonical b/test/data/spec-09-24.canonical new file mode 100644 index 0000000..45a99b0 --- /dev/null +++ b/test/data/spec-09-24.canonical @@ -0,0 +1,10 @@ +%YAML 1.1 +--- +!!map { + ? !!str "strip" + : !!str "", + ? !!str "clip" + : !!str "", + ? !!str "keep" + : !!str "\n", +} diff --git a/test/data/spec-09-24.data b/test/data/spec-09-24.data new file mode 100644 index 0000000..de0b64b --- /dev/null +++ b/test/data/spec-09-24.data @@ -0,0 +1,6 @@ +strip: >- + +clip: > + +keep: |+ + diff --git a/test/data/spec-09-25.canonical b/test/data/spec-09-25.canonical new file mode 100644 index 0000000..9d2327b --- /dev/null +++ b/test/data/spec-09-25.canonical @@ -0,0 +1,4 @@ +%YAML 1.1 +--- +!!str "literal\n\ + \ttext\n" diff --git a/test/data/spec-09-25.data b/test/data/spec-09-25.data new file mode 100644 index 0000000..f6303a1 --- /dev/null +++ b/test/data/spec-09-25.data @@ -0,0 +1,3 @@ +| # Simple block scalar + literal + text diff --git a/test/data/spec-09-26.canonical b/test/data/spec-09-26.canonical new file mode 100644 index 0000000..3029a11 --- /dev/null +++ b/test/data/spec-09-26.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "\n\nliteral\n\ntext\n" diff --git a/test/data/spec-09-26.data b/test/data/spec-09-26.data new file mode 100644 index 0000000..f28555a --- /dev/null +++ b/test/data/spec-09-26.data @@ -0,0 +1,8 @@ +| + + + literal + + text + + # Comment diff --git a/test/data/spec-09-27.canonical b/test/data/spec-09-27.canonical new file mode 100644 index 0000000..3029a11 --- /dev/null +++ b/test/data/spec-09-27.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "\n\nliteral\n\ntext\n" diff --git a/test/data/spec-09-27.data b/test/data/spec-09-27.data new file mode 100644 index 0000000..f28555a --- /dev/null +++ b/test/data/spec-09-27.data @@ -0,0 +1,8 @@ +| + + + literal + + text + + # Comment diff --git a/test/data/spec-09-28.canonical b/test/data/spec-09-28.canonical new file mode 100644 index 0000000..3029a11 --- /dev/null +++ b/test/data/spec-09-28.canonical @@ -0,0 +1,3 @@ +%YAML 1.1 +--- +!!str "\n\nliteral\n\ntext\n" diff --git a/test/data/spec-09-28.data b/test/data/spec-09-28.data new file mode 100644 index 0000000..f28555a --- /dev/null +++ b/test/data/spec-09-28.data @@ -0,0 +1,8 @@ +| + + + literal + + text + + # Comment diff --git a/test/data/spec-09-29.canonical b/test/data/spec-09-29.canonical new file mode 100644 index 0000000..0980789 --- /dev/null +++ b/test/data/spec-09-29.canonical @@ -0,0 +1,4 @@ +%YAML 1.1 +--- +!!str "folded text\n\ + \tlines\n" diff --git a/test/data/spec-09-29.data b/test/data/spec-09-29.data new file mode 100644 index 0000000..82e611f --- /dev/null +++ b/test/data/spec-09-29.data @@ -0,0 +1,4 @@ +> # Simple folded scalar + folded + text + lines diff --git a/test/data/spec-09-30.canonical b/test/data/spec-09-30.canonical new file mode 100644 index 0000000..fc37db1 --- /dev/null +++ b/test/data/spec-09-30.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!str "folded line\n\ + next line\n\n\ + \ * bullet\n\ + \ * list\n\n\ + last line\n" diff --git a/test/data/spec-09-30.data b/test/data/spec-09-30.data new file mode 100644 index 0000000..a4d8c36 --- /dev/null +++ b/test/data/spec-09-30.data @@ -0,0 +1,14 @@ +> + folded + line + + next + line + + * bullet + * list + + last + line + +# Comment diff --git a/test/data/spec-09-31.canonical b/test/data/spec-09-31.canonical new file mode 100644 index 0000000..fc37db1 --- /dev/null +++ b/test/data/spec-09-31.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!str "folded line\n\ + next line\n\n\ + \ * bullet\n\ + \ * list\n\n\ + last line\n" diff --git a/test/data/spec-09-31.data b/test/data/spec-09-31.data new file mode 100644 index 0000000..a4d8c36 --- /dev/null +++ b/test/data/spec-09-31.data @@ -0,0 +1,14 @@ +> + folded + line + + next + line + + * bullet + * list + + last + line + +# Comment diff --git a/test/data/spec-09-32.canonical b/test/data/spec-09-32.canonical new file mode 100644 index 0000000..fc37db1 --- /dev/null +++ b/test/data/spec-09-32.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!str "folded line\n\ + next line\n\n\ + \ * bullet\n\ + \ * list\n\n\ + last line\n" diff --git a/test/data/spec-09-32.data b/test/data/spec-09-32.data new file mode 100644 index 0000000..a4d8c36 --- /dev/null +++ b/test/data/spec-09-32.data @@ -0,0 +1,14 @@ +> + folded + line + + next + line + + * bullet + * list + + last + line + +# Comment diff --git a/test/data/spec-09-33.canonical b/test/data/spec-09-33.canonical new file mode 100644 index 0000000..fc37db1 --- /dev/null +++ b/test/data/spec-09-33.canonical @@ -0,0 +1,7 @@ +%YAML 1.1 +--- +!!str "folded line\n\ + next line\n\n\ + \ * bullet\n\ + \ * list\n\n\ + last line\n" diff --git a/test/data/spec-09-33.data b/test/data/spec-09-33.data new file mode 100644 index 0000000..a4d8c36 --- /dev/null +++ b/test/data/spec-09-33.data @@ -0,0 +1,14 @@ +> + folded + line + + next + line + + * bullet + * list + + last + line + +# Comment diff --git a/test/data/spec-10-01.canonical b/test/data/spec-10-01.canonical new file mode 100644 index 0000000..d08cdd4 --- /dev/null +++ b/test/data/spec-10-01.canonical @@ -0,0 +1,12 @@ +%YAML 1.1 +--- +!!seq [ + !!seq [ + !!str "inner", + !!str "inner", + ], + !!seq [ + !!str "inner", + !!str "last", + ], +] diff --git a/test/data/spec-10-01.data b/test/data/spec-10-01.data new file mode 100644 index 0000000..e668d38 --- /dev/null +++ b/test/data/spec-10-01.data @@ -0,0 +1,2 @@ +- [ inner, inner, ] +- [inner,last] diff --git a/test/data/spec-10-02.canonical b/test/data/spec-10-02.canonical new file mode 100644 index 0000000..82fe0d9 --- /dev/null +++ b/test/data/spec-10-02.canonical @@ -0,0 +1,14 @@ +%YAML 1.1 +--- +!!seq [ + !!str "double quoted", + !!str "single quoted", + !!str "plain text", + !!seq [ + !!str "nested", + ], + !!map { + ? !!str "single" + : !!str "pair" + } +] diff --git a/test/data/spec-10-02.data b/test/data/spec-10-02.data new file mode 100644 index 0000000..3b23351 --- /dev/null +++ b/test/data/spec-10-02.data @@ -0,0 +1,8 @@ +[ +"double + quoted", 'single + quoted', +plain + text, [ nested ], +single: pair , +] diff --git a/test/data/spec-10-03.canonical b/test/data/spec-10-03.canonical new file mode 100644 index 0000000..1443395 --- /dev/null +++ b/test/data/spec-10-03.canonical @@ -0,0 +1,12 @@ +%YAML 1.1 +--- +!!map { + ? !!str "block" + : !!seq [ + !!str "one", + !!map { + ? !!str "two" + : !!str "three" + } + ] +} diff --git a/test/data/spec-10-03.data b/test/data/spec-10-03.data new file mode 100644 index 0000000..9e15f83 --- /dev/null +++ b/test/data/spec-10-03.data @@ -0,0 +1,4 @@ +block: # Block + # sequence +- one +- two : three diff --git a/test/data/spec-10-04.canonical b/test/data/spec-10-04.canonical new file mode 100644 index 0000000..ae486a3 --- /dev/null +++ b/test/data/spec-10-04.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!map { + ? !!str "block" + : !!seq [ + !!str "one", + !!seq [ + !!str "two" + ] + ] +} diff --git a/test/data/spec-10-04.data b/test/data/spec-10-04.data new file mode 100644 index 0000000..2905b0d --- /dev/null +++ b/test/data/spec-10-04.data @@ -0,0 +1,4 @@ +block: +- one +- + - two diff --git a/test/data/spec-10-05.canonical b/test/data/spec-10-05.canonical new file mode 100644 index 0000000..07cc0c9 --- /dev/null +++ b/test/data/spec-10-05.canonical @@ -0,0 +1,14 @@ +%YAML 1.1 +--- +!!seq [ + !!null "", + !!str "block node\n", + !!seq [ + !!str "one", + !!str "two", + ], + !!map { + ? !!str "one" + : !!str "two", + } +] diff --git a/test/data/spec-10-05.data b/test/data/spec-10-05.data new file mode 100644 index 0000000..f19a99e --- /dev/null +++ b/test/data/spec-10-05.data @@ -0,0 +1,7 @@ +- # Empty +- | + block node +- - one # in-line + - two # sequence +- one: two # in-line + # mapping diff --git a/test/data/spec-10-06.canonical b/test/data/spec-10-06.canonical new file mode 100644 index 0000000..d9986c2 --- /dev/null +++ b/test/data/spec-10-06.canonical @@ -0,0 +1,16 @@ +%YAML 1.1 +--- +!!seq [ + !!map { + ? !!str "inner" + : !!str "entry", + ? !!str "also" + : !!str "inner" + }, + !!map { + ? !!str "inner" + : !!str "entry", + ? !!str "last" + : !!str "entry" + } +] diff --git a/test/data/spec-10-06.data b/test/data/spec-10-06.data new file mode 100644 index 0000000..860ba25 --- /dev/null +++ b/test/data/spec-10-06.data @@ -0,0 +1,2 @@ +- { inner : entry , also: inner , } +- {inner: entry,last : entry} diff --git a/test/data/spec-10-07.canonical b/test/data/spec-10-07.canonical new file mode 100644 index 0000000..ec74230 --- /dev/null +++ b/test/data/spec-10-07.canonical @@ -0,0 +1,16 @@ +%YAML 1.1 +--- +!!map { + ? !!null "" + : !!str "value", + ? !!str "explicit key" + : !!str "value", + ? !!str "simple key" + : !!str "value", + ? !!seq [ + !!str "collection", + !!str "simple", + !!str "key" + ] + : !!str "value" +} diff --git a/test/data/spec-10-07.data b/test/data/spec-10-07.data new file mode 100644 index 0000000..ff943fb --- /dev/null +++ b/test/data/spec-10-07.data @@ -0,0 +1,7 @@ +{ +? : value, # Empty key +? explicit + key: value, +simple key : value, +[ collection, simple, key ]: value +} diff --git a/test/data/spec-10-08.data b/test/data/spec-10-08.data new file mode 100644 index 0000000..55bd788 --- /dev/null +++ b/test/data/spec-10-08.data @@ -0,0 +1,5 @@ +{ +multi-line + simple key : value, +very long ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................(>1KB)................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... key: value +} diff --git a/test/data/spec-10-08.error b/test/data/spec-10-08.error new file mode 100644 index 0000000..3979e1f --- /dev/null +++ b/test/data/spec-10-08.error @@ -0,0 +1,5 @@ +ERROR: +- A simple key is restricted + to only one line. +- A simple key must not be + longer than 1024 characters. diff --git a/test/data/spec-10-09.canonical b/test/data/spec-10-09.canonical new file mode 100644 index 0000000..4d9827b --- /dev/null +++ b/test/data/spec-10-09.canonical @@ -0,0 +1,8 @@ +%YAML 1.1 +--- +!!map { + ? !!str "key" + : !!str "value", + ? !!str "empty" + : !!null "", +} diff --git a/test/data/spec-10-09.data b/test/data/spec-10-09.data new file mode 100644 index 0000000..4d55e21 --- /dev/null +++ b/test/data/spec-10-09.data @@ -0,0 +1,4 @@ +{ +key : value, +empty: # empty value↓ +} diff --git a/test/data/spec-10-10.canonical b/test/data/spec-10-10.canonical new file mode 100644 index 0000000..016fb64 --- /dev/null +++ b/test/data/spec-10-10.canonical @@ -0,0 +1,16 @@ +%YAML 1.1 +--- +!!map { + ? !!str "explicit key1" + : !!str "explicit value", + ? !!str "explicit key2" + : !!null "", + ? !!str "explicit key3" + : !!null "", + ? !!str "simple key1" + : !!str "explicit value", + ? !!str "simple key2" + : !!null "", + ? !!str "simple key3" + : !!null "", +} diff --git a/test/data/spec-10-10.data b/test/data/spec-10-10.data new file mode 100644 index 0000000..0888b05 --- /dev/null +++ b/test/data/spec-10-10.data @@ -0,0 +1,8 @@ +{ +? explicit key1 : explicit value, +? explicit key2 : , # Explicit empty +? explicit key3, # Empty value +simple key1 : explicit value, +simple key2 : , # Explicit empty +simple key3, # Empty value +} diff --git a/test/data/spec-10-11.canonical b/test/data/spec-10-11.canonical new file mode 100644 index 0000000..7309544 --- /dev/null +++ b/test/data/spec-10-11.canonical @@ -0,0 +1,24 @@ +%YAML 1.1 +--- +!!seq [ + !!map { + ? !!str "explicit key1" + : !!str "explicit value", + }, + !!map { + ? !!str "explicit key2" + : !!null "", + }, + !!map { + ? !!str "explicit key3" + : !!null "", + }, + !!map { + ? !!str "simple key1" + : !!str "explicit value", + }, + !!map { + ? !!str "simple key2" + : !!null "", + }, +] diff --git a/test/data/spec-10-11.data b/test/data/spec-10-11.data new file mode 100644 index 0000000..9f05568 --- /dev/null +++ b/test/data/spec-10-11.data @@ -0,0 +1,7 @@ +[ +? explicit key1 : explicit value, +? explicit key2 : , # Explicit empty +? explicit key3, # Implicit empty +simple key1 : explicit value, +simple key2 : , # Explicit empty +] diff --git a/test/data/spec-10-12.canonical b/test/data/spec-10-12.canonical new file mode 100644 index 0000000..a95dd40 --- /dev/null +++ b/test/data/spec-10-12.canonical @@ -0,0 +1,9 @@ +%YAML 1.1 +--- +!!map { + ? !!str "block" + : !!map { + ? !!str "key" + : !!str "value" + } +} diff --git a/test/data/spec-10-12.data b/test/data/spec-10-12.data new file mode 100644 index 0000000..5521443 --- /dev/null +++ b/test/data/spec-10-12.data @@ -0,0 +1,3 @@ +block: # Block + # mapping + key: value diff --git a/test/data/spec-10-13.canonical b/test/data/spec-10-13.canonical new file mode 100644 index 0000000..e183c50 --- /dev/null +++ b/test/data/spec-10-13.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!map { + ? !!str "explicit key" + : !!null "", + ? !!str "block key\n" + : !!seq [ + !!str "one", + !!str "two", + ] +} diff --git a/test/data/spec-10-13.data b/test/data/spec-10-13.data new file mode 100644 index 0000000..b5b97db --- /dev/null +++ b/test/data/spec-10-13.data @@ -0,0 +1,5 @@ +? explicit key # implicit value +? | + block key +: - one # explicit in-line + - two # block value diff --git a/test/data/spec-10-14.canonical b/test/data/spec-10-14.canonical new file mode 100644 index 0000000..e87c880 --- /dev/null +++ b/test/data/spec-10-14.canonical @@ -0,0 +1,11 @@ +%YAML 1.1 +--- +!!map { + ? !!str "plain key" + : !!null "", + ? !!str "quoted key" + : !!seq [ + !!str "one", + !!str "two", + ] +} diff --git a/test/data/spec-10-14.data b/test/data/spec-10-14.data new file mode 100644 index 0000000..7f5995c --- /dev/null +++ b/test/data/spec-10-14.data @@ -0,0 +1,4 @@ +plain key: # empty value +"quoted key": +- one # explicit next-line +- two # block value diff --git a/test/data/spec-10-15.canonical b/test/data/spec-10-15.canonical new file mode 100644 index 0000000..85fbbd0 --- /dev/null +++ b/test/data/spec-10-15.canonical @@ -0,0 +1,18 @@ +%YAML 1.1 +--- +!!seq [ + !!map { + ? !!str "sun" + : !!str "yellow" + }, + !!map { + ? !!map { + ? !!str "earth" + : !!str "blue" + } + : !!map { + ? !!str "moon" + : !!str "white" + } + } +] diff --git a/test/data/spec-10-15.data b/test/data/spec-10-15.data new file mode 100644 index 0000000..d675cfd --- /dev/null +++ b/test/data/spec-10-15.data @@ -0,0 +1,3 @@ +- sun: yellow +- ? earth: blue + : moon: white diff --git a/test/data/str.data b/test/data/str.data new file mode 100644 index 0000000..7cbdb7c --- /dev/null +++ b/test/data/str.data @@ -0,0 +1 @@ +- abcd diff --git a/test/data/str.detect b/test/data/str.detect new file mode 100644 index 0000000..7d5026f --- /dev/null +++ b/test/data/str.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:str diff --git a/test/data/tags.events b/test/data/tags.events new file mode 100644 index 0000000..bb93dce --- /dev/null +++ b/test/data/tags.events @@ -0,0 +1,12 @@ +- !StreamStart +- !DocumentStart +- !SequenceStart +- !Scalar { value: 'data' } +#- !Scalar { tag: '!', value: 'data' } +- !Scalar { tag: 'tag:yaml.org,2002:str', value: 'data' } +- !Scalar { tag: '!myfunnytag', value: 'data' } +- !Scalar { tag: '!my!ugly!tag', value: 'data' } +- !Scalar { tag: 'tag:my.domain.org,2002:data!? #', value: 'data' } +- !SequenceEnd +- !DocumentEnd +- !StreamEnd diff --git a/test/data/test_mark.marks b/test/data/test_mark.marks new file mode 100644 index 0000000..7b08ee4 --- /dev/null +++ b/test/data/test_mark.marks @@ -0,0 +1,38 @@ +--- +*The first line. +The last line. +--- +The first*line. +The last line. +--- +The first line.* +The last line. +--- +The first line. +*The last line. +--- +The first line. +The last*line. +--- +The first line. +The last line.* +--- +The first line. +*The selected line. +The last line. +--- +The first line. +The selected*line. +The last line. +--- +The first line. +The selected line.* +The last line. +--- +*The only line. +--- +The only*line. +--- +The only line.* +--- +Loooooooooooooooooooooooooooooooooooooooooooooong*Liiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiine diff --git a/test/data/timestamp-bugs.code b/test/data/timestamp-bugs.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/timestamp-bugs.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/timestamp-bugs.data b/test/data/timestamp-bugs.data new file mode 100644 index 0000000..503f1ce --- /dev/null +++ b/test/data/timestamp-bugs.data @@ -0,0 +1,6 @@ +- 2001-12-14 21:59:43.1 -5:30 +- 2001-12-14 21:59:43.1 +5:30 +- 2001-12-14 21:59:43.00101 +- 2001-12-14 21:59:43+1 +- 2001-12-14 21:59:43-1:30 +- 2005-07-08 17:35:04.517600 diff --git a/test/data/timestamp.data b/test/data/timestamp.data new file mode 100644 index 0000000..7d214ce --- /dev/null +++ b/test/data/timestamp.data @@ -0,0 +1,5 @@ +- 2001-12-15T02:59:43.1Z +- 2001-12-14t21:59:43.10-05:00 +- 2001-12-14 21:59:43.10 -5 +- 2001-12-15 2:59:43.10 +- 2002-12-14 diff --git a/test/data/timestamp.detect b/test/data/timestamp.detect new file mode 100644 index 0000000..2013936 --- /dev/null +++ b/test/data/timestamp.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:timestamp diff --git a/test/data/unclosed-bracket.loader-error b/test/data/unclosed-bracket.loader-error new file mode 100644 index 0000000..8c82077 --- /dev/null +++ b/test/data/unclosed-bracket.loader-error @@ -0,0 +1,6 @@ +test: + - [ foo: bar +# comment the rest of the stream to let the scanner detect the problem. +# - baz +#"we could have detected the unclosed bracket on the above line, but this would forbid such syntax as": { +#} diff --git a/test/data/unclosed-quoted-scalar.loader-error b/test/data/unclosed-quoted-scalar.loader-error new file mode 100644 index 0000000..8537429 --- /dev/null +++ b/test/data/unclosed-quoted-scalar.loader-error @@ -0,0 +1,2 @@ +'foo + bar diff --git a/test/data/undefined-anchor.loader-error b/test/data/undefined-anchor.loader-error new file mode 100644 index 0000000..9469103 --- /dev/null +++ b/test/data/undefined-anchor.loader-error @@ -0,0 +1,3 @@ +- foo +- &bar baz +- *bat diff --git a/test/data/undefined-constructor.loader-error b/test/data/undefined-constructor.loader-error new file mode 100644 index 0000000..9a37ccc --- /dev/null +++ b/test/data/undefined-constructor.loader-error @@ -0,0 +1 @@ +--- !foo bar diff --git a/test/data/undefined-tag-handle.loader-error b/test/data/undefined-tag-handle.loader-error new file mode 100644 index 0000000..82ba335 --- /dev/null +++ b/test/data/undefined-tag-handle.loader-error @@ -0,0 +1 @@ +--- !foo!bar baz diff --git a/test/data/unknown.dumper-error b/test/data/unknown.dumper-error new file mode 100644 index 0000000..83204d2 --- /dev/null +++ b/test/data/unknown.dumper-error @@ -0,0 +1 @@ +yaml.safe_dump(object) diff --git a/test/data/unsupported-version.emitter-error b/test/data/unsupported-version.emitter-error new file mode 100644 index 0000000..f9c6197 --- /dev/null +++ b/test/data/unsupported-version.emitter-error @@ -0,0 +1,5 @@ +- !StreamStart +- !DocumentStart { version: [5,6] } +- !Scalar { value: foo } +- !DocumentEnd +- !StreamEnd diff --git a/test/data/utf16be.code b/test/data/utf16be.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/utf16be.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/utf16be.data b/test/data/utf16be.data new file mode 100644 index 0000000000000000000000000000000000000000..50dcfaef829a24326c0bf0f94472a6bb54b2e16d GIT binary patch literal 30 fcmezOpFtN46&OMpLKxhDY(oY!AnC;5%D@ExWH|)p literal 0 HcmV?d00001 diff --git a/test/data/utf16le.code b/test/data/utf16le.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/utf16le.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/utf16le.data b/test/data/utf16le.data new file mode 100644 index 0000000000000000000000000000000000000000..76f5e7345b75f6d1924902bcd46bbea271eb45db GIT binary patch literal 30 gcmezWPnQ7%6&OMpLKxhDEJFq}AnC*4%D}|{0B2qV@Bjb+ literal 0 HcmV?d00001 diff --git a/test/data/utf8-implicit.code b/test/data/utf8-implicit.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/utf8-implicit.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/utf8-implicit.data b/test/data/utf8-implicit.data new file mode 100644 index 0000000..9d8081e --- /dev/null +++ b/test/data/utf8-implicit.data @@ -0,0 +1 @@ +--- implicit UTF-8 diff --git a/test/data/utf8.code b/test/data/utf8.code new file mode 100644 index 0000000..97e0aca --- /dev/null +++ b/test/data/utf8.code @@ -0,0 +1 @@ +#dummy used in constructor test diff --git a/test/data/utf8.data b/test/data/utf8.data new file mode 100644 index 0000000..686f48a --- /dev/null +++ b/test/data/utf8.data @@ -0,0 +1 @@ +--- UTF-8 diff --git a/test/data/value.data b/test/data/value.data new file mode 100644 index 0000000..c5b7680 --- /dev/null +++ b/test/data/value.data @@ -0,0 +1 @@ +- = diff --git a/test/data/value.detect b/test/data/value.detect new file mode 100644 index 0000000..7c37d02 --- /dev/null +++ b/test/data/value.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:value diff --git a/test/data/yaml.data b/test/data/yaml.data new file mode 100644 index 0000000..a4bb3f8 --- /dev/null +++ b/test/data/yaml.data @@ -0,0 +1,3 @@ +- !!yaml '!' +- !!yaml '&' +- !!yaml '*' diff --git a/test/data/yaml.detect b/test/data/yaml.detect new file mode 100644 index 0000000..e2cf189 --- /dev/null +++ b/test/data/yaml.detect @@ -0,0 +1 @@ +tag:yaml.org,2002:yaml diff --git a/test/src/common.d b/test/src/common.d new file mode 100644 index 0000000..1bf7e06 --- /dev/null +++ b/test/src/common.d @@ -0,0 +1,202 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testcommon; + +public import std.conv; +public import std.stdio; +public import std.stream; +public import yaml; + +import core.exception; +import std.algorithm; +import std.array; +import std.conv; +import std.file; +import std.path; +import std.typecons; + +package: + +alias std.stream.File File; + +/** + * Run an unittest. + * + * Params: testName = Name of the unittest. + * testFunction = Unittest function. + * unittestExt = Extensions of data files needed for the unittest. + * skipExt = Extensions that must not be used for the unittest. + */ +void run(F ...)(string testName, void function(bool, F) testFunction, + string[] unittestExt, string[] skipExt = []) +{ + immutable string dataDir = "test/data"; + auto testFilenames = findTestFilenames(dataDir); + bool verbose = false; + + Result[] results; + if(unittestExt.length > 0) + { + outer: foreach(base, extensions; testFilenames) + { + string[] filenames; + foreach(ext; unittestExt) + { + if(!extensions.canFind(ext)){continue outer;} + filenames ~= base ~ '.' ~ ext; + } + foreach(ext; skipExt) + { + if(extensions.canFind(ext)){continue outer;} + } + + results ~= execute!F(testName, testFunction, filenames, verbose); + } + } + else + { + results ~= execute!F(testName, testFunction, cast(string[])[], verbose); + } + display(results, verbose); +} + + +private: + +///Unittest status. +enum TestStatus +{ + Success, //Unittest passed. + Failure, //Unittest failed. + Error //There's an error in the unittest. +} + +///Unittest result. +alias Tuple!(string, "name", string[], "filenames", TestStatus, "kind", string, "info") Result; + +/** + * Find unittest input filenames. + * + * Params: dir = Directory to look in. + * + * Returns: Test input base filenames and their extensions. + */ +string[][string] findTestFilenames(in string dir) +{ + //Groups of extensions indexed by base names. + string[][string] names; + foreach(string name; dirEntries(dir, SpanMode.shallow)) + { + if(isFile(name)) + { + string base = name.getName(); + string ext = name.getExt(); + if(ext is null){ext = "";} + + //If the base name doesn't exist yet, add it; otherwise add new extension. + names[base] = ((base in names) is null) ? [ext] : names[base] ~ ext; + } + } + return names; +} + +/** + * Recursively copy an array of strings to a tuple to use for unittest function input. + * + * Params: index = Current index in the array/tuple. + * tuple = Tuple to copy to. + * strings = Strings to copy. + */ +void stringsToTuple(uint index, F ...)(ref F tuple, in string[] strings) +in{assert(F.length == strings.length);} +body +{ + tuple[index] = strings[index]; + static if(index > 0){stringsToTuple!(index - 1, F)(tuple, strings);} +} + +/** + * Execute an unittest on specified files. + * + * Params: testName = Name of the unittest. + * testFunction = Unittest function. + * filenames = Names of input files to test with. + * verbose = Print verbose output? + * + * Returns: Information about the results of the unittest. + */ +Result execute(F ...)(in string testName, void function(bool, F) testFunction, + string[] filenames, in bool verbose) +{ + if(verbose) + { + writeln("==========================================================================="); + writeln(testName ~ "(" ~ filenames.join(", ") ~ ")..."); + } + + auto kind = TestStatus.Success; + string info = ""; + try + { + //Convert filenames to parameters tuple and call the test function. + F parameters; + stringsToTuple!(F.length - 1, F)(parameters, filenames); + testFunction(verbose, parameters); + if(!verbose){write(".");} + } + catch(Throwable e) + { + info = to!string(typeid(e)) ~ "\n" ~ to!string(e); + kind = (typeid(e) is typeid(AssertError)) ? TestStatus.Failure : TestStatus.Error; + write((verbose ? to!string(e) : to!string(kind)) ~ " "); + } + + stdout.flush(); + + return Result(testName, filenames, kind, info); +} + +/** + * Display unittest results. + * + * Params: results = Unittest results. + * verbose = Print verbose output? + */ +void display(Result[] results, in bool verbose) +{ + if(results.length > 0 && !verbose){write("\n");} + + size_t failures = 0; + size_t errors = 0; + + if(verbose) + { + writeln("==========================================================================="); + } + //Results of each test. + foreach(result; results) + { + if(verbose) + { + writeln(result.name, "(" ~ result.filenames.join(", ") ~ "): ", + to!string(result.kind)); + } + + if(result.kind == TestStatus.Success){continue;} + + if(result.kind == TestStatus.Failure){++failures;} + else if(result.kind == TestStatus.Error){++errors;} + writeln(result.info); + writeln("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + } + + //Totals. + writeln("==========================================================================="); + writeln("TESTS: ", results.length); + if(failures > 0){writeln("FAILURES: ", failures);} + if(errors > 0) {writeln("ERRORS: ", errors);} +} diff --git a/test/src/compare.d b/test/src/compare.d new file mode 100644 index 0000000..d35e6d1 --- /dev/null +++ b/test/src/compare.d @@ -0,0 +1,61 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testcompare; + + +import dyaml.testcommon; +import dyaml.token; + + +/** + * Test parser by comparing output from parsing two equivalent YAML files. + * + * Params: verbose = Print verbose output? + * dataFilename = YAML file to parse. + * canonicalFilename = Another file to parse, in canonical YAML format. + */ +void testParser(bool verbose, string dataFilename, string canonicalFilename) +{ + auto dataEvents = Loader(dataFilename).parse(); + auto canonicalEvents = Loader(canonicalFilename).parse(); + + assert(dataEvents.length == canonicalEvents.length); + + + foreach(e; 0 .. dataEvents.length) + { + assert(dataEvents[e].id == canonicalEvents[e].id); + } +} + + +/** + * Test loader by comparing output from loading two equivalent YAML files. + * + * Params: verbose = Print verbose output? + * dataFilename = YAML file to load. + * canonicalFilename = Another file to load, in canonical YAML format. + */ +void testLoader(bool verbose, string dataFilename, string canonicalFilename) +{ + auto data = loadAll(dataFilename); + auto canonical = loadAll(canonicalFilename); + + assert(data.length == canonical.length); + foreach(n; 0 .. data.length) + { + assert(data[n] == canonical[n]); + } +} + + +unittest +{ + writeln("D:YAML comparison unittest"); + run("testParser", &testParser, ["data", "canonical"]); + run("testLoader", &testLoader, ["data", "canonical"], ["test_loader_skip"]); +} diff --git a/test/src/constructor.d b/test/src/constructor.d new file mode 100644 index 0000000..82419f5 --- /dev/null +++ b/test/src/constructor.d @@ -0,0 +1,408 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testconstructor; + + +import std.datetime; +import std.exception; +import std.path; + +import dyaml.testcommon; + + +///Expected results of loading test inputs. +Node[][string] expected; + +///Initialize expected. +static this() +{ + expected["construct-binary.data"] = constructBinary(); + expected["construct-bool.data"] = constructBool(); + expected["construct-custom.data"] = constructCustom(); + expected["construct-float.data"] = constructFloat(); + expected["construct-int.data"] = constructInt(); + expected["construct-map.data"] = constructMap(); + expected["construct-merge.data"] = constructMerge(); + expected["construct-null.data"] = constructNull(); + expected["construct-omap.data"] = constructOMap(); + expected["construct-pairs.data"] = constructPairs(); + expected["construct-seq.data"] = constructSeq(); + expected["construct-set.data"] = constructSet(); + expected["construct-str-ascii.data"] = constructStrASCII(); + expected["construct-str.data"] = constructStr(); + expected["construct-str-utf8.data"] = constructStrUTF8(); + expected["construct-timestamp.data"] = constructTimestamp(); + expected["construct-value.data"] = constructValue(); + expected["duplicate-merge-key.data"] = duplicateMergeKey(); + expected["float-representer-2.3-bug.data"] = floatRepresenterBug(); + expected["invalid-single-quote-bug.data"] = invalidSingleQuoteBug(); + expected["more-floats.data"] = moreFloats(); + expected["negative-float-bug.data"] = negativeFloatBug(); + expected["single-dot-is-not-float-bug.data"] = singleDotFloatBug(); + expected["timestamp-bugs.data"] = timestampBugs(); + expected["utf16be.data"] = utf16be(); + expected["utf16le.data"] = utf16le(); + expected["utf8.data"] = utf8(); + expected["utf8-implicit.data"] = utf8implicit(); +} + +///Construct a node with specified value. +Node node(T)(T value) +{ + static if(Node.Value.allowed!T){return Node(Node.Value(value));} + else{return Node(Node.userValue(value));} +} + +///Construct a pair of nodes with specified values. +Node.Pair pair(A, B)(A a, B b) +{ + static if(is(A == Node) && is(B == Node)){return Node.Pair(a, b);} + else static if(is(A == Node)) {return Node.Pair(a, node(b));} + else static if(is(B == Node)) {return Node.Pair(node(a), b);} + else {return Node.Pair(node(a), node(b));} +} + +///Test cases: + +Node[] constructBinary() +{ + auto canonical = cast(ubyte[])"GIF89a\x0c\x00\x0c\x00\x84\x00\x00\xff\xff\xf7\xf5\xf5\xee\xe9\xe9\xe5fff\x00\x00\x00\xe7\xe7\xe7^^^\xf3\xf3\xed\x8e\x8e\x8e\xe0\xe0\xe0\x9f\x9f\x9f\x93\x93\x93\xa7\xa7\xa7\x9e\x9e\x9eiiiccc\xa3\xa3\xa3\x84\x84\x84\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9!\xfe\x0eMade with GIMP\x00,\x00\x00\x00\x00\x0c\x00\x0c\x00\x00\x05, \x8e\x810\x9e\xe3@\x14\xe8i\x10\xc4\xd1\x8a\x08\x1c\xcf\x80M$z\xef\xff0\x85p\xb8\xb01f\r\x1b\xce\x01\xc3\x01\x1e\x10' \x82\n\x01\x00;"; + auto generic = cast(ubyte[])"GIF89a\x0c\x00\x0c\x00\x84\x00\x00\xff\xff\xf7\xf5\xf5\xee\xe9\xe9\xe5fff\x00\x00\x00\xe7\xe7\xe7^^^\xf3\xf3\xed\x8e\x8e\x8e\xe0\xe0\xe0\x9f\x9f\x9f\x93\x93\x93\xa7\xa7\xa7\x9e\x9e\x9eiiiccc\xa3\xa3\xa3\x84\x84\x84\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9\xff\xfe\xf9!\xfe\x0eMade with GIMP\x00,\x00\x00\x00\x00\x0c\x00\x0c\x00\x00\x05, \x8e\x810\x9e\xe3@\x14\xe8i\x10\xc4\xd1\x8a\x08\x1c\xcf\x80M$z\xef\xff0\x85p\xb8\xb01f\r\x1b\xce\x01\xc3\x01\x1e\x10' \x82\n\x01\x00;"; + auto description = "The binary value above is a tiny arrow encoded as a gif image."; + + return [node([pair("canonical", canonical), + pair("generic", generic), + pair("description", description)])]; +} + +Node[] constructBool() +{ + return [node([pair("canonical", true), + pair("answer", false), + pair("logical", true), + pair("option", true), + pair("but", [pair("y", "is a string"), pair("n", "is a string")])])]; +} + +Node[] constructCustom() +{ + return [node([node(new TestClass(1, 0, 0)), + node(new TestClass(1, 2, 3)), + node(TestStruct(10))])]; +} + +Node[] constructFloat() +{ + return [node([pair("canonical", cast(real)685230.15), + pair("exponential", cast(real)685230.15), + pair("fixed", cast(real)685230.15), + pair("sexagesimal", cast(real)685230.15), + pair("negative infinity", -real.infinity), + pair("not a number", real.nan)])]; +} + +Node[] constructInt() +{ + return [node([pair("canonical", 685230L), + pair("decimal", 685230L), + pair("octal", 685230L), + pair("hexadecimal", 685230L), + pair("binary", 685230L), + pair("sexagesimal", 685230L)])]; +} + +Node[] constructMap() +{ + return [node([pair("Block style", + [pair("Clark", "Evans"), + pair("Brian", "Ingerson"), + pair("Oren", "Ben-Kiki")]), + pair("Flow style", + [pair("Clark", "Evans"), + pair("Brian", "Ingerson"), + pair("Oren", "Ben-Kiki")])])]; +} + +Node[] constructMerge() +{ + return [node([node([pair("x", 1L), pair("y", 2L)]), + node([pair("x", 0L), pair("y", 2L)]), + node([pair("r", 10L)]), + node([pair("r", 1L)]), + node([pair("x", 1L), pair("y", 2L), pair("r", 10L), pair("label", "center/big")]), + node([pair("r", 10L), pair("label", "center/big"), pair("x", 1L), pair("y", 2L)]), + node([pair("label", "center/big"), pair("x", 1L), pair("y", 2L), pair("r", 10L)]), + node([pair("x", 1L), pair("label", "center/big"), pair("r", 10L), pair("y", 2L)])])]; +} + +Node[] constructNull() +{ + return [node(YAMLNull()), + node([pair("empty", YAMLNull()), + pair("canonical", YAMLNull()), + pair("english", YAMLNull()), + pair(YAMLNull(), "null key")]), + node([pair("sparse", + [node(YAMLNull()), + node("2nd entry"), + node(YAMLNull()), + node("4th entry"), + node(YAMLNull())])])]; +} + +Node[] constructOMap() +{ + return [node([pair("Bestiary", + [pair("aardvark", "African pig-like ant eater. Ugly."), + pair("anteater", "South-American ant eater. Two species."), + pair("anaconda", "South-American constrictor snake. Scaly.")]), + pair("Numbers",[pair("one", 1L), + pair("two", 2L), + pair("three", 3L)])])]; +} + +Node[] constructPairs() +{ + return [node([pair("Block tasks", + [pair("meeting", "with team."), + pair("meeting", "with boss."), + pair("break", "lunch."), + pair("meeting", "with client.")]), + pair("Flow tasks", + [pair("meeting", "with team"), + pair("meeting", "with boss")])])]; +} + +Node[] constructSeq() +{ + return [node([pair("Block style", + [node("Mercury"), node("Venus"), node("Earth"), node("Mars"), + node("Jupiter"), node("Saturn"), node("Uranus"), node("Neptune"), + node("Pluto")]), + pair("Flow style", + [node("Mercury"), node("Venus"), node("Earth"), node("Mars"), + node("Jupiter"), node("Saturn"), node("Uranus"), node("Neptune"), + node("Pluto")])])]; +} + +Node[] constructSet() +{ + return [node([pair("baseball players", + [node("Mark McGwire"), node("Sammy Sosa"), node("Ken Griffey")]), + pair("baseball teams", + [node("Boston Red Sox"), node("Detroit Tigers"), node("New York Yankees")])])]; +} + +Node[] constructStrASCII() +{ + return [node("ascii string")]; +} + +Node[] constructStr() +{ + return [node([pair("string", "abcd")])]; +} + +Node[] constructStrUTF8() +{ + return [node("\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430")]; +} + +Node[] constructTimestamp() +{ + return [node([pair("canonical", SysTime(DateTime(2001, 12, 15, 2, 59, 43), FracSec.from!"hnsecs"(1000000), UTC())), + pair("valid iso8601", SysTime(DateTime(2001, 12, 15, 2, 59, 43), FracSec.from!"hnsecs"(1000000), UTC())), + pair("space separated", SysTime(DateTime(2001, 12, 15, 2, 59, 43), FracSec.from!"hnsecs"(1000000), UTC())), + pair("no time zone (Z)", SysTime(DateTime(2001, 12, 15, 2, 59, 43), FracSec.from!"hnsecs"(1000000), UTC())), + pair("date (00:00:00Z)", SysTime(DateTime(2002, 12, 14), UTC()))])]; +} + +Node[] constructValue() +{ + return[node([pair("link with", + [node("library1.dll"), node("library2.dll")])]), + node([pair("link with", + [node([pair("=", "library1.dll"), pair("version", cast(real)1.2)]), + node([pair("=", "library2.dll"), pair("version", cast(real)2.3)])])])]; +} + +Node[] duplicateMergeKey() +{ + return [node([pair("foo", "bar"), + pair("x", 1L), + pair("y", 2L), + pair("z", 3L), + pair("t", 4L)])]; +} + +Node[] floatRepresenterBug() +{ + return [node([pair(cast(real)1.0, 1L), + pair(real.infinity, 10L), + pair(-real.infinity, -10L), + pair(real.nan, 100L)])]; +} + +Node[] invalidSingleQuoteBug() +{ + return [node([node("foo \'bar\'"), node("foo\n\'bar\'")])]; +} + +Node[] moreFloats() +{ + return [node([node(cast(real)0.0), + node(cast(real)1.0), + node(cast(real)-1.0), + node(real.infinity), + node(-real.infinity), + node(real.nan), + node(real.nan)])]; +} + +Node[] negativeFloatBug() +{ + return [node(cast(real)-1.0)]; +} + +Node[] singleDotFloatBug() +{ + return [node(".")]; +} + +Node[] timestampBugs() +{ + return [node([node(SysTime(DateTime(2001, 12, 15, 3, 29, 43), FracSec.from!"hnsecs"(1000000), UTC())), + node(SysTime(DateTime(2001, 12, 14, 16, 29, 43), FracSec.from!"hnsecs"(1000000), UTC())), + node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), FracSec.from!"hnsecs"(10100), UTC())), + node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), new SimpleTimeZone(60))), + node(SysTime(DateTime(2001, 12, 14, 21, 59, 43), new SimpleTimeZone(-90))), + node(SysTime(DateTime(2005, 7, 8, 17, 35, 4), FracSec.from!"hnsecs"(5176000), UTC()))])]; +} + +Node[] utf16be() +{ + return [node("UTF-16-BE")]; +} + +Node[] utf16le() +{ + return [node("UTF-16-LE")]; +} + +Node[] utf8() +{ + return [node("UTF-8")]; +} + +Node[] utf8implicit() +{ + return [node("implicit UTF-8")]; +} + +///Testing custom YAML class type. +class TestClass +{ + int x, y, z; + + this(int x, int y, int z) + { + this.x = x; + this.y = y; + this.z = z; + } + + override bool opEquals(Object rhs) + { + if(typeid(rhs) != typeid(TestClass)){return false;} + auto t = cast(TestClass)rhs; + return x == t.x && y == t.y && z == t.z; + } +} + +///Testing custom YAML struct type. +struct TestStruct +{ + int value; + + bool opEquals(const ref TestStruct rhs) const + { + return value == rhs.value; + } +} + +///Constructor function for TestClass. +TestClass constructClass(Mark start, Mark end, Node.Pair[] pairs) +{ + int x, y, z; + foreach(ref pair; pairs) + { + switch(pair.key.get!string) + { + case "x": x = pair.value.get!int; break; + case "y": y = pair.value.get!int; break; + case "z": z = pair.value.get!int; break; + default: break; + } + } + + return new TestClass(x, y, z); +} + +///Constructor function for TestStruct. +TestStruct constructStruct(Mark start, Mark end, string value) +{ + return TestStruct(to!int(value)); +} + +/** + * Constructor unittest. + * + * Params: verbose = Print verbose output? + * dataFilename = File name to read from. + * codeDummy = Dummy .code filename, used to determine that + * .data file with the same name should be used in this test. + */ +void testConstructor(bool verbose, string dataFilename, string codeDummy) +{ + string base = dataFilename.basename; + enforce((base in expected) !is null, + new Exception("Unimplemented constructor test: " ~ base)); + + auto constructor = new Constructor; + constructor.addConstructor("!tag1", &constructClass); + constructor.addConstructor("!tag2", &constructStruct); + + auto resolver = new Resolver; + auto loader = Loader(dataFilename, constructor, resolver); + + //Compare with expected results document by document. + size_t i = 0; + foreach(node; loader) + { + if(node != expected[base][i]) + { + if(verbose) + { + writeln("Expected value:"); + writeln(expected[base][i].debugString); + writeln("\n"); + writeln("Actual value:"); + writeln(node.debugString); + } + assert(false); + } + ++i; + } + assert(i == expected[base].length); +} + + +unittest +{ + writeln("D:YAML Constructor unittest"); + run("testConstructor", &testConstructor, ["data", "code"]); +} diff --git a/test/src/errors.d b/test/src/errors.d new file mode 100644 index 0000000..157225f --- /dev/null +++ b/test/src/errors.d @@ -0,0 +1,103 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testerrors; + + +import dyaml.testcommon; + + +/** + * Loader error unittest from file stream. + * + * Params: verbose = Print verbose output? + * errorFilename = File name to read from. + */ +void testLoaderError(bool verbose, string errorFilename) +{ + auto file = new File(errorFilename); + scope(exit){file.close();} + + Node[] nodes; + try{nodes = loadAll(file, errorFilename);} + catch(YAMLException e) + { + if(verbose){writeln(typeid(e).toString(), "\n", e);} + return; + } + assert(false, "Expected an exception"); +} + +/** + * Loader error unittest from string. + * + * Params: verbose = Print verbose output? + * errorFilename = File name to read from. + */ +void testLoaderErrorString(bool verbose, string errorFilename) +{ + //Load file to a buffer, then pass that to the YAML loader. + auto file = new File(errorFilename); + scope(exit){file.close();} + ubyte[] buffer; + buffer.length = file.available; + file.read(buffer); + + try + { + auto nodes = loadAll(new MemoryStream(buffer), errorFilename); + } + catch(YAMLException e) + { + if(verbose){writeln(typeid(e).toString(), "\n", e);} + return; + } + assert(false, "Expected an exception"); +} + +/** + * Loader error unittest from filename. + * + * Params: verbose = Print verbose output? + * errorFilename = File name to read from. + */ +void testLoaderErrorFilename(bool verbose, string errorFilename) +{ + try{auto nodes = loadAll(errorFilename);} + catch(YAMLException e) + { + if(verbose){writeln(typeid(e).toString(), "\n", e);} + return; + } + assert(false, "Expected an exception"); +} + +/** + * Loader error unittest loading a single document from a file. + * + * Params: verbose = Print verbose output? + * errorFilename = File name to read from. + */ +void testLoaderErrorSingle(bool verbose, string errorFilename) +{ + try{auto nodes = load(errorFilename);} + catch(YAMLException e) + { + if(verbose){writeln(typeid(e).toString(), "\n", e);} + return; + } + assert(false, "Expected an exception"); +} + + +unittest +{ + writeln("D:YAML Errors unittest"); + run("testLoaderError", &testLoaderError, ["loader-error"]); + run("testLoaderErrorString", &testLoaderErrorString, ["loader-error"]); + run("testLoaderErrorFilename", &testLoaderErrorFilename, ["loader-error"]); + run("testLoaderErrorSingle", &testLoaderErrorSingle, ["single-loader-error"]); +} diff --git a/test/src/inputoutput.d b/test/src/inputoutput.d new file mode 100644 index 0000000..c43925d --- /dev/null +++ b/test/src/inputoutput.d @@ -0,0 +1,101 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testinputoutput; + + +import std.array; +import std.file; +import std.system; + +import dyaml.testcommon; + + +alias std.system.endian endian; + +/** + * Get an UTF-16 byte order mark. + * + * Params: wrong = Get the incorrect BOM for this system. + * + * Returns: UTF-16 byte order mark. + */ +wchar bom16(bool wrong = false) pure +{ + wchar little = *(cast(wchar*)ByteOrderMarks[BOM.UTF16LE]); + wchar big = *(cast(wchar*)ByteOrderMarks[BOM.UTF16BE]); + if(!wrong){return endian == Endian.LittleEndian ? little : big;} + return endian == Endian.LittleEndian ? big : little; +} + +/** + * Get an UTF-32 byte order mark. + * + * Params: wrong = Get the incorrect BOM for this system. + * + * Returns: UTF-32 byte order mark. + */ +dchar bom32(bool wrong = false) pure +{ + dchar little = *(cast(dchar*)ByteOrderMarks[BOM.UTF32LE]); + dchar big = *(cast(dchar*)ByteOrderMarks[BOM.UTF32BE]); + if(!wrong){return endian == Endian.LittleEndian ? little : big;} + return endian == Endian.LittleEndian ? big : little; +} + +/** + * Unicode input unittest. Tests various encodings. + * + * Params: verbose = Print verbose output? + * unicodeFilename = File name to read from. + */ +void testUnicodeInput(bool verbose, string unicodeFilename) +{ + string data = readText(unicodeFilename); + string expected = data.split().join(" "); + + Node output = load(new MemoryStream(to!(char[])(data)), unicodeFilename); + assert(output.get!string == expected); + + foreach(stream; [new MemoryStream(cast(byte[])(bom16() ~ to!(wchar[])(data))), + new MemoryStream(cast(byte[])(bom32() ~ to!(dchar[])(data)))]) + { + output = load(stream, unicodeFilename); + assert(output.get!string == expected); + } +} + +/** + * Unicode input error unittest. Tests various encodings with incorrect BOMs. + * + * Params: verbose = Print verbose output? + * unicodeFilename = File name to read from. + */ +void testUnicodeInputErrors(bool verbose, string unicodeFilename) +{ + string data = readText(unicodeFilename); + foreach(stream; [new MemoryStream(cast(byte[])(to!(wchar[])(data))), + new MemoryStream(cast(byte[])(to!(wchar[])(data))), + new MemoryStream(cast(byte[])(bom16(true) ~ to!(wchar[])(data))), + new MemoryStream(cast(byte[])(bom32(true) ~ to!(dchar[])(data)))]) + { + try{load(stream, unicodeFilename);} + catch(YAMLException e) + { + if(verbose){writeln(typeid(e).toString(), "\n", e);} + continue; + } + assert(false, "Expected an exception"); + } +} + + +unittest +{ + writeln("D:YAML I/O unittest"); + run("testUnicodeInput", &testUnicodeInput, ["unicode"]); + run("testUnicodeInputErrors", &testUnicodeInputErrors, ["unicode"]); +} diff --git a/test/src/reader.d b/test/src/reader.d new file mode 100644 index 0000000..d79d212 --- /dev/null +++ b/test/src/reader.d @@ -0,0 +1,53 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testreader; + + +import dyaml.testcommon; +import dyaml.reader; + + +/** + * Try reading entire stream through Reader, expecting an error (the stream is invalid). + * + * Params: verbose = Print verbose output? + * data = Stream to read. + */ +void runReader(in bool verbose, Stream stream) +{ + try + { + auto reader = new Reader(stream); + while(reader.peek() != '\0'){reader.forward();} + } + catch(ReaderException e) + { + if(verbose){writeln(typeid(e).toString(), "\n", e);} + return; + } + assert(false, "Expected an exception"); +} + + +/** + * Stream error unittest. Tries to read invalid input streams, expecting errors. + * + * Params: verbose = Print verbose output? + * errorFilename = File name to read from. + */ +void testStreamError(bool verbose, string errorFilename) +{ + auto file = new File(errorFilename); + scope(exit){file.close();} + runReader(verbose, file); +} + +unittest +{ + writeln("D:YAML Reader unittest"); + run("testStreamError", &testStreamError, ["stream-error"]); +} diff --git a/test/src/tokens.d b/test/src/tokens.d new file mode 100644 index 0000000..02dd329 --- /dev/null +++ b/test/src/tokens.d @@ -0,0 +1,91 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module dyaml.testtokens; + + +import std.array; +import std.file; + +import dyaml.testcommon; +import dyaml.token; + + +/** + * Test tokens output by scanner. + * + * Params: verbose = Print verbose output? + * dataFilename = File to scan. + * tokensFilename = File containing expected tokens. + */ +void testTokens(bool verbose, string dataFilename, string tokensFilename) +{ + //representations of YAML tokens in tokens file. + auto replace = [TokenID.Directive : "%" , + TokenID.DocumentStart : "---" , + TokenID.DocumentEnd : "..." , + TokenID.Alias : "*" , + TokenID.Anchor : "&" , + TokenID.Tag : "!" , + TokenID.Scalar : "_" , + TokenID.BlockSequenceStart : "[[" , + TokenID.BlockMappingStart : "{{" , + TokenID.BlockEnd : "]}" , + TokenID.FlowSequenceStart : "[" , + TokenID.FlowSequenceEnd : "]" , + TokenID.FlowMappingStart : "{" , + TokenID.FlowMappingEnd : "}" , + TokenID.BlockEntry : "," , + TokenID.FlowEntry : "," , + TokenID.Key : "?" , + TokenID.Value : ":" ]; + + string[] tokens1; + string[] tokens2 = readText(tokensFilename).split(); + scope(exit) + { + if(verbose){writeln("tokens1: ", tokens1, "\ntokens2: ", tokens2);} + } + + auto loader = Loader(dataFilename); + foreach(token; loader.scan()) + { + if(token.id != TokenID.StreamStart && token.id != TokenID.StreamEnd) + { + tokens1 ~= replace[token.id]; + } + } + + assert(tokens1 == tokens2); +} + +/** + * Test scanner by scanning a file, expecting no errors. + * + * Params: verbose = Print verbose output? + * dataFilename = File to scan. + * canonicalFilename = Another file to scan, in canonical YAML format. + */ +void testScanner(bool verbose, string dataFilename, string canonicalFilename) +{ + foreach(filename; [dataFilename, canonicalFilename]) + { + string[] tokens; + scope(exit) + { + if(verbose){writeln(tokens);} + } + auto loader = Loader(filename); + foreach(ref token; loader.scan()){tokens ~= to!string(token.id);} + } +} + +unittest +{ + writeln("D:YAML tokens unittest"); + run("testTokens", &testTokens, ["data", "tokens"]); + run("testScanner", &testScanner, ["data", "canonical"]); +} diff --git a/unittest.d b/unittest.d new file mode 100644 index 0000000..c3b75a1 --- /dev/null +++ b/unittest.d @@ -0,0 +1,16 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +import yaml; + +import std.stdio; + + +void main() +{ + writeln("Done"); +} + diff --git a/yaml.d b/yaml.d new file mode 100644 index 0000000..2f79d9b --- /dev/null +++ b/yaml.d @@ -0,0 +1,13 @@ + +// Copyright Ferdinand Majerech 2011. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module yaml; + +public import dyaml.loader; +public import dyaml.constructor; +public import dyaml.resolver; +public import dyaml.node; +public import dyaml.exception;