├── .codecov.yml ├── .editorconfig ├── .github └── workflows │ └── d.yml ├── .gitignore ├── LICENSE_1_0.txt ├── README.md ├── appveyor.yml ├── docs ├── articles │ └── spec_differences.md ├── index.md ├── logo.svg ├── logo128.png ├── logo210.png └── tutorials │ ├── custom_types.md │ ├── getting_started.md │ └── yaml_syntax.md ├── dub.json ├── examples ├── constructor ├── getting_started │ ├── dub.json │ ├── input.yaml │ └── main.d ├── representer │ ├── dub.json │ └── main.d ├── resolver │ ├── dub.json │ ├── input.yaml │ └── main.d ├── tojson │ ├── dub.json │ └── source │ │ └── app.d ├── tokens │ ├── dub.json │ └── source │ │ └── app.d ├── yaml_bench │ ├── dub.json │ └── yaml_bench.d ├── yaml_gen │ ├── config.yaml │ ├── dub.json │ └── yaml_gen.d └── yaml_stats │ ├── dub.json │ ├── small.yaml │ └── yaml_stats.d ├── hmod.cfg ├── meson.build ├── source └── dyaml │ ├── composer.d │ ├── constructor.d │ ├── dumper.d │ ├── emitter.d │ ├── encoding.d │ ├── escapes.d │ ├── event.d │ ├── exception.d │ ├── linebreak.d │ ├── loader.d │ ├── node.d │ ├── package.d │ ├── parser.d │ ├── queue.d │ ├── reader.d │ ├── representer.d │ ├── resolver.d │ ├── scanner.d │ ├── serializer.d │ ├── stdsumtype.d │ ├── style.d │ ├── tagdirective.d │ ├── test │ ├── constructor.d │ ├── representer.d │ ├── suite.d │ └── suitehelpers.d │ └── token.d ├── subprojects └── tinyendian.wrap ├── test ├── a-nasty-libyaml-bug.yaml ├── bmpchars.yaml ├── colon-in-flow-context.yaml ├── composer.yaml ├── construct.yaml ├── document-separator-in-quoted-scalar.yaml ├── duplicate-errors.yaml ├── emit-block-scalar-in-simple-key-context-bug.yaml ├── emojianchor.yaml ├── empty-document-bug.yaml ├── expected.yaml ├── fetch-complex-value-bug.yaml ├── forbidden.yaml ├── invalid.yaml ├── multiline.yaml ├── no-block-collection-end.yaml ├── no-block-mapping-end.yaml ├── no-document-start.yaml ├── no-flow-mapping-end.yaml ├── no-flow-sequence-end.yaml ├── no-node.yaml ├── question-mark-in-flow-context.yaml ├── recursive-alias.yaml ├── remove-possible-simple-key-bug.yaml ├── run-parser-crash-bug.yaml ├── scan-document-end-bug.yaml ├── scan-line-break-bug.yaml ├── sloppy-indentation.yaml ├── spec 1.1 │ ├── spec-02-01.yaml │ ├── spec-02-02.yaml │ ├── spec-02-03.yaml │ ├── spec-02-04.yaml │ ├── spec-02-05.yaml │ ├── spec-02-06.yaml │ ├── spec-02-07.yaml │ ├── spec-02-08.yaml │ ├── spec-02-09.yaml │ ├── spec-02-10.yaml │ ├── spec-02-11.yaml │ ├── spec-02-12.yaml │ ├── spec-02-13.yaml │ ├── spec-02-14.yaml │ ├── spec-02-15.yaml │ ├── spec-02-16.yaml │ ├── spec-02-17.yaml │ ├── spec-02-18.yaml │ ├── spec-02-19.yaml │ ├── spec-02-20.yaml │ ├── spec-02-21.yaml │ ├── spec-02-22.yaml │ ├── spec-02-23.yaml │ ├── spec-02-24.yaml │ ├── spec-02-25.yaml │ ├── spec-02-26.yaml │ ├── spec-02-27.yaml │ ├── spec-02-28.yaml │ ├── spec-05-01-utf8.yaml │ ├── spec-05-02-utf8.yaml │ ├── spec-05-03.yaml │ ├── spec-05-04.yaml │ ├── spec-05-05.yaml │ ├── spec-05-06.yaml │ ├── spec-05-07.yaml │ ├── spec-05-08.yaml │ ├── spec-05-09.yaml │ ├── spec-05-10.yaml │ ├── spec-05-11.yaml │ ├── spec-05-12.yaml │ ├── spec-05-13.yaml │ ├── spec-05-14.yaml │ ├── spec-05-15.yaml │ ├── spec-06-01.yaml │ ├── spec-06-02.yaml │ ├── spec-06-03.yaml │ ├── spec-06-04.yaml │ ├── spec-06-05.yaml │ ├── spec-06-06.yaml │ ├── spec-06-07.yaml │ ├── spec-06-08.yaml │ ├── spec-07-01.yaml │ ├── spec-07-02.yaml │ ├── spec-07-03.yaml │ ├── spec-07-04.yaml │ ├── spec-07-05.yaml │ ├── spec-07-06.yaml │ ├── spec-07-07.yaml │ ├── spec-07-08.yaml │ ├── spec-07-09.yaml │ ├── spec-07-10.yaml │ ├── spec-07-11.yaml │ ├── spec-07-12.yaml │ ├── spec-07-13.yaml │ ├── spec-08-01.yaml │ ├── spec-08-02.yaml │ ├── spec-08-03.yaml │ ├── spec-08-04.yaml │ ├── spec-08-05.yaml │ ├── spec-08-06.yaml │ ├── spec-08-07.yaml │ ├── spec-08-08.yaml │ ├── spec-08-09.yaml │ ├── spec-08-10.yaml │ ├── spec-08-11.yaml │ ├── spec-08-12.yaml │ ├── spec-08-13.yaml │ ├── spec-08-14.yaml │ ├── spec-08-15.yaml │ ├── spec-09-01.yaml │ ├── spec-09-02.yaml │ ├── spec-09-03.yaml │ ├── spec-09-04.yaml │ ├── spec-09-05.yaml │ ├── spec-09-06.yaml │ ├── spec-09-07.yaml │ ├── spec-09-08.yaml │ ├── spec-09-09.yaml │ ├── spec-09-10.yaml │ ├── spec-09-11.yaml │ ├── spec-09-12.yaml │ ├── spec-09-13.yaml │ ├── spec-09-14.yaml │ ├── spec-09-15.yaml │ ├── spec-09-16.yaml │ ├── spec-09-17.yaml │ ├── spec-09-18.yaml │ ├── spec-09-19.yaml │ ├── spec-09-20.yaml │ ├── spec-09-21.yaml │ ├── spec-09-22.yaml │ ├── spec-09-23.yaml │ ├── spec-09-24.yaml │ ├── spec-09-25.yaml │ ├── spec-09-26.yaml │ ├── spec-09-29.yaml │ ├── spec-09-30.yaml │ ├── spec-10-01.yaml │ ├── spec-10-02.yaml │ ├── spec-10-03.yaml │ ├── spec-10-04.yaml │ ├── spec-10-05.yaml │ ├── spec-10-06.yaml │ ├── spec-10-07.yaml │ ├── spec-10-08.yaml │ ├── spec-10-09.yaml │ ├── spec-10-10.yaml │ ├── spec-10-11.yaml │ ├── spec-10-12.yaml │ ├── spec-10-13.yaml │ ├── spec-10-14.yaml │ └── spec-10-15.yaml ├── unclosed-bracket.yaml ├── unclosed-quoted-scalar.yaml ├── undefined-anchor.yaml └── undefined-tag-handle.yaml └── testsuite ├── dub.json └── source └── app.d /.codecov.yml: -------------------------------------------------------------------------------- 1 | # Documentation: https://github.com/codecov/support/wiki/codecov.yml 2 | codecov: 3 | coverage: 4 | precision: 3 5 | round: down 6 | 7 | status: 8 | # Learn more at https://codecov.io/docs#yaml_default_commit_status 9 | project: true 10 | patch: true 11 | changes: false 12 | 13 | comment: false 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig file: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | insert_final_newline = true 9 | 10 | [*.d] 11 | charset = utf-8 12 | indent_style = space 13 | indent_size = 4 14 | trim_trailing_whitespace = true 15 | -------------------------------------------------------------------------------- /.github/workflows/d.yml: -------------------------------------------------------------------------------- 1 | name: D 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | dc: 14 | - dmd-latest 15 | - ldc-latest 16 | - dmd-beta 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v3 20 | with: 21 | fetch-depth: 2 22 | - uses: dlang-community/setup-dlang@v1 23 | with: 24 | compiler: ${{ matrix.dc }} 25 | - name: 'Test' 26 | run: | 27 | dub test -c unittest-dip1000 28 | dub test --build=unittest-cov 29 | bash <(curl -s https://codecov.io/bash) 30 | examples: 31 | runs-on: ubuntu-latest 32 | needs: build 33 | steps: 34 | - uses: actions/checkout@v3 35 | - uses: dlang-community/setup-dlang@v1 36 | with: 37 | compiler: dmd-latest 38 | - name: 'Build Examples' 39 | run: | 40 | dub build dyaml:benchmark 41 | dub build dyaml:constructor 42 | dub build dyaml:getting-started 43 | dub build dyaml:representer 44 | dub build dyaml:resolver 45 | dub build dyaml:testsuite 46 | dub build dyaml:tojson 47 | dub build dyaml:tokens 48 | dub build dyaml:yaml_gen 49 | dub build dyaml:yaml_stats 50 | ninja: 51 | runs-on: ubuntu-latest 52 | steps: 53 | - uses: actions/checkout@v3 54 | - uses: dlang-community/setup-dlang@v1 55 | with: 56 | compiler: dmd-latest 57 | - name: 'Install dependencies' 58 | run: | 59 | sudo apt-get install python3-pip python3-setuptools python3-wheel ninja-build 60 | sudo pip3 install meson 61 | - name: 'Build' 62 | run: | 63 | export PATH=$PATH:$PWD/.ntmp 64 | meson build && ninja -j8 -C build 65 | ninja -j8 -C build test -v 66 | yaml-test-suite: 67 | runs-on: ubuntu-latest 68 | needs: build 69 | steps: 70 | - uses: actions/checkout@v3 71 | - uses: dlang-community/setup-dlang@v1 72 | with: 73 | compiler: dmd-latest 74 | - name: 'Run YAML test suite' 75 | run: | 76 | git clone https://github.com/yaml/yaml-test-suite 77 | dub run dyaml:testsuite 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /__test__library__ 2 | /examples/resolver/resolver 3 | /examples/representer/representer 4 | /examples/getting_started/getting-started 5 | /examples/constructor/constructor 6 | /libdyaml 7 | /examples/yaml_gen/yaml_gen 8 | /unittest.obj 9 | /examples/yaml_stats/yaml_stats 10 | /examples/yaml_bench/yaml_bench 11 | /examples/representer/output.yaml 12 | /examples/getting_started/output.yaml 13 | /examples/getting_started/main.obj 14 | /cdc.obj 15 | /unittest 16 | *.pdb 17 | 18 | # Backups # 19 | ########### 20 | *~ 21 | *.sw* 22 | 23 | # dub # 24 | ####### 25 | *.dub* 26 | dub.selections.json 27 | 28 | # Compiled source # 29 | ################### 30 | unittest 31 | cdc 32 | main 33 | *.a 34 | *.lib 35 | *.o 36 | *.obj 37 | *.exe 38 | docs.json 39 | 40 | # Packages # 41 | ############ 42 | # it's better to unpack these files and commit the raw source 43 | # git has its own built in compression methods 44 | *.tar 45 | *.tar.xz 46 | *.tar.gz 47 | *.zip 48 | 49 | # OS generated files # 50 | ###################### 51 | .DS_Store? 52 | ehthumbs.db 53 | Icon? 54 | Thumbs.db 55 | .directory 56 | 57 | # Profiling outputs # 58 | ##################### 59 | perf.data 60 | perf.data.old 61 | callgrind.out.* 62 | 63 | # Test outputs # 64 | example.yaml 65 | 66 | # Unittest Coverage output # 67 | *.lst 68 | 69 | .meson-subproject-wrap-hash.txt 70 | -------------------------------------------------------------------------------- /LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # D:YAML 2 | 3 | [![codecov](https://codecov.io/gh/dlang-community/D-YAML/branch/master/graph/badge.svg)](https://codecov.io/gh/dlang-community/D-YAML) 4 | [![code.dlang.org](https://img.shields.io/dub/v/dyaml.svg)](http://code.dlang.org/packages/dyaml) 5 | 6 | ## Introduction 7 | 8 | D:YAML is an open source YAML parser and emitter library for the D programming language. 9 | It is [almost](https://dlang-community.github.io/D-YAML/articles/spec_differences.html) compliant to the YAML 1.1 specification. 10 | D:YAML is based on [PyYAML](http://www.pyyaml.org) created by Kirill Simonov. 11 | 12 | D:YAML is designed to be easy to use while supporting the full feature set of YAML. 13 | To start using it in your project, see the [Getting Started](https://dlang-community.github.io/D-YAML/tutorials/getting_started.html) tutorial. 14 | 15 | ## Features 16 | 17 | - Easy to use, high level API and detailed debugging messages. 18 | - Detailed API documentation and tutorials. 19 | - Code examples. 20 | - Supports all YAML 1.1 constructs. All examples from the YAML 1.1 21 | specification are parsed correctly. 22 | - Reads from and writes from/to YAML files or in-memory buffers. 23 | - UTF-8, UTF-16 and UTF-32 encodings are supported, both big and 24 | little endian (plain ASCII also works as it is a subset of UTF-8). 25 | - Support for both block (Python-like, based on indentation) and flow 26 | (JSON-like, based on bracing) constructs. 27 | - Support for YAML anchors and aliases. 28 | - Support for default values in mappings. 29 | - Support for custom tags (data types), and implicit tag resolution 30 | for custom scalar tags. 31 | - All tags (data types) described at are 32 | supported, with the exception of `tag:yaml.org,2002:yaml`, which is 33 | used to represent YAML code in YAML. 34 | - Remembers YAML style information between loading and dumping if 35 | possible. 36 | - Reuses input memory and uses slices to minimize memory allocations. 37 | - There is no support for recursive data structures. There are no 38 | plans to implement this at the moment. 39 | 40 | ## Directory structure 41 | 42 | | Directory | Contents | 43 | |---------------|--------------------------------| 44 | | `./` | This README, utility scripts. | 45 | | `./docs` | Documentation. | 46 | | `./source` | Source code. | 47 | | `./examples/` | Example projects using D:YAML. | 48 | | `./test` | Unittest data. | 49 | 50 | ## Installing and tutorial 51 | 52 | See the [Getting Started](https://dlang-community.github.io/D-YAML/tutorials/getting_started.html). 53 | Tutorial and other tutorials that can be found at the [GitHub pages](https://dlang-community.github.io/D-YAML/) or in the `docs` directory of the repository. 54 | 55 | API documentation is available [here](https://dyaml.dpldocs.info/dyaml.html). 56 | 57 | ## License 58 | 59 | D:YAML is released under the terms of the [Boost Software 60 | License 1.0](http://www.boost.org/LICENSE_1_0.txt). This license allows 61 | you to use the source code in your own projects, open source or 62 | proprietary, and to modify it to suit your needs. However, in source 63 | distributions, you have to preserve the license headers in the source 64 | code and the accompanying license file. 65 | 66 | Full text of the license can be found in file `LICENSE_1_0.txt` and is 67 | also displayed here: 68 | 69 | Boost Software License - Version 1.0 - August 17th, 2003 70 | 71 | Permission is hereby granted, free of charge, to any person or organization 72 | obtaining a copy of the software and accompanying documentation covered by 73 | this license (the "Software") to use, reproduce, display, distribute, 74 | execute, and transmit the Software, and to prepare derivative works of the 75 | Software, and to permit third-parties to whom the Software is furnished to 76 | do so, all subject to the following: 77 | 78 | The copyright notices in the Software and this entire statement, including 79 | the above license grant, this restriction and the following disclaimer, 80 | must be included in all copies of the Software, in whole or in part, and 81 | all derivative works of the Software, unless such copies or derivative 82 | works are solely in the form of machine-executable object code generated by 83 | a source language processor. 84 | 85 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 86 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 87 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 88 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 89 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 90 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 91 | DEALINGS IN THE SOFTWARE. 92 | 93 | ## Credits 94 | 95 | D:YAML was created by Ferdinand Majerech aka Kiith-Sa and is handled by the [dlang-community](https://github.com/dlang-community) organization since 2017. 96 | Parts of code based on [PyYAML](http://www.pyyaml.org) created by Kirill Simonov. 97 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | platform: x64 2 | environment: 3 | matrix: 4 | #- DC: dmd 5 | # DVersion: nightly 6 | # arch: x64 7 | #- DC: dmd 8 | # DVersion: nightly 9 | # arch: x86 10 | #- DC: dmd 11 | # DVersion: beta 12 | # arch: x64 13 | #- DC: dmd 14 | # DVersion: beta 15 | # arch: x86 16 | - DC: dmd 17 | DVersion: stable 18 | arch: x64 19 | - DC: dmd 20 | DVersion: stable 21 | arch: x86 22 | #- DC: ldc 23 | # DVersion: beta 24 | # arch: x86 25 | #- DC: ldc 26 | # DVersion: beta 27 | # arch: x64 28 | - DC: ldc 29 | DVersion: stable 30 | arch: x86 31 | - DC: ldc 32 | DVersion: stable 33 | arch: x64 34 | 35 | skip_tags: false 36 | branches: 37 | only: 38 | - master 39 | 40 | install: 41 | - ps: function ResolveLatestDMD 42 | { 43 | $version = $env:DVersion; 44 | if($version -eq "stable") { 45 | $latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString(); 46 | $url = "http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z"; 47 | }elseif($version -eq "beta") { 48 | $latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString(); 49 | $latestVersion = $latest.split("-")[0].split("~")[0]; 50 | $url = "http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z"; 51 | }elseif($version -eq "nightly") { 52 | $url = "http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z" 53 | }else { 54 | $url = "http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z"; 55 | } 56 | $env:PATH += ";C:\dmd2\windows\bin;"; 57 | return $url; 58 | } 59 | - ps: function ResolveLatestLDC 60 | { 61 | $version = $env:DVersion; 62 | $arch = $env:arch; 63 | if($version -eq "stable") { 64 | $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r",""); 65 | $url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-windows-$($arch).7z"; 66 | }elseif($version -eq "beta") { 67 | $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r",""); 68 | $url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-windows-$($arch).7z"; 69 | } else { 70 | $latest = $version; 71 | $url = "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-windows-$($arch).7z"; 72 | } 73 | $env:PATH += ";C:\ldc2-$($latest)-windows-$($arch)\bin"; 74 | $env:DC = "ldc2"; 75 | return $url; 76 | } 77 | - ps: function SetUpDCompiler 78 | { 79 | $env:toolchain = "msvc"; 80 | if($env:DC -eq "dmd"){ 81 | echo "downloading ..."; 82 | $url = ResolveLatestDMD; 83 | echo $url; 84 | Invoke-WebRequest $url -OutFile "c:\dmd.7z"; 85 | echo "finished."; 86 | pushd c:\\; 87 | 7z x dmd.7z > $null; 88 | popd; 89 | } 90 | elseif($env:DC -eq "ldc"){ 91 | echo "downloading ..."; 92 | $url = ResolveLatestLDC; 93 | echo $url; 94 | Invoke-WebRequest $url -OutFile "c:\ldc.zip"; 95 | echo "finished."; 96 | pushd c:\\; 97 | 7z x ldc.zip > $null; 98 | popd; 99 | } 100 | } 101 | - ps: SetUpDCompiler 102 | 103 | build_script: 104 | - ps: if($env:arch -eq "x86"){ 105 | $env:compilersetupargs = "x86"; 106 | $env:Darch = "x86"; 107 | $env:DConf = "m32"; 108 | }elseif($env:arch -eq "x64"){ 109 | $env:compilersetupargs = "amd64"; 110 | $env:Darch = "x86_64"; 111 | $env:DConf = "m64"; 112 | } 113 | - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall"; 114 | - '"%compilersetup%" %compilersetupargs%' 115 | 116 | test_script: 117 | - echo %PLATFORM% 118 | - echo %Darch% 119 | - echo %DC% 120 | - echo %PATH% 121 | - '%DC% --version' 122 | - dub test --arch=%Darch% --compiler=%DC% 123 | -------------------------------------------------------------------------------- /docs/articles/spec_differences.md: -------------------------------------------------------------------------------- 1 | # Differences between D:YAML and the YAML specification 2 | 3 | There are some differences between D:YAML and the YAML 1.1 4 | specification. Some are caused by difficulty of implementation of some 5 | features, such as multiple Unicode encodings within single stream, and 6 | some by unnecessary restrictions or ambiguities in the specification. 7 | 8 | Still, D:YAML tries to be as close to the specification as possible. It 9 | should never load documents with different meaning than according to the 10 | specification, and documents that fail to load should be very rare (for 11 | instance, very few files use multiple Unicode encodings). 12 | 13 | ## List of known differences: 14 | 15 | Differences that can cause valid YAML documents not to load: 16 | 17 | - No support for byte order marks and multiple Unicode encodings in a 18 | stream. 19 | 20 | - The specification does not restrict characters for anchors and 21 | aliases. This may lead to problems, for instance, the document: 22 | 23 | [ *alias, value ] 24 | 25 | can be interpteted in two ways, as: 26 | 27 | [ "value" ] 28 | 29 | and: 30 | 31 | [ *alias , "value" ] 32 | 33 | Therefore we restrict aliases and anchors to ASCII alphanumeric 34 | characters. 35 | 36 | - The specification is confusing about tabs in plain scalars. We don't 37 | use tabs in plain scalars at all. 38 | 39 | - There is no support for recursive data structures in DYAML. 40 | 41 | Other differences: 42 | 43 | - Indentation is ignored in the flow context, which is less 44 | restrictive than the specification. This allows code such as: 45 | 46 | key: { 47 | } 48 | 49 | - Indentation rules for quoted scalars are loosed: They don't need to 50 | adhere indentation as `"` and `'` clearly mark the beginning and the 51 | end of them. 52 | 53 | - We allow `_` in tag handles. 54 | 55 | - Right now, two mappings with the same contents but different 56 | orderings are considered unequal, even if they are unordered 57 | mappings. This is because all mappings are ordered in the D:YAML 58 | implementation. This should change in future, once D associative 59 | arrays work with variant types or a map class or struct appears in 60 | Phobos. 61 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Welcome to D:YAML documentation! 2 | 3 | API Documentation [online](https://dyaml.dpldocs.info/dyaml.html) 4 | 5 | Tutorials: 6 | - [Getting Started](tutorials/getting_started.md) 7 | - [Custom Types](tutorials/custom_types.md) 8 | - [YAML Syntax](tutorials/yaml_syntax.md) 9 | 10 | Articles: 11 | - [Spec Differences](articles/spec_differences.md) 12 | -------------------------------------------------------------------------------- /docs/logo128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlang-community/D-YAML/f1f07d22428295d7b40c113ec9cd933204b08d5b/docs/logo128.png -------------------------------------------------------------------------------- /docs/logo210.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dlang-community/D-YAML/f1f07d22428295d7b40c113ec9cd933204b08d5b/docs/logo210.png -------------------------------------------------------------------------------- /docs/tutorials/getting_started.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | Welcome to D:YAML\! D:YAML is a 4 | [YAML](http://en.wikipedia.org/wiki/YAML) parser library for the [D 5 | programming language](http://dlang.org). This tutorial will explain how 6 | to set D:YAML up and use it in your projects. 7 | 8 | This is meant to be the **simplest possible** introduction to D:YAML. 9 | Some of this information might already be known to you. Only basic usage 10 | is covered. 11 | 12 | ## Setting up 13 | 14 | ### Install the DMD compiler 15 | 16 | Digital Mars D compiler, or DMD, is the most commonly used D compiler. 17 | You can find its newest version [here](http://dlang.org/download.html). 18 | Download the version of DMD for your operating system and install it. 19 | 20 | Note: Other D compilers exist, such as [GDC](http://gdcproject.org/) and 21 | [LDC](https://github.com/ldc-developers/ldc). 22 | 23 | ## Your first D:YAML project 24 | 25 | First, create a directory for your project and navigate to that directory 26 | using your preferred command line. Then simply execute these two commands: 27 | 28 | dub init 29 | dub add dyaml 30 | 31 | In that directory, create a new file named `input.yaml` and paste this data 32 | into the file: 33 | 34 | ```YAML 35 | Hello World : [Hello, World] 36 | Answer: 42 37 | ``` 38 | 39 | This will serve as input for our example. 40 | 41 | Now we need to parse it. Open the file named `source/app.d` and paste the 42 | following code into the file: 43 | 44 | ```D 45 | import std.stdio; 46 | import dyaml; 47 | 48 | void main() 49 | { 50 | //Read the input. 51 | Node root = Loader.fromFile("input.yaml").load(); 52 | 53 | //Display the data read. 54 | foreach(string word; root["Hello World"]) 55 | { 56 | writeln(word); 57 | } 58 | writeln("The answer is ", root["Answer"].as!int); 59 | 60 | //Dump the loaded document to output.yaml. 61 | dumper.dump(File("output.yaml", "w").lockingTextWriter, root); 62 | } 63 | ``` 64 | 65 | ### Explanation of the code 66 | 67 | First, we import the *dyaml* module. This is the only D:YAML module 68 | you need to import - it automatically imports all needed modules. 69 | 70 | Next we load the file using the *Loader.fromFile().load()* method. *Loader* is a 71 | struct used for parsing YAML documents. The *fromFile()* method loads the 72 | document from a file. The *load()* method loads the 73 | file as **one** YAML document, or throws *YAMLException*, D:YAML 74 | exception type, if the file could not be parsed or contains more than 75 | one document. Note that we don't do any error checking here in order to 76 | keep the example as simple as possible. 77 | 78 | *Node* represents a node in a YAML document. It can be a sequence 79 | (array), mapping (associative array) or a scalar (value). Here the root 80 | node is a mapping, and we use the index operator to get subnodes with 81 | keys "Hello World" and "Answer". We iterate over the former, as it is a 82 | sequence, and use the *Node.as()* method on the latter to read its value 83 | as an integer. 84 | 85 | You can iterate over a mapping or sequence as if it was an associative 86 | or normal array, respectively. If you try to iterate over a scalar, it 87 | will throw a *YAMLException*. 88 | 89 | You can iterate using *Node* as the iterated type, or specify the type 90 | iterated nodes are expected to have. D:YAML will automatically convert 91 | to that type if possible. Here we specify the *string* type, so we 92 | iterate over the "Hello World" sequence as an array of strings. If it is 93 | not possible to convert to iterated type, a *YAMLException* is thrown. 94 | For instance, if we specified *int* here, we would get an error, as 95 | "Hello" cannot be converted to an integer. 96 | 97 | The *Node.as()* method is used to read value of a scalar node as 98 | specified type. If the scalar does not have the specified type, D:YAML 99 | will try to convert it, throwing *YAMLException* if not possible. 100 | 101 | Finally we dump the document we just read to `output.yaml` with the 102 | *Dumper.dump()* method. *Dumper* is a struct used to dump YAML 103 | documents. *dumper()* returns a *Dumper* with the default setting. 104 | The *dump()* method writes one or more documents to a range, 105 | throwing *YAMLException* if it could not be written to. 106 | 107 | D:YAML tries to preserve style information in documents so e.g. `[Hello, 108 | World]` is not turned into: 109 | 110 | ```YAML 111 | - Hello 112 | - World 113 | ``` 114 | 115 | However, comments are not preserved and neither are any extra formatting 116 | whitespace that doesn't affect the meaning of YAML contents. 117 | 118 | ### Compiling 119 | 120 | Run the following command in your project's directory: 121 | 122 | dub build 123 | 124 | DUB will automatically download D:YAML and compile it, and then it 125 | will compile our program. This will generate an executable called 126 | `getting-started` or `getting-started.exe` in your directory. When you 127 | run it, it should produce the following output: 128 | 129 | Hello 130 | World 131 | The answer is 42 132 | 133 | You may also run ```dub run``` to combine the compile+run steps. 134 | 135 | ### Conclusion 136 | 137 | You should now have a basic idea about how to use D:YAML. To learn more, 138 | look at the [API documentation](https://dyaml.dpldocs.info/dyaml.html) and other tutorials. 139 | You can find code for this example in the `example/getting_started` 140 | directory in the package. 141 | -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dyaml", 3 | "description": "YAML parser and emitter", 4 | "authors": [ 5 | "Ferdinand Majerech", 6 | "Cameron \"Herringway\" Ross" 7 | ], 8 | "license": "BSL-1.0", 9 | "dependencies": { 10 | "tinyendian" : "~>0.2.0" 11 | }, 12 | "homepage": "https://github.com/dlang-community/D-YAML", 13 | "copyright": "Copyright © 2011-2018, Ferdinand Majerech", 14 | "configurations": [ 15 | { "name": "library" }, 16 | { "name": "unittest" }, 17 | { 18 | "name": "unittest-dip1000", 19 | "dflags": [ "-preview=dip1000" ], 20 | "dependencies": { 21 | "tinyendian": { "version": "*", "dflags" : [ "-preview=dip1000" ] }, 22 | } 23 | } 24 | ], 25 | "subPackages": [ 26 | "examples/constructor", 27 | "examples/getting_started", 28 | "examples/representer", 29 | "examples/resolver", 30 | "examples/tojson", 31 | "examples/tokens", 32 | "examples/yaml_bench", 33 | "examples/yaml_gen", 34 | "examples/yaml_stats", 35 | "testsuite" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /examples/constructor/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "constructor", 3 | "targetType": "executable", 4 | "sourceFiles": ["main.d"], 5 | "mainSourceFile": "main.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*"} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/constructor/input.yaml: -------------------------------------------------------------------------------- 1 | scalar-red: !color FF0000 2 | scalar-orange: !color FFFF00 3 | mapping-red: !color-mapping {r: 255, g: 0, b: 0} 4 | mapping-orange: 5 | !color-mapping 6 | r: 255 7 | g: 255 8 | b: 0 9 | -------------------------------------------------------------------------------- /examples/constructor/main.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | import std.string; 3 | import dyaml; 4 | 5 | struct Color 6 | { 7 | ubyte red; 8 | ubyte green; 9 | ubyte blue; 10 | 11 | this(ubyte r, ubyte g, ubyte b) @safe 12 | { 13 | red = r; 14 | green = g; 15 | blue = b; 16 | } 17 | 18 | this(const Node node, string tag) @safe 19 | { 20 | if (tag == "!color-mapping") 21 | { 22 | //Will throw if a value is missing, is not an integer, or is out of range. 23 | red = node["r"].as!ubyte; 24 | green = node["g"].as!ubyte; 25 | blue = node["b"].as!ubyte; 26 | } 27 | else 28 | { 29 | string value = node.as!string; 30 | 31 | if(value.length != 6) 32 | { 33 | throw new Exception("Invalid color: " ~ value); 34 | } 35 | //We don't need to check for uppercase chars this way. 36 | value = value.toLower(); 37 | 38 | //Get value of a hex digit. 39 | uint hex(char c) 40 | { 41 | import std.ascii; 42 | if(!std.ascii.isHexDigit(c)) 43 | { 44 | throw new Exception("Invalid color: " ~ value); 45 | } 46 | 47 | if(std.ascii.isDigit(c)) 48 | { 49 | return c - '0'; 50 | } 51 | return c - 'a' + 10; 52 | } 53 | 54 | red = cast(ubyte)(16 * hex(value[0]) + hex(value[1])); 55 | green = cast(ubyte)(16 * hex(value[2]) + hex(value[3])); 56 | blue = cast(ubyte)(16 * hex(value[4]) + hex(value[5])); 57 | } 58 | } 59 | } 60 | 61 | void main(string[] args) 62 | { 63 | auto red = Color(255, 0, 0); 64 | auto orange = Color(255, 255, 0); 65 | 66 | string path = "input.yaml"; 67 | if (args.length > 1) 68 | { 69 | path = args[1]; 70 | } 71 | 72 | try 73 | { 74 | auto root = Loader.fromFile(path).load(); 75 | 76 | if(root["scalar-red"].as!Color == red && 77 | root["mapping-red"].as!Color == red && 78 | root["scalar-orange"].as!Color == orange && 79 | root["mapping-orange"].as!Color == orange) 80 | { 81 | writeln("SUCCESS"); 82 | return; 83 | } 84 | } 85 | catch(YAMLException e) 86 | { 87 | writeln(e.msg); 88 | } 89 | 90 | writeln("FAILURE"); 91 | } 92 | -------------------------------------------------------------------------------- /examples/getting_started/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "getting-started", 3 | "targetType": "executable", 4 | "sourceFiles": ["main.d"], 5 | "mainSourceFile": "main.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/getting_started/input.yaml: -------------------------------------------------------------------------------- 1 | Hello World : [Hello, World] 2 | Answer : 42 3 | -------------------------------------------------------------------------------- /examples/getting_started/main.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | import dyaml; 3 | 4 | void main() 5 | { 6 | //Read the input. 7 | Node root = Loader.fromFile("input.yaml").load(); 8 | 9 | //Display the data read. 10 | foreach(string word; root["Hello World"]) 11 | { 12 | writeln(word); 13 | } 14 | writeln("The answer is ", root["Answer"].as!int); 15 | 16 | //Dump the loaded document to output.yaml. 17 | dumper().dump(File("output.yaml", "w").lockingTextWriter, root); 18 | } 19 | -------------------------------------------------------------------------------- /examples/representer/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "representer", 3 | "targetType": "executable", 4 | "sourceFiles": ["main.d"], 5 | "mainSourceFile": "main.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/representer/main.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | import dyaml; 3 | 4 | struct Color 5 | { 6 | ubyte red; 7 | ubyte green; 8 | ubyte blue; 9 | 10 | Node opCast(T: Node)() const 11 | { 12 | static immutable hex = "0123456789ABCDEF"; 13 | 14 | //Using the color format from the Constructor example. 15 | string scalar; 16 | foreach(channel; [red, green, blue]) 17 | { 18 | scalar ~= hex[channel / 16]; 19 | scalar ~= hex[channel % 16]; 20 | } 21 | 22 | //Representing as a scalar, with custom tag to specify this data type. 23 | return Node(scalar, "!color"); 24 | } 25 | } 26 | 27 | void main() 28 | { 29 | try 30 | { 31 | auto dumper = dumper(); 32 | 33 | auto document = Node([Color(255, 0, 0), 34 | Color(0, 255, 0), 35 | Color(0, 0, 255)]); 36 | 37 | dumper.dump(File("output.yaml", "w").lockingTextWriter, document); 38 | } 39 | catch(YAMLException e) 40 | { 41 | writeln(e.msg); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/resolver/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resolver", 3 | "targetType": "executable", 4 | "sourceFiles": ["main.d"], 5 | "mainSourceFile": "main.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/resolver/input.yaml: -------------------------------------------------------------------------------- 1 | scalar-red: FF0000 2 | scalar-orange: FFFF00 3 | mapping-red: !color-mapping {r: 255, g: 0, b: 0} 4 | mapping-orange: 5 | !color-mapping 6 | r: 255 7 | g: 255 8 | b: 0 9 | -------------------------------------------------------------------------------- /examples/resolver/main.d: -------------------------------------------------------------------------------- 1 | import std.regex; 2 | import std.stdio; 3 | import dyaml; 4 | 5 | int main(string[] args) 6 | { 7 | string path = "input.yaml"; 8 | if (args.length > 1) 9 | { 10 | path = args[1]; 11 | } 12 | 13 | try 14 | { 15 | 16 | auto loader = Loader.fromFile("input.yaml"); 17 | loader.resolver.addImplicitResolver("!color", regex("[0-9a-fA-F]{6}"), 18 | "0123456789abcdefABCDEF"); 19 | 20 | auto root = loader.load(); 21 | 22 | if(root["scalar-red"].tag == "!color" && 23 | root["scalar-orange"].tag == "!color") 24 | { 25 | writeln("SUCCESS"); 26 | return 0; 27 | } 28 | } 29 | catch(YAMLException e) 30 | { 31 | writeln(e.msg); 32 | } 33 | 34 | writeln("FAILURE"); 35 | return 1; 36 | } 37 | -------------------------------------------------------------------------------- /examples/tojson/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tojson", 3 | "targetType": "executable", 4 | "dependencies": 5 | { 6 | "dyaml": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/tojson/source/app.d: -------------------------------------------------------------------------------- 1 | module dyaml.tojson; 2 | import std.datetime; 3 | import std.json; 4 | import std.stdio; 5 | import dyaml; 6 | 7 | void main() 8 | { 9 | auto doc = Loader.fromFile(stdin).load(); 10 | auto json = doc.toJSON; 11 | writeln(json.toPrettyString); 12 | } 13 | 14 | JSONValue toJSON(Node node) 15 | { 16 | JSONValue output; 17 | final switch (node.type) 18 | { 19 | case NodeType.sequence: 20 | output = JSONValue(string[].init); 21 | foreach (Node seqNode; node) 22 | { 23 | output.array ~= seqNode.toJSON(); 24 | } 25 | break; 26 | case NodeType.mapping: 27 | output = JSONValue(string[string].init); 28 | foreach (Node keyNode, Node valueNode; node) 29 | { 30 | output[keyNode.as!string] = valueNode.toJSON(); 31 | } 32 | break; 33 | case NodeType.string: 34 | output = node.as!string; 35 | break; 36 | case NodeType.integer: 37 | output = node.as!long; 38 | break; 39 | case NodeType.decimal: 40 | output = node.as!real; 41 | break; 42 | case NodeType.boolean: 43 | output = node.as!bool; 44 | break; 45 | case NodeType.timestamp: 46 | output = node.as!SysTime.toISOExtString(); 47 | break; 48 | case NodeType.merge: 49 | case NodeType.null_: 50 | case NodeType.binary: 51 | case NodeType.invalid: 52 | } 53 | return output; 54 | } 55 | -------------------------------------------------------------------------------- /examples/tokens/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tokens", 3 | "targetType": "executable", 4 | "dependencies": 5 | { 6 | "dyaml": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/tokens/source/app.d: -------------------------------------------------------------------------------- 1 | module dyaml.testsuite; 2 | 3 | import dyaml; 4 | import dyaml.event; 5 | import dyaml.parser; 6 | import dyaml.reader; 7 | import dyaml.scanner; 8 | 9 | import std.algorithm; 10 | import std.conv; 11 | import std.file; 12 | import std.format; 13 | import std.getopt; 14 | import std.json; 15 | import std.path; 16 | import std.range; 17 | import std.stdio; 18 | import std.string; 19 | import std.typecons; 20 | import std.utf; 21 | import std.uni; 22 | 23 | void dumpEventString(string str) @safe 24 | { 25 | auto events = new Parser(Scanner(Reader(cast(ubyte[])str.dup))); 26 | foreach (event; events) 27 | { 28 | writeln(event); 29 | } 30 | } 31 | void dumpTokens(string str) @safe 32 | { 33 | writefln("%(%s\n%)", new Parser(Scanner(Reader(cast(ubyte[])str.dup)))); 34 | } 35 | 36 | 37 | void main(string[] args) @system 38 | { 39 | bool tokens; 40 | getopt(args, 41 | "t|tokens", &tokens); 42 | string str; 43 | if (args[1] == "-") { 44 | str = cast(string)(stdin.byChunk(4096).joiner().array); 45 | } else { 46 | str = readText(args[1]); 47 | } 48 | if (tokens) { 49 | dumpTokens(str); 50 | } else { 51 | dumpEventString(str); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/yaml_bench/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "benchmark", 3 | "targetType": "executable", 4 | "sourceFiles": ["yaml_bench.d"], 5 | "mainSourceFile": "yaml_bench.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/yaml_gen/config.yaml: -------------------------------------------------------------------------------- 1 | root-type: map 2 | documents: 2 3 | complex-keys: false 4 | collection-keys: false 5 | min-nodes-per-document: 4096 6 | encoding: utf-8 7 | indent: 4 8 | text-width: 40 9 | 10 | #Note: setting collection probabilities too high can lead to stack overflow as 11 | #we end up with extremely deeply nested structures 12 | 13 | string: 14 | probability: 20 15 | alphabet: " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_0123456789ábćčďéěǵǧȟíǐǰḱǩĺľḿńňóǒôäṕŕřśšť" 16 | range: {min: 1, max: 40, dist: cubic} 17 | int: 18 | probability: 10 19 | range: {min: -10000000, max: 10000000, dist: linear} 20 | float: 21 | probability: 10 22 | range: {min: -10000000.0, max: 10000000.0, dist: linear} 23 | bool: 24 | probability: 10 25 | timestamp: 26 | probability: 10 27 | round-chance: 0.9 28 | range: {min: 0, max: 1231200000000000000, dist: linear} 29 | binary: 30 | probability: 4 31 | range: {min: 1, max: 400, dist: quadratic} 32 | map: 33 | probability: 2 34 | range: {min: 1, max: 20, dist: cubic} 35 | omap: 36 | probability: 1 37 | range: {min: 1, max: 20, dist: cubic} 38 | pairs: 39 | probability: 1 40 | range: {min: 1, max: 20, dist: cubic} 41 | seq: 42 | probability: 2 43 | range: {min: 1, max: 20, dist: cubic} 44 | set: 45 | probability: 1 46 | range: {min: 1, max: 20, dist: cubic} 47 | -------------------------------------------------------------------------------- /examples/yaml_gen/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yaml_gen", 3 | "targetType": "executable", 4 | "sourceFiles": ["yaml_gen.d"], 5 | "mainSourceFile": "yaml_gen.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/yaml_stats/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yaml_stats", 3 | "targetType": "executable", 4 | "sourceFiles": ["yaml_stats.d"], 5 | "mainSourceFile": "yaml_stats.d", 6 | "dependencies": 7 | { 8 | "dyaml": { "version" : "*" } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/yaml_stats/small.yaml: -------------------------------------------------------------------------------- 1 | - 1 2 | - 2 : 'a' 3 | 3 : 'b' 4 | - 4 : [1.0, 2.1, 3.2] 5 | -------------------------------------------------------------------------------- /examples/yaml_stats/yaml_stats.d: -------------------------------------------------------------------------------- 1 | 2 | ///Example D:YAML application that displays statistics about YAML documents. 3 | 4 | import std.stdio; 5 | import std.string; 6 | import dyaml; 7 | 8 | 9 | ///Collects statistics about a YAML document and returns them as string. 10 | string statistics(ref Node document) 11 | { 12 | size_t nodes; 13 | size_t scalars, sequences, mappings; 14 | size_t seqItems, mapPairs; 15 | 16 | size_t[string] tags; 17 | 18 | void crawl(ref Node root) 19 | { 20 | ++nodes; 21 | if((root.tag in tags) is null) 22 | { 23 | tags[root.tag] = 0; 24 | } 25 | ++tags[root.tag]; 26 | final switch (root.nodeID) 27 | { 28 | case NodeID.scalar: 29 | ++scalars; 30 | return; 31 | case NodeID.sequence: 32 | ++sequences; 33 | seqItems += root.length; 34 | foreach(ref Node node; root) 35 | { 36 | crawl(node); 37 | } 38 | return; 39 | case NodeID.mapping: 40 | ++mappings; 41 | mapPairs += root.length; 42 | foreach(ref Node key, ref Node value; root) 43 | { 44 | crawl(key); 45 | crawl(value); 46 | } 47 | return; 48 | case NodeID.invalid: 49 | assert(0); 50 | } 51 | } 52 | 53 | crawl(document); 54 | 55 | string tagStats = "\nTag statistics:\n"; 56 | foreach(tag, count; tags) 57 | { 58 | tagStats ~= format("\n%s : %s", tag, count); 59 | } 60 | 61 | return format( "\nNodes: %s" ~ 62 | "\n\nScalars: %s" ~ 63 | "\nSequences: %s" ~ 64 | "\nMappings: %s" ~ 65 | "\n\nAverage sequence length: %s" ~ 66 | "\nAverage mapping length: %s" ~ 67 | "\n\n%s", 68 | nodes, scalars, sequences, mappings, 69 | sequences == 0.0 ? 0.0 : cast(real)seqItems / sequences, 70 | mappings == 0.0 ? 0.0 : cast(real)mapPairs / mappings, 71 | tagStats); 72 | } 73 | 74 | void main(string[] args) 75 | { 76 | //Help message 77 | if(args.length == 1) 78 | { 79 | writeln("Usage: yaml_stats [YAML_FILE ...]\n"); 80 | writeln("Analyzes YAML files with provided filenames and displays statistics."); 81 | return; 82 | } 83 | 84 | //Print stats about every document in every file. 85 | foreach(file; args[1 .. $]) 86 | { 87 | writeln("\nFile ", file); 88 | writeln("------------------------------------------------------------"); 89 | try 90 | { 91 | auto loader = Loader.fromFile(file); 92 | 93 | size_t idx = 0; 94 | foreach(ref document; loader) 95 | { 96 | writeln("\nDocument ", idx++); 97 | writeln("----------------------------------------"); 98 | writeln(statistics(document)); 99 | } 100 | } 101 | catch(YAMLException e) 102 | { 103 | writeln("ERROR: ", e.msg); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /hmod.cfg: -------------------------------------------------------------------------------- 1 | 2 | # This file contains configuration options for harbored-mod (hmod). 3 | # 4 | # By default, hmod loads configuration from file 'hmod.cfg' in the directory from where 5 | # hmod is running, if such file exists. These configuration options can also be passed 6 | # as command-line options for hmod, overriding contents of the config file, if any, 7 | # with the exception of options that allow multiple values (such as 'exclude' or 8 | # 'macros') where the values specified as command-line options are *added* to the values 9 | # in config file. 10 | 11 | 12 | 13 | # Source code files or directories to document. Specify more than once to document more 14 | # files/directories, e.g: 15 | # 16 | # sources = ./sources 17 | # sources = ./thirdparty 18 | # 19 | # This will document both the source code in the ./source/ and ./thirdparty/ directories. 20 | # 21 | # For DUB (http://code.dlang.org) projects, './sources' is usually a good setting here. 22 | source = ./source/dyaml 23 | 24 | 25 | # Directory where the generated documentation will be written. 26 | output-directory = ./doc/html/api 27 | 28 | 29 | # Modules or packages to exclude from generated documentation. Specify more than once to 30 | # exclude more modules/packages, e.g: 31 | # 32 | # exclude = tharsis.util 33 | # exclude = tharsis.entity.gamestate 34 | # 35 | # This will exclude both the package (or module) tharsis.util and module (or package) 36 | # tharsis.entity.gamestate . 37 | 38 | exclude = dyaml.all 39 | exclude = dyaml.anchor 40 | exclude = dyaml.composer 41 | exclude = dyaml.emitter 42 | exclude = dyaml.encoding 43 | exclude = dyaml.escapes 44 | exclude = dyaml.event 45 | exclude = dyaml.fastcharsearch 46 | exclude = dyaml.flags 47 | exclude = dyaml.nogcutil 48 | exclude = dyaml.parser 49 | exclude = dyaml.queue 50 | exclude = dyaml.reader 51 | exclude = dyaml.scanner 52 | exclude = dyaml.serializer 53 | exclude = dyaml.streamcompat 54 | exclude = dyaml.tag 55 | exclude = dyaml.tagdirective 56 | exclude = dyaml.testcommon 57 | exclude = dyaml.testcompare 58 | exclude = dyaml.testconstructor 59 | exclude = dyaml.testemitter 60 | exclude = dyaml.testerrors 61 | exclude = dyaml.testinputoutput 62 | exclude = dyaml.testreader 63 | exclude = dyaml.testrepresenter 64 | exclude = dyaml.testresolver 65 | exclude = dyaml.testtokens 66 | exclude = dyaml.token 67 | exclude = dyaml.unused 68 | exclude = dyaml.zerostring 69 | 70 | # DDoc+markdown source of the main page of your documentation. Currently the main page is 71 | # blank by default; this can be used to fill it with something useful. 72 | 73 | index = 74 | 75 | 76 | # DDoc+markdown source of additional content to add to the table of contents sidebar. 77 | # Useful e.g. to add links to tutorials. 78 | 79 | toc-additional = 80 | 81 | 82 | # CSS file to use for styling. Can be used to replace the default style. 83 | # To create a new style, you can start by generating the default style file with 84 | # 'hmod --generate-css CSS_OUT_FILE' (CSS_OUT_FILE is name the generated file will have) 85 | # and then modifying the CSS to get the desired style. 86 | 87 | css = 88 | 89 | 90 | # File to load DDoc macros from. Can be used to override builtin macros or add new ones. 91 | # Can be specified more than once to use multiple macro files, e.g.: 92 | # 93 | # macros = macros.ddoc 94 | # macros = moremacros.ddoc 95 | 96 | 97 | macros = 98 | 99 | # Additional config file to load, if needed. Configuration options in specified file will 100 | # override or add to any options specified before this line, and will be overridden by 101 | # any options after this line. Think of it as including the config file in this file. 102 | 103 | config = 104 | 105 | 106 | 107 | #--------------------------------------------------------------------------- 108 | # Configuration options **only** useful for harbored-mod testing 109 | #--------------------------------------------------------------------------- 110 | # Uncommenting these will result in printing help information; only useful for testing. 111 | # 112 | # # Print help message. 113 | # 114 | # help 115 | # 116 | # 117 | # # Generate default CSS file and write it to specified file. 118 | # generate-css = hmod-style.css 119 | # 120 | # 121 | # # Generate default config file and write it to 'hmod.cfg'. 122 | # 123 | # generate-cfg 124 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('D-YAML', 'd', 2 | meson_version: '>=0.40.0', 3 | version: '0.10.0' 4 | ) 5 | 6 | project_soversion = '0' 7 | 8 | src_dir = include_directories('source/') 9 | pkgc = import('pkgconfig') 10 | 11 | d_compiler = meson.get_compiler('d') 12 | global_d_args = [] 13 | if d_compiler.get_id() == 'gcc' 14 | global_d_args += ['-fall-instantiations'] 15 | endif 16 | 17 | dyaml_src = [ 18 | 'source/dyaml/composer.d', 19 | 'source/dyaml/constructor.d', 20 | 'source/dyaml/dumper.d', 21 | 'source/dyaml/emitter.d', 22 | 'source/dyaml/encoding.d', 23 | 'source/dyaml/escapes.d', 24 | 'source/dyaml/event.d', 25 | 'source/dyaml/exception.d', 26 | 'source/dyaml/linebreak.d', 27 | 'source/dyaml/loader.d', 28 | 'source/dyaml/node.d', 29 | 'source/dyaml/package.d', 30 | 'source/dyaml/parser.d', 31 | 'source/dyaml/queue.d', 32 | 'source/dyaml/reader.d', 33 | 'source/dyaml/representer.d', 34 | 'source/dyaml/resolver.d', 35 | 'source/dyaml/scanner.d', 36 | 'source/dyaml/serializer.d', 37 | 'source/dyaml/style.d', 38 | 'source/dyaml/tagdirective.d', 39 | 'source/dyaml/test/constructor.d', 40 | 'source/dyaml/test/representer.d', 41 | 'source/dyaml/test/suite.d', 42 | 'source/dyaml/test/suitehelpers.d', 43 | 'source/dyaml/token.d', 44 | 'source/dyaml/stdsumtype.d' 45 | ] 46 | install_subdir('source/dyaml', install_dir: 'include/d/yaml/') 47 | 48 | tinyendian_dep = dependency('tinyendian', version: '>=0.2.0', fallback: ['tinyendian', 'tinyendian_dep']) 49 | 50 | dyaml_lib = library('dyaml', 51 | [dyaml_src], 52 | include_directories: [src_dir], 53 | dependencies: [tinyendian_dep], 54 | install: true, 55 | version: meson.project_version(), 56 | d_args: global_d_args, 57 | soversion: project_soversion 58 | ) 59 | pkgc.generate(name: 'dyaml', 60 | libraries: dyaml_lib, 61 | subdirs: 'd/yaml/', 62 | version: meson.project_version(), 63 | extra_cflags: global_d_args, 64 | description: 'YAML parser and emitter for the D programming language.' 65 | ) 66 | 67 | # Make D-YAML easy to use as subproject 68 | dyaml_dep = declare_dependency( 69 | link_with: dyaml_lib, 70 | include_directories: [src_dir], 71 | dependencies: [tinyendian_dep], 72 | compile_args: global_d_args, 73 | ) 74 | -------------------------------------------------------------------------------- /source/dyaml/encoding.d: -------------------------------------------------------------------------------- 1 | // Copyright Ferdinand Majerech 2014. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | module dyaml.encoding; 7 | 8 | 9 | import tinyendian; 10 | 11 | alias Encoding = tinyendian.UTFEncoding; 12 | -------------------------------------------------------------------------------- /source/dyaml/escapes.d: -------------------------------------------------------------------------------- 1 | 2 | 3 | // Copyright Ferdinand Majerech 2011. 4 | // Distributed under the Boost Software License, Version 1.0. 5 | // (See accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | module dyaml.escapes; 9 | 10 | package: 11 | 12 | import std.meta : AliasSeq; 13 | alias escapes = AliasSeq!('0', 'a', 'b', 't', '\t', 'n', 'v', 'f', 'r', 'e', ' ', 14 | '/', '\"', '\\', 'N', '_', 'L', 'P'); 15 | 16 | /// YAML hex codes specifying the length of the hex number. 17 | alias escapeHexCodeList = AliasSeq!('x', 'u', 'U'); 18 | 19 | /// Convert a YAML escape to a dchar. 20 | dchar fromEscape(dchar escape) @safe pure nothrow @nogc 21 | { 22 | switch(escape) 23 | { 24 | case '0': return '\0'; 25 | case 'a': return '\x07'; 26 | case 'b': return '\x08'; 27 | case 't': return '\x09'; 28 | case '\t': return '\x09'; 29 | case 'n': return '\x0A'; 30 | case 'v': return '\x0B'; 31 | case 'f': return '\x0C'; 32 | case 'r': return '\x0D'; 33 | case 'e': return '\x1B'; 34 | case '/': return '/'; 35 | case ' ': return '\x20'; 36 | case '\"': return '\"'; 37 | case '\\': return '\\'; 38 | case 'N': return '\x85'; //'\u0085'; 39 | case '_': return '\xA0'; 40 | case 'L': return '\u2028'; 41 | case 'P': return '\u2029'; 42 | default: assert(false, "No such YAML escape"); 43 | } 44 | } 45 | 46 | /** 47 | * Convert a dchar to a YAML escape. 48 | * 49 | * Params: 50 | * value = The possibly escapable character. 51 | * 52 | * Returns: 53 | * If the character passed as parameter can be escaped, returns the matching 54 | * escape, otherwise returns a null character. 55 | */ 56 | dchar toEscape(dchar value) @safe pure nothrow @nogc 57 | { 58 | switch(value) 59 | { 60 | case '\0': return '0'; 61 | case '\x07': return 'a'; 62 | case '\x08': return 'b'; 63 | case '\x09': return 't'; 64 | case '\x0A': return 'n'; 65 | case '\x0B': return 'v'; 66 | case '\x0C': return 'f'; 67 | case '\x0D': return 'r'; 68 | case '\x1B': return 'e'; 69 | case '\"': return '\"'; 70 | case '\\': return '\\'; 71 | case '\xA0': return '_'; 72 | case '\x85': return 'N'; 73 | case '\u2028': return 'L'; 74 | case '\u2029': return 'P'; 75 | default: return 0; 76 | } 77 | } 78 | 79 | /// Get the length of a hexadecimal number determined by its hex code. 80 | /// 81 | /// Need a function as associative arrays don't work with @nogc. 82 | /// (And this may be even faster with a function.) 83 | uint escapeHexLength(dchar hexCode) @safe pure nothrow @nogc 84 | { 85 | switch(hexCode) 86 | { 87 | case 'x': return 2; 88 | case 'u': return 4; 89 | case 'U': return 8; 90 | default: assert(false, "No such YAML hex code"); 91 | } 92 | } 93 | 94 | // Issue #302: Support optional escaping of forward slashes in string 95 | // for JSON compatibility 96 | @safe unittest 97 | { 98 | import dyaml.loader : Loader; 99 | 100 | const str = `{ 101 | "forward/slashes": "can\/be\/optionally\/escaped" 102 | }`; 103 | 104 | auto node = Loader.fromString(str).load(); 105 | assert(node["forward/slashes"] == "can/be/optionally/escaped"); 106 | } 107 | -------------------------------------------------------------------------------- /source/dyaml/exception.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Ferdinand Majerech 2011. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ///Exceptions thrown by D:YAML and _exception related code. 8 | module dyaml.exception; 9 | 10 | import std.algorithm; 11 | import std.array; 12 | import std.conv; 13 | import std.exception; 14 | import std.format; 15 | import std.range; 16 | import std.string; 17 | import std.typecons; 18 | 19 | 20 | /// Base class for all exceptions thrown by D:YAML. 21 | class YAMLException : Exception 22 | { 23 | mixin basicExceptionCtors; 24 | } 25 | 26 | /// Position in a YAML stream, used for error messages. 27 | struct Mark 28 | { 29 | /// File name. 30 | string name = ""; 31 | /// Line number. 32 | ushort line; 33 | /// Column number. 34 | ushort column; 35 | 36 | public: 37 | /// Construct a Mark with specified line and column in the file. 38 | this(string name, const uint line, const uint column) @safe pure nothrow @nogc 39 | { 40 | this.name = name; 41 | this.line = cast(ushort)min(ushort.max, line); 42 | // This *will* overflow on extremely wide files but saves CPU time 43 | // (mark ctor takes ~5% of time) 44 | this.column = cast(ushort)column; 45 | } 46 | 47 | /// Get a string representation of the mark. 48 | void toString(W)(ref W writer) const scope 49 | { 50 | // Line/column numbers start at zero internally, make them start at 1. 51 | void writeClamped(ushort v) 52 | { 53 | writer.formattedWrite!"%s"(v + 1); 54 | if (v == ushort.max) 55 | { 56 | put(writer, "or higher"); 57 | } 58 | } 59 | put(writer, name); 60 | put(writer, ":"); 61 | writeClamped(line); 62 | put(writer, ","); 63 | writeClamped(column); 64 | } 65 | } 66 | 67 | /// Base class of YAML exceptions with marked positions of the problem. 68 | abstract class MarkedYAMLException : YAMLException 69 | { 70 | /// Position of the error. 71 | Mark mark; 72 | /// Additional position information, usually the start of a token or scalar 73 | Nullable!Mark mark2; 74 | /// A label for the extra information 75 | string mark2Label; 76 | 77 | // Construct a MarkedYAMLException with two marks 78 | this(string context, const Mark mark, string mark2Label, const Nullable!Mark mark2, 79 | string file = __FILE__, size_t line = __LINE__) @safe pure nothrow 80 | { 81 | super(context, file, line); 82 | this.mark = mark; 83 | this.mark2 = mark2; 84 | this.mark2Label = mark2Label; 85 | } 86 | 87 | // Construct a MarkedYAMLException with specified problem. 88 | this(string msg, const Mark mark, 89 | string file = __FILE__, size_t line = __LINE__) 90 | @safe pure nothrow 91 | { 92 | super(msg, file, line); 93 | this.mark = mark; 94 | } 95 | 96 | /// Custom toString to add context without requiring allocation up-front 97 | void toString(W)(ref W sink) const 98 | { 99 | sink.formattedWrite!"%s@%s(%s): "(typeid(this).name, file, line); 100 | put(sink, msg); 101 | put(sink, "\n"); 102 | mark.toString(sink); 103 | if (!mark2.isNull) 104 | { 105 | put(sink, "\n"); 106 | put(sink, mark2Label); 107 | put(sink, ":"); 108 | mark2.get.toString(sink); 109 | } 110 | put(sink, "\n"); 111 | put(sink, info.toString()); 112 | } 113 | /// Ditto 114 | override void toString(scope void delegate(in char[]) sink) const 115 | { 116 | toString!(typeof(sink))(sink); 117 | } 118 | /// An override of message 119 | override const(char)[] message() const @safe nothrow 120 | { 121 | if (mark2.isNull) 122 | { 123 | return assertNotThrown(text(msg, "\n", mark)); 124 | } 125 | else 126 | { 127 | return assertNotThrown(text(msg, "\n", mark, "\n", mark2Label, ": ", mark2.get)); 128 | } 129 | } 130 | } 131 | 132 | /// Exception thrown on composer errors. 133 | class ComposerException : MarkedYAMLException 134 | { 135 | mixin MarkedExceptionCtors; 136 | } 137 | 138 | /// Exception thrown on constructor errors. 139 | class ConstructorException : MarkedYAMLException 140 | { 141 | mixin MarkedExceptionCtors; 142 | } 143 | 144 | /// Exception thrown on loader errors. 145 | class LoaderException : MarkedYAMLException 146 | { 147 | mixin MarkedExceptionCtors; 148 | } 149 | 150 | /// Exception thrown on node related errors. 151 | class NodeException : MarkedYAMLException 152 | { 153 | mixin MarkedExceptionCtors; 154 | } 155 | 156 | /// Exception thrown on parser errors. 157 | class ParserException : MarkedYAMLException 158 | { 159 | mixin MarkedExceptionCtors; 160 | } 161 | 162 | /// Exception thrown on Reader errors. 163 | class ReaderException : MarkedYAMLException 164 | { 165 | mixin MarkedExceptionCtors; 166 | } 167 | 168 | /// Exception thrown on Representer errors. 169 | class RepresenterException : YAMLException 170 | { 171 | mixin basicExceptionCtors; 172 | } 173 | 174 | /// Exception thrown on scanner errors. 175 | class ScannerException : MarkedYAMLException 176 | { 177 | mixin MarkedExceptionCtors; 178 | } 179 | 180 | private: 181 | 182 | /// Constructors of marked YAML exceptions are identical, so we use a mixin. 183 | /// 184 | /// See_Also: MarkedYAMLException 185 | template MarkedExceptionCtors() 186 | { 187 | public: 188 | this(string msg, const Mark mark1, string mark2Label, 189 | const Mark mark2, string file = __FILE__, size_t line = __LINE__) 190 | @safe pure nothrow 191 | { 192 | super(msg, mark1, mark2Label, Nullable!Mark(mark2), file, line); 193 | } 194 | 195 | this(string msg, const Mark mark, 196 | string file = __FILE__, size_t line = __LINE__) 197 | @safe pure nothrow 198 | { 199 | super(msg, mark, file, line); 200 | } 201 | this(string msg, const Mark mark1, string mark2Label, 202 | const Nullable!Mark mark2, string file = __FILE__, size_t line = __LINE__) 203 | @safe pure nothrow 204 | { 205 | super(msg, mark1, mark2Label, mark2, file, line); 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /source/dyaml/linebreak.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Ferdinand Majerech 2011. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module dyaml.linebreak; 8 | 9 | 10 | ///Enumerates platform specific line breaks. 11 | enum LineBreak 12 | { 13 | ///Unix line break ("\n"). 14 | unix, 15 | ///Windows line break ("\r\n"). 16 | windows, 17 | ///Macintosh line break ("\r"). 18 | macintosh 19 | } 20 | 21 | package: 22 | 23 | //Get line break string for specified line break. 24 | string lineBreak(in LineBreak b) pure @safe nothrow 25 | { 26 | final switch(b) 27 | { 28 | case LineBreak.unix: return "\n"; 29 | case LineBreak.windows: return "\r\n"; 30 | case LineBreak.macintosh: return "\r"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /source/dyaml/package.d: -------------------------------------------------------------------------------- 1 | // Copyright Ferdinand Majerech 2011. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | module dyaml; 7 | 8 | public import dyaml.dumper; 9 | public import dyaml.encoding; 10 | public import dyaml.exception; 11 | public import dyaml.linebreak; 12 | public import dyaml.loader; 13 | public import dyaml.resolver; 14 | public import dyaml.style; 15 | public import dyaml.node; 16 | -------------------------------------------------------------------------------- /source/dyaml/style.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Ferdinand Majerech 2011. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ///YAML node formatting styles. 8 | module dyaml.style; 9 | 10 | 11 | ///Scalar styles. 12 | enum ScalarStyle : ubyte 13 | { 14 | /// Invalid (uninitialized) style 15 | invalid = 0, 16 | /// `|` (Literal block style) 17 | literal, 18 | /// `>` (Folded block style) 19 | folded, 20 | /// Plain scalar 21 | plain, 22 | /// Single quoted scalar 23 | singleQuoted, 24 | /// Double quoted scalar 25 | doubleQuoted 26 | } 27 | 28 | ///Collection styles. 29 | enum CollectionStyle : ubyte 30 | { 31 | /// Invalid (uninitialized) style 32 | invalid = 0, 33 | /// Block style. 34 | block, 35 | /// Flow style. 36 | flow 37 | } 38 | -------------------------------------------------------------------------------- /source/dyaml/tagdirective.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Ferdinand Majerech 2011. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ///Tag directives. 8 | module dyaml.tagdirective; 9 | 10 | ///Single tag directive. handle is the shortcut, prefix is the prefix that replaces it. 11 | struct TagDirective 12 | { 13 | string handle; 14 | string prefix; 15 | } 16 | -------------------------------------------------------------------------------- /source/dyaml/test/representer.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Ferdinand Majerech 2011. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module dyaml.test.representer; 8 | 9 | @safe unittest 10 | { 11 | import std.array : Appender, array; 12 | import std.conv : text; 13 | import std.meta : AliasSeq; 14 | import std.path : baseName, stripExtension; 15 | import std.utf : toUTF8; 16 | 17 | import dyaml : dumper, Loader, Node; 18 | import dyaml.test.constructor : expected; 19 | 20 | /** 21 | Representer unittest. Dumps nodes, then loads them again. 22 | 23 | Params: 24 | baseName = Nodes in dyaml.test.constructor.expected for roundtripping. 25 | */ 26 | static void testRepresenterTypes(string baseName) @safe 27 | { 28 | assert((baseName in expected) !is null, "Unimplemented representer test: " ~ baseName); 29 | 30 | Node[] expectedNodes = expected[baseName]; 31 | foreach (encoding; AliasSeq!(char, wchar, dchar)) 32 | { 33 | auto emitStream = new Appender!(immutable(encoding)[]); 34 | auto dumper = dumper(); 35 | dumper.dump!encoding(emitStream, expectedNodes); 36 | 37 | immutable output = emitStream.data; 38 | 39 | auto loader = Loader.fromString(emitStream.data.toUTF8); 40 | loader.name = "TEST"; 41 | auto readNodes = loader.array; 42 | 43 | assert(expectedNodes == readNodes, text("Got '", readNodes, "', expected '", expectedNodes, "'")); 44 | } 45 | } 46 | foreach (key, _; expected) 47 | { 48 | testRepresenterTypes(key); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source/dyaml/token.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Ferdinand Majerech 2011-2014. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | /// YAML tokens. 8 | /// Code based on PyYAML: http://www.pyyaml.org 9 | module dyaml.token; 10 | 11 | 12 | import std.conv; 13 | 14 | import dyaml.encoding; 15 | import dyaml.exception; 16 | import dyaml.reader; 17 | import dyaml.style; 18 | 19 | 20 | package: 21 | 22 | /// Token types. 23 | enum TokenID : ubyte 24 | { 25 | // Invalid (uninitialized) token 26 | invalid = 0, 27 | directive, 28 | documentStart, 29 | documentEnd, 30 | streamStart, 31 | streamEnd, 32 | blockSequenceStart, 33 | blockMappingStart, 34 | blockEnd, 35 | flowSequenceStart, 36 | flowMappingStart, 37 | flowSequenceEnd, 38 | flowMappingEnd, 39 | key, 40 | value, 41 | blockEntry, 42 | flowEntry, 43 | alias_, 44 | anchor, 45 | tag, 46 | scalar 47 | } 48 | 49 | /// Specifies the type of a tag directive token. 50 | enum DirectiveType : ubyte 51 | { 52 | // YAML version directive. 53 | yaml, 54 | // Tag directive. 55 | tag, 56 | // Any other directive is "reserved" for future YAML versions. 57 | reserved 58 | } 59 | 60 | /// Token produced by scanner. 61 | /// 62 | /// 32 bytes on 64-bit. 63 | struct Token 64 | { 65 | // 16B 66 | /// Value of the token, if any. 67 | /// 68 | /// Values are char[] instead of string, as Parser may still change them in a few 69 | /// cases. Parser casts values to strings when producing Events. 70 | char[] value; 71 | // 4B 72 | /// Start position of the token in file/stream. 73 | Mark startMark; 74 | // 4B 75 | /// End position of the token in file/stream. 76 | Mark endMark; 77 | // 1B 78 | /// Token type. 79 | TokenID id; 80 | // 1B 81 | /// Style of scalar token, if this is a scalar token. 82 | ScalarStyle style; 83 | // 1B 84 | /// Encoding, if this is a stream start token. 85 | Encoding encoding; 86 | // 1B 87 | /// Type of directive for directiveToken. 88 | DirectiveType directive; 89 | // 4B 90 | /// Used to split value into 2 substrings for tokens that need 2 values (tagToken) 91 | uint valueDivider; 92 | 93 | /// Get string representation of the token ID. 94 | @property string idString() @safe pure const {return id.to!string;} 95 | } 96 | 97 | /// Construct a directive token. 98 | /// 99 | /// Params: start = Start position of the token. 100 | /// end = End position of the token. 101 | /// value = Value of the token. 102 | /// directive = Directive type (YAML or TAG in YAML 1.1). 103 | /// nameEnd = Position of the end of the name 104 | Token directiveToken(const Mark start, const Mark end, char[] value, 105 | DirectiveType directive, const uint nameEnd) @safe pure nothrow @nogc 106 | { 107 | return Token(value, start, end, TokenID.directive, ScalarStyle.init, Encoding.init, 108 | directive, nameEnd); 109 | } 110 | 111 | /// Construct a simple (no value) token with specified type. 112 | /// 113 | /// Params: id = Type of the token. 114 | /// start = Start position of the token. 115 | /// end = End position of the token. 116 | Token simpleToken(TokenID id)(const Mark start, const Mark end) 117 | { 118 | return Token(null, start, end, id); 119 | } 120 | 121 | /// Construct a stream start token. 122 | /// 123 | /// Params: start = Start position of the token. 124 | /// end = End position of the token. 125 | /// encoding = Encoding of the stream. 126 | Token streamStartToken(const Mark start, const Mark end, const Encoding encoding) @safe pure nothrow @nogc 127 | { 128 | return Token(null, start, end, TokenID.streamStart, ScalarStyle.invalid, encoding); 129 | } 130 | 131 | /// Aliases for construction of simple token types. 132 | alias streamEndToken = simpleToken!(TokenID.streamEnd); 133 | alias blockSequenceStartToken = simpleToken!(TokenID.blockSequenceStart); 134 | alias blockMappingStartToken = simpleToken!(TokenID.blockMappingStart); 135 | alias blockEndToken = simpleToken!(TokenID.blockEnd); 136 | alias keyToken = simpleToken!(TokenID.key); 137 | alias valueToken = simpleToken!(TokenID.value); 138 | alias blockEntryToken = simpleToken!(TokenID.blockEntry); 139 | alias flowEntryToken = simpleToken!(TokenID.flowEntry); 140 | 141 | /// Construct a simple token with value with specified type. 142 | /// 143 | /// Params: id = Type of the token. 144 | /// start = Start position of the token. 145 | /// end = End position of the token. 146 | /// value = Value of the token. 147 | /// valueDivider = A hack for TagToken to store 2 values in value; the first 148 | /// value goes up to valueDivider, the second after it. 149 | Token simpleValueToken(TokenID id)(const Mark start, const Mark end, char[] value, 150 | const uint valueDivider = uint.max) 151 | { 152 | return Token(value, start, end, id, ScalarStyle.invalid, Encoding.init, 153 | DirectiveType.init, valueDivider); 154 | } 155 | 156 | /// Alias for construction of tag token. 157 | alias tagToken = simpleValueToken!(TokenID.tag); 158 | alias aliasToken = simpleValueToken!(TokenID.alias_); 159 | alias anchorToken = simpleValueToken!(TokenID.anchor); 160 | 161 | /// Construct a scalar token. 162 | /// 163 | /// Params: start = Start position of the token. 164 | /// end = End position of the token. 165 | /// value = Value of the token. 166 | /// style = Style of the token. 167 | Token scalarToken(const Mark start, const Mark end, char[] value, const ScalarStyle style) @safe pure nothrow @nogc 168 | { 169 | return Token(value, start, end, TokenID.scalar, style); 170 | } 171 | -------------------------------------------------------------------------------- /subprojects/tinyendian.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | directory = tinyendian 3 | 4 | url = https://github.com/dlang-community/tinyendian.git 5 | revision = head 6 | -------------------------------------------------------------------------------- /test/a-nasty-libyaml-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: a-nasty-libyaml-bug 4 | fail: true 5 | mark: { line: 1, column: 4 } 6 | mark2: { line: 1, column: 4 } 7 | error: "While parsing a flow node, expected node content, but found: streamEnd" 8 | yaml: |- 9 | [ [ 10 | -------------------------------------------------------------------------------- /test/bmpchars.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: bmpchars 4 | yaml: "a: \U00012157" 5 | tree: | 6 | +STR 7 | +DOC 8 | +MAP 9 | =VAL :a 10 | =VAL :𒅗 11 | -MAP 12 | -DOC 13 | -STR 14 | - name: bmpchars-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- 18 | !!map { 19 | ? !!str "a" 20 | : !!str "\U00012157" 21 | } 22 | tree: | 23 | +STR 24 | +DOC --- 25 | +MAP {} 26 | =VAL "a 27 | =VAL "𒅗 28 | -MAP 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /test/colon-in-flow-context.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: colon-in-flow-context 4 | yaml: | 5 | { foo:bar } 6 | tree: | 7 | +STR 8 | +DOC 9 | +MAP {} 10 | =VAL :foo:bar 11 | =VAL : 12 | -MAP 13 | -DOC 14 | -STR 15 | -------------------------------------------------------------------------------- /test/composer.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: bool 4 | tags: dyaml composer 5 | detect: | 6 | tag:yaml.org,2002:bool 7 | tree: | 8 | +STR 9 | +DOC 10 | +SEQ 11 | =VAL :yes 12 | =VAL :NO 13 | =VAL :True 14 | =VAL :on 15 | -SEQ 16 | -DOC 17 | -STR 18 | yaml: | 19 | - yes 20 | - NO 21 | - True 22 | - on 23 | - name: float 24 | tags: dyaml composer 25 | detect: | 26 | tag:yaml.org,2002:float 27 | tree: | 28 | +STR 29 | +DOC 30 | +SEQ 31 | =VAL :6.8523015e+5 32 | =VAL :685.230_15e+03 33 | =VAL :685_230.15 34 | =VAL :190:20:30.15 35 | =VAL :-.inf 36 | =VAL :.NaN 37 | -SEQ 38 | -DOC 39 | -STR 40 | yaml: | 41 | - 6.8523015e+5 42 | - 685.230_15e+03 43 | - 685_230.15 44 | - 190:20:30.15 45 | - -.inf 46 | - .NaN 47 | - name: int 48 | tags: dyaml composer 49 | detect: | 50 | tag:yaml.org,2002:int 51 | tree: | 52 | +STR 53 | +DOC 54 | +SEQ 55 | =VAL :685230 56 | =VAL :+685_230 57 | =VAL :02472256 58 | =VAL :0x_0A_74_AE 59 | =VAL :0b1010_0111_0100_1010_1110 60 | =VAL :190:20:30 61 | -SEQ 62 | -DOC 63 | -STR 64 | yaml: | 65 | - 685230 66 | - +685_230 67 | - 02472256 68 | - 0x_0A_74_AE 69 | - 0b1010_0111_0100_1010_1110 70 | - 190:20:30 71 | - name: merge 72 | tags: dyaml composer 73 | detect: | 74 | tag:yaml.org,2002:merge 75 | tree: | 76 | +STR 77 | +DOC 78 | +SEQ 79 | =VAL :<< 80 | -SEQ 81 | -DOC 82 | -STR 83 | yaml: | 84 | - << 85 | - name: "null" 86 | tags: dyaml composer 87 | detect: | 88 | tag:yaml.org,2002:null 89 | tree: | 90 | +STR 91 | +DOC 92 | +SEQ 93 | =VAL : 94 | =VAL :~ 95 | =VAL :null 96 | -SEQ 97 | -DOC 98 | -STR 99 | yaml: | 100 | - 101 | - ~ 102 | - null 103 | - name: str 104 | tags: dyaml composer 105 | detect: | 106 | tag:yaml.org,2002:str 107 | tree: | 108 | +STR 109 | +DOC 110 | +SEQ 111 | =VAL :abcd 112 | =VAL :9a8b 113 | =VAL :9.1adsf 114 | -SEQ 115 | -DOC 116 | -STR 117 | yaml: | 118 | - abcd 119 | - 9a8b 120 | - 9.1adsf 121 | - name: timestamp 122 | tags: dyaml composer 123 | detect: | 124 | tag:yaml.org,2002:timestamp 125 | tree: | 126 | +STR 127 | +DOC 128 | +SEQ 129 | =VAL :2001-12-15T02:59:43.1Z 130 | =VAL :2001-12-14t21:59:43.10-05:00 131 | =VAL :2001-12-14 21:59:43.10 -5 132 | =VAL :2001-12-15 2:59:43.10 133 | =VAL :2002-12-14 134 | -SEQ 135 | -DOC 136 | -STR 137 | yaml: | 138 | - 2001-12-15T02:59:43.1Z 139 | - 2001-12-14t21:59:43.10-05:00 140 | - 2001-12-14 21:59:43.10 -5 141 | - 2001-12-15 2:59:43.10 142 | - 2002-12-14 143 | - name: uri 144 | tags: dyaml composer 145 | detect: "tag:example.com,2000:app/tag\U0001F914\n" 146 | tree: | 147 | +STR 148 | +DOC --- 149 | +SEQ 150 | =VAL :baz 151 | -SEQ 152 | -DOC 153 | -STR 154 | yaml: | 155 | %TAG !e! tag:example.com,2000:app/ 156 | --- 157 | - !e!tag%F0%9F%A4%94 baz 158 | - name: value 159 | tags: dyaml composer 160 | detect: | 161 | tag:yaml.org,2002:value 162 | tree: | 163 | +STR 164 | +DOC 165 | +SEQ 166 | =VAL := 167 | -SEQ 168 | -DOC 169 | -STR 170 | yaml: | 171 | - = 172 | -------------------------------------------------------------------------------- /test/document-separator-in-quoted-scalar.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: document-separator-in-quoted-scalar 4 | fail: true 5 | mark: { line: 10, column: 1 } 6 | mark2: { line: 8, column: 1 } 7 | error: "While scanning a quoted scalar, found unexpected document separator" 8 | yaml: | 9 | --- 10 | "this --- is correct" 11 | --- 12 | "this 13 | ...is also 14 | correct" 15 | --- 16 | "a quoted scalar 17 | cannot contain 18 | --- 19 | document separators" 20 | -------------------------------------------------------------------------------- /test/duplicate-errors.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: duplicate-anchor-1 4 | fail: true 5 | mark: { line: 3, column: 3 } 6 | mark2: { line: 1, column: 3 } 7 | error: | 8 | Unable to load test/duplicate-errors.yaml#duplicate-anchor-1:yaml: Found duplicate anchor: foo 9 | yaml: | 10 | - &foo bar 11 | - &bar bar 12 | - &foo bar 13 | - name: duplicate-anchor-2 14 | fail: true 15 | mark: { line: 1, column: 16 } 16 | mark2: { line: 1, column: 1 } 17 | error: | 18 | Unable to load test/duplicate-errors.yaml#duplicate-anchor-2:yaml: Found duplicate anchor: foo 19 | yaml: | 20 | &foo [1, 2, 3, &foo 4] 21 | - name: duplicate-mapping-key 22 | fail: true 23 | mark: { line: 2, column: 1 } 24 | mark2: { line: 1, column: 1 } 25 | error: | 26 | Unable to load test/duplicate-errors.yaml#duplicate-mapping-key:yaml: Key 'a' appears multiple times in mapping 27 | yaml: |- 28 | a: 1 29 | a: 2 30 | - name: duplicate-tag-directive 31 | fail: true 32 | mark: { line: 2, column: 1 } 33 | error: "Duplicate tag handle: !foo!" 34 | yaml: | 35 | %TAG !foo! bar 36 | %TAG !foo! baz 37 | --- foo 38 | - name: duplicate-yaml-directive 39 | fail: true 40 | mark: { line: 2, column: 1 } 41 | error: "Duplicate YAML directive" 42 | yaml: | 43 | %YAML 1.1 44 | %YAML 1.1 45 | --- foo 46 | -------------------------------------------------------------------------------- /test/emit-block-scalar-in-simple-key-context-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: emit-block-scalar-in-simple-key-context-bug 4 | yaml: | 5 | ? |- 6 | foo 7 | : |- 8 | bar 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL |foo 14 | =VAL |bar 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: emit-block-scalar-in-simple-key-context-bug-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- !!map 22 | { 23 | ? !!str "foo" 24 | : !!str "bar" 25 | } 26 | tree: | 27 | +STR 28 | +DOC --- 29 | +MAP {} 30 | =VAL "foo 31 | =VAL "bar 32 | -MAP 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /test/emojianchor.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: emojianchor 4 | yaml: | 5 | --- 6 | - &😁 unicode anchor 7 | tree: | 8 | +STR 9 | +DOC --- 10 | +SEQ 11 | =VAL &😁 :unicode anchor 12 | -SEQ 13 | -DOC 14 | -STR 15 | - name: emojianchor-canonical 16 | yaml: | 17 | %YAML 1.1 18 | --- 19 | !!seq [ 20 | &😁 !!str "unicode anchor" 21 | ] 22 | tree: | 23 | +STR 24 | +DOC --- 25 | +SEQ [] 26 | =VAL &😁 "unicode anchor 27 | -SEQ 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /test/empty-document-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: empty-document-bug 4 | yaml: "" 5 | tree: | 6 | +STR 7 | -STR 8 | - name: empty-document-bug-canonical 9 | yaml: | 10 | # This YAML stream contains no YAML documents. 11 | tree: | 12 | +STR 13 | -STR 14 | -------------------------------------------------------------------------------- /test/expected.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: expected-mapping 4 | fail: true 5 | mark: { line: 1, column: 5 } 6 | mark2: { line: 1, column: 24 } 7 | error: | 8 | Unable to load test/expected.yaml#expected-mapping:yaml: Error constructing Node[]: Only mappings can be maps 9 | yaml: | 10 | --- !!map [not, a, map] 11 | - name: expected-scalar 12 | fail: true 13 | mark: { line: 1, column: 5 } 14 | mark2: { line: 1, column: 25 } 15 | error: | 16 | Unable to load test/expected.yaml#expected-scalar:yaml: Error constructing Node[]: Only scalars can be strings 17 | yaml: | 18 | --- !!str [not a scalar] 19 | - name: expected-sequence 20 | fail: true 21 | mark: { line: 1, column: 5 } 22 | mark2: { line: 1, column: 26 } 23 | error: | 24 | Unable to load test/expected.yaml#expected-sequence:yaml: Error constructing Pair[]: Only sequences can be sequences 25 | yaml: | 26 | --- !!seq {foo, bar, baz} 27 | -------------------------------------------------------------------------------- /test/fetch-complex-value-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: fetch-complex-value-bug 4 | fail: true 5 | mark: { line: 2, column: 2 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While parsing a block mapping, expected block end, but found: blockMappingStart" 8 | yaml: | 9 | ? "foo" 10 | : "bar" 11 | -------------------------------------------------------------------------------- /test/forbidden.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: forbidden-entry 4 | fail: true 5 | mark: { line: 1, column: 7 } 6 | error: "Sequence keys are not allowed here" 7 | yaml: | 8 | test: - foo 9 | - bar 10 | - name: forbidden-key 11 | fail: true 12 | mark: { line: 1, column: 7 } 13 | error: "Mapping keys are not allowed here" 14 | yaml: | 15 | test: ? foo 16 | : bar 17 | - name: forbidden-value 18 | fail: true 19 | mark: { line: 1, column: 10 } 20 | error: "Mapping values are not allowed here" 21 | yaml: | 22 | test: key: value 23 | - name: forbidden-starting-character 24 | fail: true 25 | mark: { line: 1, column: 1 } 26 | error: "While scanning for the next token, found character '@', index 64 that cannot start any token" 27 | yaml: | 28 | @ 29 | -------------------------------------------------------------------------------- /test/multiline.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: end-of-buffer-multiline #Issue 309 - https://github.com/dlang-community/D-YAML/issues/309 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :exp 9 | =VAL |foobar 10 | -MAP 11 | -DOC 12 | -STR 13 | yaml: |- 14 | exp: | 15 | foobar 16 | -------------------------------------------------------------------------------- /test/no-block-collection-end.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: no-block-collection-end 4 | fail: true 5 | mark: { line: 3, column: 1 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While parsing a block sequence, expected block end, but found: key" 8 | yaml: | 9 | - foo 10 | - bar 11 | baz: bar 12 | -------------------------------------------------------------------------------- /test/no-block-mapping-end.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: no-block-mapping-end 4 | fail: true 5 | mark: { line: 1, column: 12 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While parsing a block mapping, expected block end, but found: scalar" 8 | yaml: | 9 | foo: "bar" "baz" 10 | - name: no-block-mapping-end-2 11 | fail: true 12 | mark: { line: 3, column: 1 } 13 | mark2: { line: 1, column: 1 } 14 | error: "While parsing a block mapping, expected block end, but found: value" 15 | yaml: | 16 | ? foo 17 | : bar 18 | : baz 19 | -------------------------------------------------------------------------------- /test/no-document-start.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: no-document-start 4 | fail: true 5 | mark: { line: 3, column: 1 } 6 | error: "Expected document start but found blockMappingStart" 7 | yaml: | 8 | %YAML 1.1 9 | # no --- 10 | foo: bar 11 | -------------------------------------------------------------------------------- /test/no-flow-mapping-end.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: no-flow-mapping-end 4 | fail: true 5 | mark: { line: 1, column: 12 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While parsing a flow mapping, expected ',' or '}', but got: flowSequenceEnd" 8 | yaml: | 9 | { foo: bar ] 10 | - name: no-flow-mapping-end-2 11 | fail: true 12 | mark: { line: 1, column: 2 } 13 | mark2: { line: 1, column: 2 } 14 | error: "While parsing a flow node, expected node content, but found: streamEnd" 15 | yaml: |- 16 | { 17 | - name: no-flow-mapping-end-3 18 | fail: true 19 | mark: { line: 1, column: 7 } 20 | mark2: { line: 1, column: 1 } 21 | error: "While parsing a flow mapping, expected ',' or '}', but got: streamEnd" 22 | yaml: |- 23 | { blah 24 | - name: no-flow-mapping-end-4 25 | fail: true 26 | mark: { line: 1, column: 7 } 27 | mark2: { line: 1, column: 1 } 28 | error: "While parsing a flow mapping, expected ',' or '}', but got: streamEnd" 29 | yaml: |- 30 | {a,b,c 31 | -------------------------------------------------------------------------------- /test/no-flow-sequence-end.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: no-flow-sequence-end 4 | fail: true 5 | mark: { line: 1, column: 10 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While parsing a flow sequence, expected ',' or ']', but got: flowMappingEnd" 8 | yaml: | 9 | [foo, bar} 10 | - name: no-flow-sequence-end-2 11 | fail: true 12 | mark: { line: 1, column: 2 } 13 | mark2: { line: 1, column: 2 } 14 | error: "While parsing a flow node, expected node content, but found: streamEnd" 15 | yaml: |- 16 | [ 17 | - name: no-flow-sequence-end-3 18 | fail: true 19 | mark: { line: 1, column: 7 } 20 | mark2: { line: 1, column: 1 } 21 | error: "While parsing a flow sequence, expected ',' or ']', but got: streamEnd" 22 | yaml: |- 23 | [ blah 24 | - name: no-flow-sequence-end-4 25 | fail: true 26 | mark: { line: 1, column: 7 } 27 | mark2: { line: 1, column: 1 } 28 | error: "While parsing a flow sequence, expected ',' or ']', but got: streamEnd" 29 | yaml: |- 30 | [a,b,c 31 | -------------------------------------------------------------------------------- /test/no-node.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: no-node-1 4 | fail: true 5 | mark: { line: 1, column: 8 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While parsing a block sequence, expected block end, but found: flowSequenceEnd" 8 | yaml: | 9 | - !foo ] 10 | - name: no-node-2 11 | fail: true 12 | mark: { line: 1, column: 10 } 13 | mark2: { line: 1, column: 3 } 14 | error: "While parsing a flow sequence, expected ',' or ']', but got: flowMappingEnd" 15 | yaml: | 16 | - [ !foo } ] 17 | -------------------------------------------------------------------------------- /test/question-mark-in-flow-context.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: question-mark-in-flow-context 4 | yaml: | 5 | { foo?bar } 6 | tree: | 7 | +STR 8 | +DOC 9 | +MAP {} 10 | =VAL :foo?bar 11 | =VAL : 12 | -MAP 13 | -DOC 14 | -STR 15 | -------------------------------------------------------------------------------- /test/recursive-alias.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: recursive-alias 4 | fail: true 5 | mark: { line: 2, column: 8 } 6 | mark2: { line: 1, column: 4 } 7 | error: | 8 | Unable to load test/recursive-alias.yaml#recursive-alias:yaml: Found recursive alias: anchor 9 | yaml: | 10 | a: &anchor { 11 | b: *anchor 12 | } 13 | -------------------------------------------------------------------------------- /test/remove-possible-simple-key-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: remove-possible-simple-key-bug 4 | fail: true 5 | mark: { line: 2, column: 4 } 6 | mark2: { line: 2, column: 1 } 7 | error: "While scanning a simple key, could not find expected ':'" 8 | yaml: | 9 | foo: &A bar 10 | *A ] # The ']' indicator triggers remove_possible_simple_key, 11 | # which should raise an error. 12 | -------------------------------------------------------------------------------- /test/run-parser-crash-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: run-parser-crash-bug 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +SEQ 8 | =VAL :Harry Potter and the Prisoner of Azkaban 9 | =VAL :Harry Potter and the Goblet of Fire 10 | =VAL :Harry Potter and the Order of the Phoenix 11 | -SEQ 12 | -DOC 13 | +DOC --- 14 | +SEQ 15 | =VAL :Memoirs Found in a Bathtub 16 | =VAL :Snow Crash 17 | =VAL :Ghost World 18 | -SEQ 19 | -DOC 20 | -STR 21 | yaml: | 22 | --- 23 | - Harry Potter and the Prisoner of Azkaban 24 | - Harry Potter and the Goblet of Fire 25 | - Harry Potter and the Order of the Phoenix 26 | --- 27 | - Memoirs Found in a Bathtub 28 | - Snow Crash 29 | - Ghost World 30 | -------------------------------------------------------------------------------- /test/scan-document-end-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: scan-document-end-bug 4 | yaml: |- 5 | # Ticket #4 6 | --- 7 | ... 8 | tree: | 9 | +STR 10 | +DOC --- 11 | =VAL : 12 | -DOC ... 13 | -STR 14 | - name: scan-document-end-bug-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- 18 | !!null "" 19 | tree: | 20 | +STR 21 | +DOC --- 22 | =VAL " 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /test/scan-line-break-bug.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: scan-line-break-bug 4 | yaml: "foo:\r\n bar\r\n baz\r\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | +MAP 9 | =VAL :foo 10 | =VAL :bar baz 11 | -MAP 12 | -DOC 13 | -STR 14 | - name: scan-line-break-bug-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- 18 | !!map { ? !!str "foo" : !!str "bar baz" } 19 | tree: | 20 | +STR 21 | +DOC --- 22 | +MAP {} 23 | =VAL "foo 24 | =VAL "bar baz 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /test/sloppy-indentation.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: sloppy-indentation 4 | yaml: "---\nin the block context:\n indentation should be kept: { \n but in\ 5 | \ the flow context: [\nit may be violated]\n}\n---\nthe parser does not require\ 6 | \ scalars\nto be indented with at least one space\n...\n---\n\"the parser does not\ 7 | \ require scalars\nto be indented with at least one space\"\n---\nfoo:\n bar:\ 8 | \ 'quoted scalars\nmay not adhere indentation'\n" 9 | - name: sloppy-indentation-canonical 10 | yaml: "%YAML 1.1\n---\n!!map { \n ? !!str \"in the block context\"\n \ 11 | \ : !!map {\n ? !!str \"indentation should be kept\"\n : !!map {\n\ 12 | \ ? !!str \"but in the flow context\"\n : !!seq [ !!str \"\ 13 | it may be violated\" ]\n }\n }\n}\n--- !!str\n\"the parser does not require\ 14 | \ scalars to be indented with at least one space\"\n--- !!str\n\"the parser does\ 15 | \ not require scalars to be indented with at least one space\"\n--- !!map\n{ ? !!str\ 16 | \ \"foo\": { ? !!str \"bar\" : !!str \"quoted scalars may not adhere indentation\"\ 17 | \ } }\n" 18 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-01.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-01 4 | tree: | 5 | +STR 6 | +DOC 7 | +SEQ 8 | =VAL :Mark McGwire 9 | =VAL :Sammy Sosa 10 | =VAL :Ken Griffey 11 | -SEQ 12 | -DOC 13 | -STR 14 | yaml: | 15 | - Mark McGwire 16 | - Sammy Sosa 17 | - Ken Griffey 18 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-02.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-02 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :hr 9 | =VAL :65 10 | =VAL :avg 11 | =VAL :0.278 12 | =VAL :rbi 13 | =VAL :147 14 | -MAP 15 | -DOC 16 | -STR 17 | yaml: | 18 | hr: 65 # Home runs 19 | avg: 0.278 # Batting average 20 | rbi: 147 # Runs Batted In 21 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-03 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :american 9 | +SEQ 10 | =VAL :Boston Red Sox 11 | =VAL :Detroit Tigers 12 | =VAL :New York Yankees 13 | -SEQ 14 | =VAL :national 15 | +SEQ 16 | =VAL :New York Mets 17 | =VAL :Chicago Cubs 18 | =VAL :Atlanta Braves 19 | -SEQ 20 | -MAP 21 | -DOC 22 | -STR 23 | yaml: | 24 | american: 25 | - Boston Red Sox 26 | - Detroit Tigers 27 | - New York Yankees 28 | national: 29 | - New York Mets 30 | - Chicago Cubs 31 | - Atlanta Braves 32 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-04 4 | tree: | 5 | +STR 6 | +DOC 7 | +SEQ 8 | +MAP 9 | =VAL :name 10 | =VAL :Mark McGwire 11 | =VAL :hr 12 | =VAL :65 13 | =VAL :avg 14 | =VAL :0.278 15 | -MAP 16 | +MAP 17 | =VAL :name 18 | =VAL :Sammy Sosa 19 | =VAL :hr 20 | =VAL :63 21 | =VAL :avg 22 | =VAL :0.288 23 | -MAP 24 | -SEQ 25 | -DOC 26 | -STR 27 | yaml: | 28 | - 29 | name: Mark McGwire 30 | hr: 65 31 | avg: 0.278 32 | - 33 | name: Sammy Sosa 34 | hr: 63 35 | avg: 0.288 36 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-05 4 | tree: | 5 | +STR 6 | +DOC 7 | +SEQ 8 | +SEQ [] 9 | =VAL :name 10 | =VAL :hr 11 | =VAL :avg 12 | -SEQ 13 | +SEQ [] 14 | =VAL :Mark McGwire 15 | =VAL :65 16 | =VAL :0.278 17 | -SEQ 18 | +SEQ [] 19 | =VAL :Sammy Sosa 20 | =VAL :63 21 | =VAL :0.288 22 | -SEQ 23 | -SEQ 24 | -DOC 25 | -STR 26 | yaml: | 27 | - [name , hr, avg ] 28 | - [Mark McGwire, 65, 0.278] 29 | - [Sammy Sosa , 63, 0.288] 30 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-06 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :Mark McGwire 9 | +MAP {} 10 | =VAL :hr 11 | =VAL :65 12 | =VAL :avg 13 | =VAL :0.278 14 | -MAP 15 | =VAL :Sammy Sosa 16 | +MAP {} 17 | =VAL :hr 18 | =VAL :63 19 | =VAL :avg 20 | =VAL :0.288 21 | -MAP 22 | -MAP 23 | -DOC 24 | -STR 25 | yaml: | 26 | Mark McGwire: {hr: 65, avg: 0.278} 27 | Sammy Sosa: { 28 | hr: 63, 29 | avg: 0.288 30 | } 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-07 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +SEQ 8 | =VAL :Mark McGwire 9 | =VAL :Sammy Sosa 10 | =VAL :Ken Griffey 11 | -SEQ 12 | -DOC 13 | +DOC --- 14 | +SEQ 15 | =VAL :Chicago Cubs 16 | =VAL :St Louis Cardinals 17 | -SEQ 18 | -DOC 19 | -STR 20 | yaml: | 21 | # Ranking of 1998 home runs 22 | --- 23 | - Mark McGwire 24 | - Sammy Sosa 25 | - Ken Griffey 26 | 27 | # Team ranking 28 | --- 29 | - Chicago Cubs 30 | - St Louis Cardinals 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-08 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :time 9 | =VAL :20:03:20 10 | =VAL :player 11 | =VAL :Sammy Sosa 12 | =VAL :action 13 | =VAL :strike (miss) 14 | -MAP 15 | -DOC ... 16 | +DOC --- 17 | +MAP 18 | =VAL :time 19 | =VAL :20:03:47 20 | =VAL :player 21 | =VAL :Sammy Sosa 22 | =VAL :action 23 | =VAL :grand slam 24 | -MAP 25 | -DOC ... 26 | -STR 27 | yaml: | 28 | --- 29 | time: 20:03:20 30 | player: Sammy Sosa 31 | action: strike (miss) 32 | ... 33 | --- 34 | time: 20:03:47 35 | player: Sammy Sosa 36 | action: grand slam 37 | ... 38 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-09.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-09 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :hr 9 | +SEQ 10 | =VAL :Mark McGwire 11 | =VAL :Sammy Sosa 12 | -SEQ 13 | =VAL :rbi 14 | +SEQ 15 | =VAL :Sammy Sosa 16 | =VAL :Ken Griffey 17 | -SEQ 18 | -MAP 19 | -DOC 20 | -STR 21 | yaml: | 22 | --- 23 | hr: # 1998 hr ranking 24 | - Mark McGwire 25 | - Sammy Sosa 26 | rbi: 27 | # 1998 rbi ranking 28 | - Sammy Sosa 29 | - Ken Griffey 30 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-10.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-10 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :hr 9 | +SEQ 10 | =VAL :Mark McGwire 11 | =VAL &SS :Sammy Sosa 12 | -SEQ 13 | =VAL :rbi 14 | +SEQ 15 | =ALI *SS 16 | =VAL :Ken Griffey 17 | -SEQ 18 | -MAP 19 | -DOC 20 | -STR 21 | yaml: | 22 | --- 23 | hr: 24 | - Mark McGwire 25 | # Following node labeled SS 26 | - &SS Sammy Sosa 27 | rbi: 28 | - *SS # Subsequent occurrence 29 | - Ken Griffey 30 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-11.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-11 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | +SEQ 9 | =VAL :Detroit Tigers 10 | =VAL :Chicago cubs 11 | -SEQ 12 | +SEQ 13 | =VAL :2001-07-23 14 | -SEQ 15 | +SEQ [] 16 | =VAL :New York Yankees 17 | =VAL :Atlanta Braves 18 | -SEQ 19 | +SEQ [] 20 | =VAL :2001-07-02 21 | =VAL :2001-08-12 22 | =VAL :2001-08-14 23 | -SEQ 24 | -MAP 25 | -DOC 26 | -STR 27 | yaml: | 28 | ? - Detroit Tigers 29 | - Chicago cubs 30 | : 31 | - 2001-07-23 32 | 33 | ? [ New York Yankees, 34 | Atlanta Braves ] 35 | : [ 2001-07-02, 2001-08-12, 36 | 2001-08-14 ] 37 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-12.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-12 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +SEQ 8 | +MAP 9 | =VAL :item 10 | =VAL :Super Hoop 11 | =VAL :quantity 12 | =VAL :1 13 | -MAP 14 | +MAP 15 | =VAL :item 16 | =VAL :Basketball 17 | =VAL :quantity 18 | =VAL :4 19 | -MAP 20 | +MAP 21 | =VAL :item 22 | =VAL :Big Shoes 23 | =VAL :quantity 24 | =VAL :1 25 | -MAP 26 | -SEQ 27 | -DOC 28 | -STR 29 | yaml: | 30 | --- 31 | # products purchased 32 | - item : Super Hoop 33 | quantity: 1 34 | - item : Basketball 35 | quantity: 4 36 | - item : Big Shoes 37 | quantity: 1 38 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-13.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-13 4 | tree: | 5 | +STR 6 | +DOC --- 7 | =VAL |\\//||\\/||\n// || ||__\n 8 | -DOC 9 | -STR 10 | yaml: | 11 | # ASCII Art 12 | --- | 13 | \//||\/|| 14 | // || ||__ 15 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-14.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-14 4 | tree: | 5 | +STR 6 | +DOC --- 7 | =VAL :Mark McGwire's year was crippled by a knee injury. 8 | -DOC 9 | -STR 10 | yaml: | 11 | --- 12 | Mark McGwire's 13 | year was crippled 14 | by a knee injury. 15 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-15.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-15 4 | tree: | 5 | +STR 6 | +DOC 7 | =VAL >Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n 8 | -DOC 9 | -STR 10 | yaml: | 11 | > 12 | Sammy Sosa completed another 13 | fine season with great stats. 14 | 15 | 63 Home Runs 16 | 0.288 Batting Average 17 | 18 | What a year! 19 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-16.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-16 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :name 9 | =VAL :Mark McGwire 10 | =VAL :accomplishment 11 | =VAL >Mark set a major league home run record in 1998.\n 12 | =VAL :stats 13 | =VAL |65 Home Runs\n0.278 Batting Average\n 14 | -MAP 15 | -DOC 16 | -STR 17 | yaml: | 18 | name: Mark McGwire 19 | accomplishment: > 20 | Mark set a major league 21 | home run record in 1998. 22 | stats: | 23 | 65 Home Runs 24 | 0.278 Batting Average 25 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-17.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-17 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :unicode 9 | =VAL "Sosa did fine.☺ 10 | =VAL :control 11 | =VAL "\b1998\t1999\t2000\n 12 | =VAL :hexesc 13 | =VAL "\r\n is \r\n 14 | =VAL :single 15 | =VAL '"Howdy!" he cried. 16 | =VAL :quoted 17 | =VAL ' # not a 'comment'. 18 | =VAL :tie-fighter 19 | =VAL '|\\-*-/| 20 | -MAP 21 | -DOC 22 | -STR 23 | yaml: | 24 | unicode: "Sosa did fine.\u263A" 25 | control: "\b1998\t1999\t2000\n" 26 | hexesc: "\x0D\x0A is \r\n" 27 | 28 | single: '"Howdy!" he cried.' 29 | quoted: ' # not a ''comment''.' 30 | tie-fighter: '|\-*-/|' 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-18.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-18 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :plain 9 | =VAL :This unquoted scalar spans many lines. 10 | =VAL :quoted 11 | =VAL "So does this quoted scalar.\n 12 | -MAP 13 | -DOC 14 | -STR 15 | yaml: | 16 | plain: 17 | This unquoted scalar 18 | spans many lines. 19 | 20 | quoted: "So does this 21 | quoted scalar.\n" 22 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-19.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-19 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :canonical 9 | =VAL :12345 10 | =VAL :decimal 11 | =VAL :+12,345 12 | =VAL :sexagesimal 13 | =VAL :3:25:45 14 | =VAL :octal 15 | =VAL :014 16 | =VAL :hexadecimal 17 | =VAL :0xC 18 | -MAP 19 | -DOC 20 | -STR 21 | yaml: | 22 | canonical: 12345 23 | decimal: +12,345 24 | sexagesimal: 3:25:45 25 | octal: 014 26 | hexadecimal: 0xC 27 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-20.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-20 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :canonical 9 | =VAL :1.23015e+3 10 | =VAL :exponential 11 | =VAL :12.3015e+02 12 | =VAL :sexagesimal 13 | =VAL :20:30.15 14 | =VAL :fixed 15 | =VAL :1,230.15 16 | =VAL :negative infinity 17 | =VAL :-.inf 18 | =VAL :not a number 19 | =VAL :.NaN 20 | -MAP 21 | -DOC 22 | -STR 23 | yaml: | 24 | canonical: 1.23015e+3 25 | exponential: 12.3015e+02 26 | sexagesimal: 20:30.15 27 | fixed: 1,230.15 28 | negative infinity: -.inf 29 | not a number: .NaN 30 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-21.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-21 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :null 9 | =VAL :~ 10 | =VAL :true 11 | =VAL :y 12 | =VAL :false 13 | =VAL :n 14 | =VAL :string 15 | =VAL '12345 16 | -MAP 17 | -DOC 18 | -STR 19 | yaml: | 20 | null: ~ 21 | true: y 22 | false: n 23 | string: '12345' 24 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-22.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-22 4 | tree: | 5 | +STR 6 | +DOC 7 | +MAP 8 | =VAL :canonical 9 | =VAL :2001-12-15T02:59:43.1Z 10 | =VAL :iso8601 11 | =VAL :2001-12-14t21:59:43.10-05:00 12 | =VAL :spaced 13 | =VAL :2001-12-14 21:59:43.10 -5 14 | =VAL :date 15 | =VAL :2002-12-14 16 | -MAP 17 | -DOC 18 | -STR 19 | yaml: | 20 | canonical: 2001-12-15T02:59:43.1Z 21 | iso8601: 2001-12-14t21:59:43.10-05:00 22 | spaced: 2001-12-14 21:59:43.10 -5 23 | date: 2002-12-14 24 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-23.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-23 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :not-date 9 | =VAL :2002-04-28 10 | =VAL :picture 11 | =VAL |R0lGODlhDAAMAIQAAP//9/X\n17unp5WZmZgAAAOfn515eXv\nPz7Y6OjuDg4J+fn5OTk6enp\n56enmleECcgggoBADs=\n 12 | =VAL :application specific tag 13 | =VAL |The semantics of the tag\nabove may be different for\ndifferent documents.\n 14 | -MAP 15 | -DOC 16 | -STR 17 | yaml: | 18 | --- 19 | not-date: !!str 2002-04-28 20 | 21 | picture: !!binary | 22 | R0lGODlhDAAMAIQAAP//9/X 23 | 17unp5WZmZgAAAOfn515eXv 24 | Pz7Y6OjuDg4J+fn5OTk6enp 25 | 56enmleECcgggoBADs= 26 | 27 | application specific tag: !something | 28 | The semantics of the tag 29 | above may be different for 30 | different documents. 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-24.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-24 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +SEQ 8 | +MAP 9 | =VAL :center 10 | +MAP {} &ORIGIN 11 | =VAL :x 12 | =VAL :73 13 | =VAL :y 14 | =VAL :129 15 | -MAP 16 | =VAL :radius 17 | =VAL :7 18 | -MAP 19 | +MAP 20 | =VAL :start 21 | =ALI *ORIGIN 22 | =VAL :finish 23 | +MAP {} 24 | =VAL :x 25 | =VAL :89 26 | =VAL :y 27 | =VAL :102 28 | -MAP 29 | -MAP 30 | +MAP 31 | =VAL :start 32 | =ALI *ORIGIN 33 | =VAL :color 34 | =VAL :0xFFEEBB 35 | =VAL :text 36 | =VAL :Pretty vector drawing. 37 | -MAP 38 | -SEQ 39 | -DOC 40 | -STR 41 | yaml: | 42 | %TAG ! tag:clarkevans.com,2002: 43 | --- !shape 44 | # Use the ! handle for presenting 45 | # tag:clarkevans.com,2002:circle 46 | - !circle 47 | center: &ORIGIN {x: 73, y: 129} 48 | radius: 7 49 | - !line 50 | start: *ORIGIN 51 | finish: { x: 89, y: 102 } 52 | - !label 53 | start: *ORIGIN 54 | color: 0xFFEEBB 55 | text: Pretty vector drawing. 56 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-25.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-25 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :Mark McGwire 9 | =VAL : 10 | =VAL :Sammy Sosa 11 | =VAL : 12 | =VAL :Ken Griff 13 | =VAL : 14 | -MAP 15 | -DOC 16 | -STR 17 | yaml: | 18 | # sets are represented as a 19 | # mapping where each key is 20 | # associated with the empty string 21 | --- !!set 22 | ? Mark McGwire 23 | ? Sammy Sosa 24 | ? Ken Griff 25 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-26.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-26 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +SEQ 8 | +MAP 9 | =VAL :Mark McGwire 10 | =VAL :65 11 | -MAP 12 | +MAP 13 | =VAL :Sammy Sosa 14 | =VAL :63 15 | -MAP 16 | +MAP 17 | =VAL :Ken Griffy 18 | =VAL :58 19 | -MAP 20 | -SEQ 21 | -DOC 22 | -STR 23 | yaml: | 24 | # ordered maps are represented as 25 | # a sequence of mappings, with 26 | # each mapping having one key 27 | --- !!omap 28 | - Mark McGwire: 65 29 | - Sammy Sosa: 63 30 | - Ken Griffy: 58 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-27.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-27 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :invoice 9 | =VAL :34843 10 | =VAL :date 11 | =VAL :2001-01-23 12 | =VAL :bill-to 13 | +MAP &id001 14 | =VAL :given 15 | =VAL :Chris 16 | =VAL :family 17 | =VAL :Dumars 18 | =VAL :address 19 | +MAP 20 | =VAL :lines 21 | =VAL |458 Walkman Dr.\nSuite #292\n 22 | =VAL :city 23 | =VAL :Royal Oak 24 | =VAL :state 25 | =VAL :MI 26 | =VAL :postal 27 | =VAL :48046 28 | -MAP 29 | -MAP 30 | =VAL :ship-to 31 | =ALI *id001 32 | =VAL :product 33 | +SEQ 34 | +MAP 35 | =VAL :sku 36 | =VAL :BL394D 37 | =VAL :quantity 38 | =VAL :4 39 | =VAL :description 40 | =VAL :Basketball 41 | =VAL :price 42 | =VAL :450.00 43 | -MAP 44 | +MAP 45 | =VAL :sku 46 | =VAL :BL4438H 47 | =VAL :quantity 48 | =VAL :1 49 | =VAL :description 50 | =VAL :Super Hoop 51 | =VAL :price 52 | =VAL :2392.00 53 | -MAP 54 | -SEQ 55 | =VAL :tax 56 | =VAL :251.42 57 | =VAL :total 58 | =VAL :4443.52 59 | =VAL :comments 60 | =VAL :Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. 61 | -MAP 62 | -DOC 63 | -STR 64 | yaml: | 65 | --- ! 66 | invoice: 34843 67 | date : 2001-01-23 68 | bill-to: &id001 69 | given : Chris 70 | family : Dumars 71 | address: 72 | lines: | 73 | 458 Walkman Dr. 74 | Suite #292 75 | city : Royal Oak 76 | state : MI 77 | postal : 48046 78 | ship-to: *id001 79 | product: 80 | - sku : BL394D 81 | quantity : 4 82 | description : Basketball 83 | price : 450.00 84 | - sku : BL4438H 85 | quantity : 1 86 | description : Super Hoop 87 | price : 2392.00 88 | tax : 251.42 89 | total: 4443.52 90 | comments: 91 | Late afternoon is best. 92 | Backup contact is Nancy 93 | Billsmer @ 338-4338. 94 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-02-28.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-02-28 4 | tree: | 5 | +STR 6 | +DOC --- 7 | +MAP 8 | =VAL :Time 9 | =VAL :2001-11-23 15:01:42 -5 10 | =VAL :User 11 | =VAL :ed 12 | =VAL :Warning 13 | =VAL :This is an error message for the log file 14 | -MAP 15 | -DOC 16 | +DOC --- 17 | +MAP 18 | =VAL :Time 19 | =VAL :2001-11-23 15:02:31 -5 20 | =VAL :User 21 | =VAL :ed 22 | =VAL :Warning 23 | =VAL :A slightly different error message. 24 | -MAP 25 | -DOC 26 | +DOC --- 27 | +MAP 28 | =VAL :Date 29 | =VAL :2001-11-23 15:03:17 -5 30 | =VAL :User 31 | =VAL :ed 32 | =VAL :Fatal 33 | =VAL :Unknown variable "bar" 34 | =VAL :Stack 35 | +SEQ 36 | +MAP 37 | =VAL :file 38 | =VAL :TopClass.py 39 | =VAL :line 40 | =VAL :23 41 | =VAL :code 42 | =VAL |x = MoreObject("345\\n")\n 43 | -MAP 44 | +MAP 45 | =VAL :file 46 | =VAL :MoreClass.py 47 | =VAL :line 48 | =VAL :58 49 | =VAL :code 50 | =VAL |foo = bar 51 | -MAP 52 | -SEQ 53 | -MAP 54 | -DOC 55 | -STR 56 | yaml: | 57 | --- 58 | Time: 2001-11-23 15:01:42 -5 59 | User: ed 60 | Warning: 61 | This is an error message 62 | for the log file 63 | --- 64 | Time: 2001-11-23 15:02:31 -5 65 | User: ed 66 | Warning: 67 | A slightly different error 68 | message. 69 | --- 70 | Date: 2001-11-23 15:03:17 -5 71 | User: ed 72 | Fatal: 73 | Unknown variable "bar" 74 | Stack: 75 | - file: TopClass.py 76 | line: 23 77 | code: | 78 | x = MoreObject("345\n") 79 | - file: MoreClass.py 80 | line: 58 81 | code: |- 82 | foo = bar 83 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-01-utf8.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-01-utf8 4 | yaml: | 5 | # Comment only. 6 | tree: | 7 | +STR 8 | -STR 9 | - name: spec-05-01-utf8-canonical 10 | yaml: "" 11 | tree: | 12 | +STR 13 | -STR 14 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-02-utf8.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-02-utf8 4 | #FIXME 5 | # error: | 6 | # ERROR: 7 | # A BOM must not appear 8 | # inside a document. 9 | yaml: "# Invalid use of BOM\n\uFEFF# inside a\n# document.\n" 10 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-03 4 | yaml: | 5 | sequence: 6 | - one 7 | - two 8 | mapping: 9 | ? sky 10 | : blue 11 | ? sea : green 12 | tree: | 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :sequence 17 | +SEQ 18 | =VAL :one 19 | =VAL :two 20 | -SEQ 21 | =VAL :mapping 22 | +MAP 23 | =VAL :sky 24 | =VAL :blue 25 | +MAP 26 | =VAL :sea 27 | =VAL :green 28 | -MAP 29 | =VAL : 30 | -MAP 31 | -MAP 32 | -DOC 33 | -STR 34 | - name: spec-05-03-canonical 35 | yaml: | 36 | %YAML 1.1 37 | --- 38 | !!map { 39 | ? !!str "sequence" 40 | : !!seq [ 41 | !!str "one", !!str "two" 42 | ], 43 | ? !!str "mapping" 44 | : !!map { 45 | ? !!str "sky" : !!str "blue", 46 | # ? !!str "sea" : !!str "green", 47 | ? !!map { ? !!str "sea" : !!str "green" } : !!null "", 48 | } 49 | } 50 | tree: | 51 | +STR 52 | +DOC --- 53 | +MAP {} 54 | =VAL "sequence 55 | +SEQ [] 56 | =VAL "one 57 | =VAL "two 58 | -SEQ 59 | =VAL "mapping 60 | +MAP {} 61 | =VAL "sky 62 | =VAL "blue 63 | +MAP {} 64 | =VAL "sea 65 | =VAL "green 66 | -MAP 67 | =VAL " 68 | -MAP 69 | -MAP 70 | -DOC 71 | -STR 72 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-04 4 | yaml: | 5 | sequence: [ one, two, ] 6 | mapping: { sky: blue, sea: green } 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :sequence 12 | +SEQ [] 13 | =VAL :one 14 | =VAL :two 15 | -SEQ 16 | =VAL :mapping 17 | +MAP {} 18 | =VAL :sky 19 | =VAL :blue 20 | =VAL :sea 21 | =VAL :green 22 | -MAP 23 | -MAP 24 | -DOC 25 | -STR 26 | - name: spec-05-04-canonical 27 | yaml: | 28 | %YAML 1.1 29 | --- 30 | !!map { 31 | ? !!str "sequence" 32 | : !!seq [ 33 | !!str "one", !!str "two" 34 | ], 35 | ? !!str "mapping" 36 | : !!map { 37 | ? !!str "sky" : !!str "blue", 38 | ? !!str "sea" : !!str "green", 39 | } 40 | } 41 | tree: | 42 | +STR 43 | +DOC --- 44 | +MAP {} 45 | =VAL "sequence 46 | +SEQ [] 47 | =VAL "one 48 | =VAL "two 49 | -SEQ 50 | =VAL "mapping 51 | +MAP {} 52 | =VAL "sky 53 | =VAL "blue 54 | =VAL "sea 55 | =VAL "green 56 | -MAP 57 | -MAP 58 | -DOC 59 | -STR 60 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-05 4 | yaml: | 5 | # Comment only. 6 | tree: | 7 | +STR 8 | -STR 9 | - name: spec-05-05-canonical 10 | yaml: "" 11 | tree: | 12 | +STR 13 | -STR 14 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-06 4 | yaml: | 5 | anchored: !local &anchor value 6 | alias: *anchor 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :anchored 12 | =VAL &anchor :value 13 | =VAL :alias 14 | =ALI *anchor 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: spec-05-06-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!map { 23 | ? !!str "anchored" 24 | : &A1 !local "value", 25 | ? !!str "alias" 26 | : *A1, 27 | } 28 | tree: | 29 | +STR 30 | +DOC --- 31 | +MAP {} 32 | =VAL "anchored 33 | =VAL &A1 "value 34 | =VAL "alias 35 | =ALI *A1 36 | -MAP 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-07 4 | yaml: | 5 | literal: | 6 | text 7 | folded: > 8 | text 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL :literal 14 | =VAL |text\n 15 | =VAL :folded 16 | =VAL >text\n 17 | -MAP 18 | -DOC 19 | -STR 20 | - name: spec-05-07-canonical 21 | yaml: | 22 | %YAML 1.1 23 | --- 24 | !!map { 25 | ? !!str "literal" 26 | : !!str "text\n", 27 | ? !!str "folded" 28 | : !!str "text\n", 29 | } 30 | tree: | 31 | +STR 32 | +DOC --- 33 | +MAP {} 34 | =VAL "literal 35 | =VAL "text\n 36 | =VAL "folded 37 | =VAL "text\n 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-08 4 | yaml: | 5 | single: 'text' 6 | double: "text" 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :single 12 | =VAL 'text 13 | =VAL :double 14 | =VAL "text 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: spec-05-08-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!map { 23 | ? !!str "single" 24 | : !!str "text", 25 | ? !!str "double" 26 | : !!str "text", 27 | } 28 | tree: | 29 | +STR 30 | +DOC --- 31 | +MAP {} 32 | =VAL "single 33 | =VAL "text 34 | =VAL "double 35 | =VAL "text 36 | -MAP 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-09.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-09 4 | yaml: | 5 | %YAML 1.1 6 | --- text 7 | tree: | 8 | +STR 9 | +DOC --- 10 | =VAL :text 11 | -DOC 12 | -STR 13 | - name: spec-05-09-canonical 14 | yaml: | 15 | %YAML 1.1 16 | --- 17 | !!str "text" 18 | tree: | 19 | +STR 20 | +DOC --- 21 | =VAL "text 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-10.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-10 4 | fail: true 5 | mark: { line: 1, column: 16 } 6 | error: | 7 | While scanning for the next token, found character '@', index 64 that cannot start any token 8 | yaml: | 9 | commercial-at: @text 10 | grave-accent: `text 11 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-11.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-11 4 | yaml: "|\n Generic line break (no glyph)\n Generic line break (glyphed)\N Line separator\L Paragraph separator\P" 5 | # FIXME 6 | # tree: | 7 | # +STR 8 | # +DOC 9 | # =VAL |Generic line break (no glyph)\nGeneric line break (glyphed)\nLine separator\LParagraph separator\P 10 | # -DOC 11 | # -STR 12 | - name: spec-05-11-canonical 13 | yaml: | 14 | %YAML 1.1 15 | --- !!str 16 | "Generic line break (no glyph)\n\ 17 | Generic line break (glyphed)\n\ 18 | Line separator\u2028\ 19 | Paragraph separator\u2029" 20 | # tree: | 21 | # +STR 22 | # +DOC --- 23 | # =VAL "Generic line break (no glyph)\nGeneric line break (glyphed)\nLine separator\LParagraph separator\P 24 | # -DOC 25 | # -STR 26 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-12.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-12 4 | fail: true 5 | mark: { line: 8, column: 11 } 6 | error: | 7 | While scanning for the next token, found character ' ', index 9 that cannot start any token 8 | yaml: "# Tabs do's and don'ts:\n# comment: \t\nquoted: \"Quoted\t\t\"\nblock: |\n\ 9 | \ void main() {\n \tprintf(\"Hello, world!\\n\");\n }\nelsewhere:\t# separation\n\ 10 | \tindentation, in\tplain scalar\n" 11 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-13.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-13 4 | yaml: " \"Text containing \n both space and\t\n \ttab\tcharacters\"\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL "Text containing both space and tab\tcharacters 9 | -DOC 10 | -STR 11 | - name: spec-05-13-canonical 12 | yaml: "%YAML 1.1\n--- !!str\n\"Text containing \\\n both space and \\\n tab\t\ 13 | characters\"\n" 14 | tree: | 15 | +STR 16 | +DOC --- 17 | =VAL "Text containing both space and tab\tcharacters 18 | -DOC 19 | -STR 20 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-14.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-14 4 | yaml: | 5 | "Fun with \\ 6 | \" \a \b \e \f \ 7 | \n \r \t \v \0 \
 \ \_ \N \L \P \
 \x41 \u0041 \U00000041" 8 | - name: spec-05-14-canonical 9 | yaml: | 10 | %YAML 1.1 11 | --- 12 | "Fun with \x5C 13 | \x22 \x07 \x08 \x1B \x0C 14 | \x0A \x0D \x09 \x0B \x00 15 | \x20 \xA0 \x85 \u2028 \u2029 16 | A A A" 17 | # FIXME 18 | # tree: | 19 | # +STR 20 | # +DOC --- 21 | # =VAL "Fun with \\ " \a \b \e \f \n \r \t \v \0 \_ \N \L \P A A A 22 | # -DOC 23 | # -STR 24 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-05-15.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-05-15 4 | fail: true 5 | mark: { line: 2, column: 5 } 6 | mark2: { line: 2, column: 3 } 7 | error: | 8 | While scanning a double quoted scalar, found unsupported escape character c 9 | yaml: | 10 | Bad escapes: 11 | "\c 12 | \xq-" 13 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-01.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-01 4 | yaml: " # Leading comment line spaces are\n # neither content nor indentation.\n\ 5 | \ \nNot indented:\n By one space: |\n By four\n spaces\n Flow style:\ 6 | \ [ # Leading spaces\n By two, # in flow style\n Also by two, #\ 7 | \ are neither\n# Tabs are not allowed:\n# \tStill by two # content nor\n Still\ 8 | \ by two # content nor\n ] # indentation.\n" 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL :Not indented 14 | +MAP 15 | =VAL :By one space 16 | =VAL |By four\n spaces\n 17 | =VAL :Flow style 18 | +SEQ [] 19 | =VAL :By two 20 | =VAL :Also by two 21 | =VAL :Still by two 22 | -SEQ 23 | -MAP 24 | -MAP 25 | -DOC 26 | -STR 27 | - name: spec-06-01-canonical 28 | yaml: | 29 | %YAML 1.1 30 | --- 31 | !!map { 32 | ? !!str "Not indented" 33 | : !!map { 34 | ? !!str "By one space" 35 | : !!str "By four\n spaces\n", 36 | ? !!str "Flow style" 37 | : !!seq [ 38 | !!str "By two", 39 | !!str "Also by two", 40 | !!str "Still by two", 41 | ] 42 | } 43 | } 44 | tree: | 45 | +STR 46 | +DOC --- 47 | +MAP {} 48 | =VAL "Not indented 49 | +MAP {} 50 | =VAL "By one space 51 | =VAL "By four\n spaces\n 52 | =VAL "Flow style 53 | +SEQ [] 54 | =VAL "By two 55 | =VAL "Also by two 56 | =VAL "Still by two 57 | -SEQ 58 | -MAP 59 | -MAP 60 | -DOC 61 | -STR 62 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-02.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-02 4 | yaml: " # Comment\n \n\n" 5 | tree: | 6 | +STR 7 | -STR 8 | - name: spec-06-02-canonical 9 | yaml: "" 10 | tree: | 11 | +STR 12 | -STR 13 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-03 4 | yaml: | 5 | key: # Comment 6 | value 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :key 12 | =VAL :value 13 | -MAP 14 | -DOC 15 | -STR 16 | - name: spec-06-03-canonical 17 | yaml: | 18 | %YAML 1.1 19 | --- 20 | !!map { 21 | ? !!str "key" 22 | : !!str "value" 23 | } 24 | tree: | 25 | +STR 26 | +DOC --- 27 | +MAP {} 28 | =VAL "key 29 | =VAL "value 30 | -MAP 31 | -DOC 32 | -STR 33 | 34 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-04 4 | yaml: |+ 5 | key: # Comment 6 | # lines 7 | value 8 | 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL :key 14 | =VAL :value 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: spec-06-04-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!map { 23 | ? !!str "key" 24 | : !!str "value" 25 | } 26 | tree: | 27 | +STR 28 | +DOC --- 29 | +MAP {} 30 | =VAL "key 31 | =VAL "value 32 | -MAP 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-05 4 | yaml: | 5 | { first: Sammy, last: Sosa }: 6 | # Statistics: 7 | hr: # Home runs 8 | 65 9 | avg: # Average 10 | 0.278 11 | tree: | 12 | +STR 13 | +DOC 14 | +MAP 15 | +MAP {} 16 | =VAL :first 17 | =VAL :Sammy 18 | =VAL :last 19 | =VAL :Sosa 20 | -MAP 21 | +MAP 22 | =VAL :hr 23 | =VAL :65 24 | =VAL :avg 25 | =VAL :0.278 26 | -MAP 27 | -MAP 28 | -DOC 29 | -STR 30 | - name: spec-06-05-canonical 31 | yaml: | 32 | %YAML 1.1 33 | --- 34 | !!map { 35 | ? !!map { 36 | ? !!str "first" 37 | : !!str "Sammy", 38 | ? !!str "last" 39 | : !!str "Sosa" 40 | } 41 | : !!map { 42 | ? !!str "hr" 43 | : !!int "65", 44 | ? !!str "avg" 45 | : !!float "0.278" 46 | } 47 | } 48 | tree: | 49 | +STR 50 | +DOC --- 51 | +MAP {} 52 | +MAP {} 53 | =VAL "first 54 | =VAL "Sammy 55 | =VAL "last 56 | =VAL "Sosa 57 | -MAP 58 | +MAP {} 59 | =VAL "hr 60 | =VAL "65 61 | =VAL "avg 62 | =VAL "0.278 63 | -MAP 64 | -MAP 65 | -DOC 66 | -STR 67 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-06 4 | yaml: "plain: text\n lines\nquoted: \"text\n \tlines\"\nblock: |\n text\n \t\ 5 | lines\n" 6 | tree: | 7 | +STR 8 | +DOC 9 | +MAP 10 | =VAL :plain 11 | =VAL :text lines 12 | =VAL :quoted 13 | =VAL "text lines 14 | =VAL :block 15 | =VAL |text\n \tlines\n 16 | -MAP 17 | -DOC 18 | -STR 19 | - name: spec-06-06-canonical 20 | yaml: "%YAML 1.1\n---\n!!map {\n ? !!str \"plain\"\n : !!str \"text lines\"\ 21 | ,\n ? !!str \"quoted\"\n : !!str \"text lines\",\n ? !!str \"block\"\n : !!str\ 22 | \ \"text\\n \tlines\\n\"\n}\n" 23 | tree: | 24 | +STR 25 | +DOC --- 26 | +MAP {} 27 | =VAL "plain 28 | =VAL "text lines 29 | =VAL "quoted 30 | =VAL "text lines 31 | =VAL "block 32 | =VAL "text\n \tlines\n 33 | -MAP 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-07 4 | yaml: "- foo\n \n bar\n- |-\n foo\n \n bar\n \n" 5 | tree: | 6 | +STR 7 | +DOC 8 | +SEQ 9 | =VAL :foo\nbar 10 | =VAL |foo\n\nbar 11 | -SEQ 12 | -DOC 13 | -STR 14 | - name: spec-06-07-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- 18 | !!seq [ 19 | !!str "foo\nbar", 20 | !!str "foo\n\nbar" 21 | ] 22 | tree: | 23 | +STR 24 | +DOC --- 25 | +SEQ [] 26 | =VAL "foo\nbar 27 | =VAL "foo\n\nbar 28 | -SEQ 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-06-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-06-08 4 | yaml: ">-\n specific\L trimmed\N \N \N\N as\N space\n" 5 | - name: spec-06-08-canonical 6 | yaml: | 7 | %YAML 1.1 8 | --- !!str 9 | "specific\L\ 10 | trimmed\n\n\n\ 11 | as space" 12 | # FIXME 13 | # tree: | 14 | # +STR 15 | # +DOC --- 16 | # =VAL "specific\Ltrimmed\n\n\nas space 17 | # -DOC 18 | # -STR 19 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-01.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-01 4 | yaml: | 5 | %FOO bar baz # Should be ignored 6 | # with a warning. 7 | --- "foo" 8 | tree: | 9 | +STR 10 | +DOC --- 11 | =VAL "foo 12 | -DOC 13 | -STR 14 | - name: spec-07-01-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- !!str 18 | "foo" 19 | tree: | 20 | +STR 21 | +DOC --- 22 | =VAL "foo 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-02.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-02 4 | yaml: | 5 | %YAML 1.2 # Attempt parsing 6 | # with a warning 7 | --- 8 | "foo" 9 | tree: | 10 | +STR 11 | +DOC --- 12 | =VAL "foo 13 | -DOC 14 | -STR 15 | - name: spec-07-02-canonical 16 | yaml: | 17 | %YAML 1.1 18 | --- 19 | !!str "foo" 20 | tree: | 21 | +STR 22 | +DOC --- 23 | =VAL "foo 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-03 4 | fail: true 5 | mark: { line: 2, column: 1} 6 | error: | 7 | Duplicate YAML directive 8 | yaml: | 9 | %YAML 1.1 10 | %YAML 1.1 11 | foo 12 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-04 4 | yaml: | 5 | %TAG !yaml! tag:yaml.org,2002: 6 | --- 7 | !yaml!str "foo" 8 | tree: | 9 | +STR 10 | +DOC --- 11 | =VAL "foo 12 | -DOC 13 | -STR 14 | - name: spec-07-04-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- 18 | !!str "foo" 19 | tree: | 20 | +STR 21 | +DOC --- 22 | =VAL "foo 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-05 4 | fail: true 5 | mark: { line: 2, column: 1} 6 | error: | 7 | Duplicate tag handle: ! 8 | yaml: | 9 | %TAG ! !foo 10 | %TAG ! !foo 11 | bar 12 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-06 4 | yaml: | 5 | %TAG ! !foo 6 | %TAG !yaml! tag:yaml.org,2002: 7 | --- 8 | - !bar "baz" 9 | - !yaml!str "string" 10 | tree: | 11 | +STR 12 | +DOC --- 13 | +SEQ 14 | =VAL "baz 15 | =VAL "string 16 | -SEQ 17 | -DOC 18 | -STR 19 | - name: spec-07-06-canonical 20 | yaml: | 21 | %YAML 1.1 22 | --- 23 | !!seq [ 24 | ! "baz", 25 | ! "string" 26 | ] 27 | tree: | 28 | +STR 29 | +DOC --- 30 | +SEQ [] 31 | =VAL "baz 32 | =VAL "string 33 | -SEQ 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-07a 4 | yaml: | 5 | # Private application: 6 | !foo "bar" 7 | tree: | 8 | +STR 9 | +DOC 10 | =VAL "bar 11 | -DOC 12 | -STR 13 | - name: spec-07-07b 14 | yaml: | 15 | # Migrated to global: 16 | %TAG ! tag:ben-kiki.org,2000:app/ 17 | --- 18 | !foo "bar" 19 | tree: | 20 | +STR 21 | +DOC --- 22 | =VAL "bar 23 | -DOC 24 | -STR 25 | - name: spec-07-07a-canonical 26 | yaml: | 27 | %YAML 1.1 28 | --- 29 | ! "bar" 30 | tree: | 31 | +STR 32 | +DOC --- 33 | =VAL "bar 34 | -DOC 35 | -STR 36 | - name: spec-07-07b-canonical 37 | yaml: | 38 | %YAML 1.1 39 | --- 40 | ! "bar" 41 | tree: | 42 | +STR 43 | +DOC --- 44 | =VAL "bar 45 | -DOC 46 | -STR 47 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-08 4 | yaml: | 5 | # Explicitly specify default settings: 6 | %TAG ! ! 7 | %TAG !! tag:yaml.org,2002: 8 | # Named handles have no default: 9 | %TAG !o! tag:ben-kiki.org,2000: 10 | --- 11 | - !foo "bar" 12 | - !!str "string" 13 | - !o!type "baz" 14 | tree: | 15 | +STR 16 | +DOC --- 17 | +SEQ 18 | =VAL "bar 19 | =VAL "string 20 | =VAL "baz 21 | -SEQ 22 | -DOC 23 | -STR 24 | - name: spec-07-08-canonical 25 | yaml: | 26 | %YAML 1.1 27 | --- 28 | !!seq [ 29 | ! "bar", 30 | ! "string", 31 | ! "baz" 32 | ] 33 | tree: | 34 | +STR 35 | +DOC --- 36 | +SEQ [] 37 | =VAL "bar 38 | =VAL "string 39 | =VAL "baz 40 | -SEQ 41 | -DOC 42 | -STR 43 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-09.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-09 4 | yaml: | 5 | --- 6 | foo 7 | ... 8 | # Repeated end marker. 9 | ... 10 | --- 11 | bar 12 | # No end marker. 13 | --- 14 | baz 15 | ... 16 | tree: | 17 | +STR 18 | +DOC --- 19 | =VAL :foo 20 | -DOC ... 21 | +DOC --- 22 | =VAL :bar 23 | -DOC 24 | +DOC --- 25 | =VAL :baz 26 | -DOC ... 27 | -STR 28 | - name: spec-07-09-canonical 29 | yaml: | 30 | %YAML 1.1 31 | --- 32 | !!str "foo" 33 | --- 34 | !!str "bar" 35 | --- 36 | !!str "baz" 37 | tree: | 38 | +STR 39 | +DOC --- 40 | =VAL "foo 41 | -DOC 42 | +DOC --- 43 | =VAL "bar 44 | -DOC 45 | +DOC --- 46 | =VAL "baz 47 | -DOC 48 | -STR 49 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-10.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-10 4 | yaml: | 5 | "Root flow 6 | scalar" 7 | --- !!str > 8 | Root block 9 | scalar 10 | --- 11 | # Root collection: 12 | foo : bar 13 | ... # Is optional. 14 | --- 15 | # Explicit document may be empty. 16 | tree: | 17 | +STR 18 | +DOC 19 | =VAL "Root flow scalar 20 | -DOC 21 | +DOC --- 22 | =VAL >Root block scalar\n 23 | -DOC 24 | +DOC --- 25 | +MAP 26 | =VAL :foo 27 | =VAL :bar 28 | -MAP 29 | -DOC ... 30 | +DOC --- 31 | =VAL : 32 | -DOC 33 | -STR 34 | - name: spec-07-10-canonical 35 | yaml: | 36 | %YAML 1.1 37 | --- 38 | !!str "Root flow scalar" 39 | --- 40 | !!str "Root block scalar\n" 41 | --- 42 | !!map { 43 | ? !!str "foo" 44 | : !!str "bar" 45 | } 46 | --- 47 | #!!str "" 48 | !!null "" 49 | tree: | 50 | +STR 51 | +DOC --- 52 | =VAL "Root flow scalar 53 | -DOC 54 | +DOC --- 55 | =VAL "Root block scalar\n 56 | -DOC 57 | +DOC --- 58 | +MAP {} 59 | =VAL "foo 60 | =VAL "bar 61 | -MAP 62 | -DOC 63 | +DOC --- 64 | =VAL " 65 | -DOC 66 | -STR 67 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-11.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-11 4 | yaml: | 5 | # A stream may contain 6 | # no documents. 7 | tree: | 8 | +STR 9 | -STR 10 | - name: spec-07-11-canonical 11 | yaml: "" 12 | tree: | 13 | +STR 14 | -STR 15 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-12.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-12a 4 | yaml: | 5 | # Implicit document. Root 6 | # collection (mapping) node. 7 | foo : bar 8 | tree: | 9 | +STR 10 | +DOC 11 | +MAP 12 | =VAL :foo 13 | =VAL :bar 14 | -MAP 15 | -DOC 16 | -STR 17 | - name: spec-07-12a-canonical 18 | yaml: | 19 | %YAML 1.1 20 | --- 21 | !!map { 22 | ? !!str "foo" 23 | : !!str "bar" 24 | } 25 | tree: | 26 | +STR 27 | +DOC --- 28 | +MAP {} 29 | =VAL "foo 30 | =VAL "bar 31 | -MAP 32 | -DOC 33 | -STR 34 | - name: spec-07-12b 35 | yaml: | 36 | # Explicit document. Root 37 | # scalar (literal) node. 38 | --- | 39 | Text content 40 | tree: | 41 | +STR 42 | +DOC --- 43 | =VAL |Text content\n 44 | -DOC 45 | -STR 46 | - name: spec-07-12b-canonical 47 | yaml: | 48 | %YAML 1.1 49 | --- 50 | !!str "Text content\n" 51 | tree: | 52 | +STR 53 | +DOC --- 54 | =VAL "Text content\n 55 | -DOC 56 | -STR 57 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-07-13.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-07-13 4 | yaml: | 5 | ! "First document" 6 | --- 7 | !foo "No directives" 8 | %TAG ! !foo 9 | --- 10 | !bar "With directives" 11 | %YAML 1.1 12 | --- 13 | !baz "Reset settings" 14 | tree: | 15 | +STR 16 | +DOC 17 | =VAL "First document 18 | -DOC 19 | +DOC --- 20 | =VAL "No directives 21 | -DOC 22 | +DOC --- 23 | =VAL "With directives 24 | -DOC 25 | +DOC --- 26 | =VAL "Reset settings 27 | -DOC 28 | -STR 29 | - name: spec-07-13-canonical 30 | yaml: | 31 | %YAML 1.1 32 | --- 33 | !!str "First document" 34 | --- 35 | ! "No directives" 36 | --- 37 | ! "With directives" 38 | --- 39 | ! "Reset settings" 40 | tree: | 41 | +STR 42 | +DOC --- 43 | =VAL "First document 44 | -DOC 45 | +DOC --- 46 | =VAL "No directives 47 | -DOC 48 | +DOC --- 49 | =VAL "With directives 50 | -DOC 51 | +DOC --- 52 | =VAL "Reset settings 53 | -DOC 54 | -STR 55 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-01.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-01 4 | yaml: | 5 | !!str &a1 "foo" : !!str bar 6 | &a2 baz : *a1 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL &a1 "foo 12 | =VAL :bar 13 | =VAL &a2 :baz 14 | =ALI *a1 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: spec-08-01-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!map { 23 | ? &A1 !!str "foo" 24 | : !!str "bar", 25 | ? &A2 !!str "baz" 26 | : *A1 27 | } 28 | tree: | 29 | +STR 30 | +DOC --- 31 | +MAP {} 32 | =VAL &A1 "foo 33 | =VAL "bar 34 | =VAL &A2 "baz 35 | =ALI *A1 36 | -MAP 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-02.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-02 4 | yaml: | 5 | First occurrence: &anchor Value 6 | Second occurrence: *anchor 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :First occurrence 12 | =VAL &anchor :Value 13 | =VAL :Second occurrence 14 | =ALI *anchor 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: spec-08-02-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!map { 23 | ? !!str "First occurrence" 24 | : &A !!str "Value", 25 | ? !!str "Second occurrence" 26 | : *A 27 | } 28 | tree: | 29 | +STR 30 | +DOC --- 31 | +MAP {} 32 | =VAL "First occurrence 33 | =VAL &A "Value 34 | =VAL "Second occurrence 35 | =ALI *A 36 | -MAP 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-03 4 | yaml: | 5 | ! foo : 6 | ! baz 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :foo 12 | =VAL :baz 13 | -MAP 14 | -DOC 15 | -STR 16 | - name: spec-08-03-canonical 17 | yaml: | 18 | %YAML 1.1 19 | --- 20 | !!map { 21 | ? ! "foo" 22 | : ! "baz" 23 | } 24 | tree: | 25 | +STR 26 | +DOC --- 27 | +MAP {} 28 | =VAL "foo 29 | =VAL "baz 30 | -MAP 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-04 4 | yaml: | 5 | - ! foo 6 | - !<$:?> bar 7 | tree: | 8 | +STR 9 | +DOC 10 | +SEQ 11 | =VAL :foo 12 | =VAL <$:?> :bar 13 | -SEQ 14 | -DOC 15 | -STR 16 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-05 4 | yaml: | 5 | %TAG !o! tag:ben-kiki.org,2000: 6 | --- 7 | - !local foo 8 | - !!str bar 9 | - !o!type baz 10 | tree: | 11 | +STR 12 | +DOC --- 13 | +SEQ 14 | =VAL :foo 15 | =VAL :bar 16 | =VAL :baz 17 | -SEQ 18 | -DOC 19 | -STR 20 | - name: spec-08-05-canonical 21 | yaml: | 22 | %YAML 1.1 23 | --- 24 | !!seq [ 25 | ! "foo", 26 | ! "bar", 27 | ! "baz", 28 | ] 29 | tree: | 30 | +STR 31 | +DOC --- 32 | +SEQ [] 33 | =VAL "foo 34 | =VAL "bar 35 | =VAL "baz 36 | -SEQ 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-06 4 | fail: true 5 | mark: { line: 3, column: 4 } 6 | mark2: { line: 3, column: 3 } 7 | error: | 8 | While scanning a tag, expected a !, but found $ 9 | yaml: | 10 | %TAG !o! tag:ben-kiki.org,2000: 11 | --- 12 | - !$a!b foo 13 | - !o! bar 14 | - !h!type baz 15 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-07 4 | yaml: | 5 | # Assuming conventional resolution: 6 | - "12" 7 | - 12 8 | - ! 12 9 | tree: | 10 | +STR 11 | +DOC 12 | +SEQ 13 | =VAL "12 14 | =VAL :12 15 | =VAL :12 16 | -SEQ 17 | -DOC 18 | -STR 19 | - name: spec-08-07-canonical 20 | yaml: | 21 | %YAML 1.1 22 | --- 23 | !!seq [ 24 | ! "12", 25 | ! "12", 26 | # ! "12", 27 | ! "12", 28 | ] 29 | tree: | 30 | +STR 31 | +DOC --- 32 | +SEQ [] 33 | =VAL "12 34 | =VAL "12 35 | =VAL "12 36 | -SEQ 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-08 4 | yaml: | 5 | --- 6 | foo: 7 | "bar 8 | baz" 9 | --- 10 | "foo 11 | bar" 12 | --- 13 | foo 14 | bar 15 | --- | 16 | foo 17 | ... 18 | tree: | 19 | +STR 20 | +DOC --- 21 | +MAP 22 | =VAL :foo 23 | =VAL "bar baz 24 | -MAP 25 | -DOC 26 | +DOC --- 27 | =VAL "foo bar 28 | -DOC 29 | +DOC --- 30 | =VAL :foo bar 31 | -DOC 32 | +DOC --- 33 | =VAL |foo\n 34 | -DOC ... 35 | -STR 36 | - name: spec-08-08-canonical 37 | yaml: | 38 | %YAML 1.1 39 | --- 40 | !!map { 41 | ? !!str "foo" 42 | : !!str "bar baz" 43 | } 44 | --- 45 | !!str "foo bar" 46 | --- 47 | !!str "foo bar" 48 | --- 49 | !!str "foo\n" 50 | tree: | 51 | +STR 52 | +DOC --- 53 | +MAP {} 54 | =VAL "foo 55 | =VAL "bar baz 56 | -MAP 57 | -DOC 58 | +DOC --- 59 | =VAL "foo bar 60 | -DOC 61 | +DOC --- 62 | =VAL "foo bar 63 | -DOC 64 | +DOC --- 65 | =VAL "foo\n 66 | -DOC 67 | -STR 68 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-09.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-09 4 | yaml: | 5 | --- 6 | scalars: 7 | plain: !!str some text 8 | quoted: 9 | single: 'some text' 10 | double: "some text" 11 | collections: 12 | sequence: !!seq [ !!str entry, 13 | # Mapping entry: 14 | key: value ] 15 | mapping: { key: value } 16 | tree: | 17 | +STR 18 | +DOC --- 19 | +MAP 20 | =VAL :scalars 21 | +MAP 22 | =VAL :plain 23 | =VAL :some text 24 | =VAL :quoted 25 | +MAP 26 | =VAL :single 27 | =VAL 'some text 28 | =VAL :double 29 | =VAL "some text 30 | -MAP 31 | -MAP 32 | =VAL :collections 33 | +MAP 34 | =VAL :sequence 35 | +SEQ [] 36 | =VAL :entry 37 | +MAP {} 38 | =VAL :key 39 | =VAL :value 40 | -MAP 41 | -SEQ 42 | =VAL :mapping 43 | +MAP {} 44 | =VAL :key 45 | =VAL :value 46 | -MAP 47 | -MAP 48 | -MAP 49 | -DOC 50 | -STR 51 | - name: spec-08-09-canonical 52 | yaml: | 53 | %YAML 1.1 54 | --- !!map { 55 | ? !!str "scalars" : !!map { 56 | ? !!str "plain" 57 | : !!str "some text", 58 | ? !!str "quoted" 59 | : !!map { 60 | ? !!str "single" 61 | : !!str "some text", 62 | ? !!str "double" 63 | : !!str "some text" 64 | } }, 65 | ? !!str "collections" : !!map { 66 | ? !!str "sequence" : !!seq [ 67 | !!str "entry", 68 | !!map { 69 | ? !!str "key" : !!str "value" 70 | } ], 71 | ? !!str "mapping" : !!map { 72 | ? !!str "key" : !!str "value" 73 | } } } 74 | tree: | 75 | +STR 76 | +DOC --- 77 | +MAP {} 78 | =VAL "scalars 79 | +MAP {} 80 | =VAL "plain 81 | =VAL "some text 82 | =VAL "quoted 83 | +MAP {} 84 | =VAL "single 85 | =VAL "some text 86 | =VAL "double 87 | =VAL "some text 88 | -MAP 89 | -MAP 90 | =VAL "collections 91 | +MAP {} 92 | =VAL "sequence 93 | +SEQ [] 94 | =VAL "entry 95 | +MAP {} 96 | =VAL "key 97 | =VAL "value 98 | -MAP 99 | -SEQ 100 | =VAL "mapping 101 | +MAP {} 102 | =VAL "key 103 | =VAL "value 104 | -MAP 105 | -MAP 106 | -MAP 107 | -DOC 108 | -STR 109 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-10.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-10 4 | yaml: "block styles:\n scalars:\n literal: !!str |\n #!/usr/bin/perl\n\ 5 | \ print \"Hello, world!\\n\";\n folded: >\n This sentence\n is\ 6 | \ false.\n collections: !!map\n sequence: !!seq # Entry:\n - entry # Plain\n\ 7 | \ # Mapping entry:\n - key: value\n mapping: \n key: value\n" 8 | tree: | 9 | +STR 10 | +DOC 11 | +MAP 12 | =VAL :block styles 13 | +MAP 14 | =VAL :scalars 15 | +MAP 16 | =VAL :literal 17 | =VAL |#!/usr/bin/perl\nprint "Hello, world!\\n";\n 18 | =VAL :folded 19 | =VAL >This sentence is false.\n 20 | -MAP 21 | =VAL :collections 22 | +MAP 23 | =VAL :sequence 24 | +SEQ 25 | =VAL :entry 26 | +MAP 27 | =VAL :key 28 | =VAL :value 29 | -MAP 30 | -SEQ 31 | =VAL :mapping 32 | +MAP 33 | =VAL :key 34 | =VAL :value 35 | -MAP 36 | -MAP 37 | -MAP 38 | -MAP 39 | -DOC 40 | -STR 41 | - name: spec-08-10-canonical 42 | yaml: | 43 | %YAML 1.1 44 | --- 45 | !!map { 46 | ? !!str "block styles" : !!map { 47 | ? !!str "scalars" : !!map { 48 | ? !!str "literal" 49 | : !!str "#!/usr/bin/perl\n\ 50 | print \"Hello, 51 | world!\\n\";\n", 52 | ? !!str "folded" 53 | : !!str "This sentence 54 | is false.\n" 55 | }, 56 | ? !!str "collections" : !!map { 57 | ? !!str "sequence" : !!seq [ 58 | !!str "entry", 59 | !!map { 60 | ? !!str "key" : !!str "value" 61 | } 62 | ], 63 | ? !!str "mapping" : !!map { 64 | ? !!str "key" : !!str "value" 65 | } } } } 66 | tree: | 67 | +STR 68 | +DOC --- 69 | +MAP {} 70 | =VAL "block styles 71 | +MAP {} 72 | =VAL "scalars 73 | +MAP {} 74 | =VAL "literal 75 | =VAL "#!/usr/bin/perl\nprint "Hello, world!\\n";\n 76 | =VAL "folded 77 | =VAL "This sentence is false.\n 78 | -MAP 79 | =VAL "collections 80 | +MAP {} 81 | =VAL "sequence 82 | +SEQ [] 83 | =VAL "entry 84 | +MAP {} 85 | =VAL "key 86 | =VAL "value 87 | -MAP 88 | -SEQ 89 | =VAL "mapping 90 | +MAP {} 91 | =VAL "key 92 | =VAL "value 93 | -MAP 94 | -MAP 95 | -MAP 96 | -MAP 97 | -DOC 98 | -STR 99 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-11.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-11 4 | yaml: | 5 | First occurrence: &anchor Value 6 | Second occurrence: *anchor 7 | tree: | 8 | +STR 9 | +DOC 10 | +MAP 11 | =VAL :First occurrence 12 | =VAL &anchor :Value 13 | =VAL :Second occurrence 14 | =ALI *anchor 15 | -MAP 16 | -DOC 17 | -STR 18 | - name: spec-08-11-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!map { 23 | ? !!str "First occurrence" 24 | : &A !!str "Value", 25 | ? !!str "Second occurrence" 26 | : *A 27 | } 28 | tree: | 29 | +STR 30 | +DOC --- 31 | +MAP {} 32 | =VAL "First occurrence 33 | =VAL &A "Value 34 | =VAL "Second occurrence 35 | =ALI *A 36 | -MAP 37 | -DOC 38 | -STR 39 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-12.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-12 4 | yaml: | 5 | [ 6 | Without properties, 7 | &anchor "Anchored", 8 | !!str 'Tagged', 9 | *anchor, # Alias node 10 | !!str , # Empty plain scalar 11 | '', # Empty plain scalar 12 | ] 13 | tree: | 14 | +STR 15 | +DOC 16 | +SEQ [] 17 | =VAL :Without properties 18 | =VAL &anchor "Anchored 19 | =VAL 'Tagged 20 | =ALI *anchor 21 | =VAL : 22 | =VAL ' 23 | -SEQ 24 | -DOC 25 | -STR 26 | - name: spec-08-12-canonical 27 | yaml: | 28 | %YAML 1.1 29 | --- 30 | !!seq [ 31 | !!str "Without properties", 32 | &A !!str "Anchored", 33 | !!str "Tagged", 34 | *A, 35 | !!str "", 36 | !!str "", 37 | ] 38 | tree: | 39 | +STR 40 | +DOC --- 41 | +SEQ [] 42 | =VAL "Without properties 43 | =VAL &A "Anchored 44 | =VAL "Tagged 45 | =ALI *A 46 | =VAL " 47 | =VAL " 48 | -SEQ 49 | -DOC 50 | -STR 51 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-13.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-13 4 | yaml: | 5 | { 6 | ? foo :, 7 | ? : bar, 8 | } 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP {} 13 | =VAL :foo 14 | =VAL : 15 | =VAL : 16 | =VAL :bar 17 | -MAP 18 | -DOC 19 | -STR 20 | - name: spec-08-13-canonical 21 | yaml: | 22 | %YAML 1.1 23 | --- 24 | !!map { 25 | ? !!str "foo" 26 | # : !!str "", 27 | # ? !!str "" 28 | : !!null "", 29 | ? !!null "" 30 | : !!str "bar", 31 | } 32 | tree: | 33 | +STR 34 | +DOC --- 35 | +MAP {} 36 | =VAL "foo 37 | =VAL " 38 | =VAL " 39 | =VAL "bar 40 | -MAP 41 | -DOC 42 | -STR 43 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-14.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-14 4 | yaml: | 5 | - "flow in block" 6 | - > 7 | Block scalar 8 | - !!map # Block collection 9 | foo : bar 10 | tree: | 11 | +STR 12 | +DOC 13 | +SEQ 14 | =VAL "flow in block 15 | =VAL >Block scalar\n 16 | +MAP 17 | =VAL :foo 18 | =VAL :bar 19 | -MAP 20 | -SEQ 21 | -DOC 22 | -STR 23 | - name: spec-08-14-canonical 24 | yaml: | 25 | %YAML 1.1 26 | --- 27 | !!seq [ 28 | !!str "flow in block", 29 | !!str "Block scalar\n", 30 | !!map { 31 | ? !!str "foo" 32 | : !!str "bar" 33 | } 34 | ] 35 | tree: | 36 | +STR 37 | +DOC --- 38 | +SEQ [] 39 | =VAL "flow in block 40 | =VAL "Block scalar\n 41 | +MAP {} 42 | =VAL "foo 43 | =VAL "bar 44 | -MAP 45 | -SEQ 46 | -DOC 47 | -STR 48 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-08-15.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-08-15 4 | yaml: | 5 | - # Empty plain scalar 6 | - ? foo 7 | : 8 | ? 9 | : bar 10 | tree: | 11 | +STR 12 | +DOC 13 | +SEQ 14 | =VAL : 15 | +MAP 16 | =VAL :foo 17 | =VAL : 18 | =VAL : 19 | =VAL :bar 20 | -MAP 21 | -SEQ 22 | -DOC 23 | -STR 24 | - name: spec-08-15-canonical 25 | yaml: | 26 | %YAML 1.1 27 | --- 28 | !!seq [ 29 | !!null "", 30 | !!map { 31 | ? !!str "foo" 32 | : !!null "", 33 | ? !!null "" 34 | : !!str "bar", 35 | } 36 | ] 37 | tree: | 38 | +STR 39 | +DOC --- 40 | +SEQ [] 41 | =VAL " 42 | +MAP {} 43 | =VAL "foo 44 | =VAL " 45 | =VAL " 46 | =VAL "bar 47 | -MAP 48 | -SEQ 49 | -DOC 50 | -STR 51 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-01.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-01 4 | yaml: | 5 | "simple key" : { 6 | "also simple" : value, 7 | ? "not a 8 | simple key" : "any 9 | value" 10 | } 11 | tree: | 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL "simple key 16 | +MAP {} 17 | =VAL "also simple 18 | =VAL :value 19 | =VAL "not a simple key 20 | =VAL "any value 21 | -MAP 22 | -MAP 23 | -DOC 24 | -STR 25 | - name: spec-09-01-canonical 26 | yaml: | 27 | %YAML 1.1 28 | --- 29 | !!map { 30 | ? !!str "simple key" 31 | : !!map { 32 | ? !!str "also simple" 33 | : !!str "value", 34 | ? !!str "not a simple key" 35 | : !!str "any value" 36 | } 37 | } 38 | tree: | 39 | +STR 40 | +DOC --- 41 | +MAP {} 42 | =VAL "simple key 43 | +MAP {} 44 | =VAL "also simple 45 | =VAL "value 46 | =VAL "not a simple key 47 | =VAL "any value 48 | -MAP 49 | -MAP 50 | -DOC 51 | -STR 52 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-02.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-02 4 | yaml: " \"as space\t\n trimmed \n\n specific\L\n escaped\t\\\P \n none\"\n" 5 | - name: spec-09-02-canonical 6 | yaml: | 7 | %YAML 1.1 8 | --- 9 | !!str "as space \ 10 | trimmed\n\ 11 | specific\L\n\ 12 | escaped\t\n\ 13 | none" 14 | # FIXME 15 | # tree: | 16 | # +STR 17 | # +DOC --- 18 | # =VAL "as space trimmed\nspecific\L\nescaped\t\nnone 19 | # -DOC 20 | # -STR 21 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-03 4 | yaml: "- \"\n last\"\n- \" \t\n last\"\n- \" \tfirst\n last\"\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | +SEQ 9 | =VAL " last 10 | =VAL " last 11 | =VAL " \tfirst last 12 | -SEQ 13 | -DOC 14 | -STR 15 | - name: spec-09-03-canonical 16 | yaml: | 17 | %YAML 1.1 18 | --- 19 | !!seq [ 20 | !!str " last", 21 | !!str " last", 22 | !!str " \tfirst last", 23 | ] 24 | tree: | 25 | +STR 26 | +DOC --- 27 | +SEQ [] 28 | =VAL " last 29 | =VAL " last 30 | =VAL " \tfirst last 31 | -SEQ 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-04 4 | yaml: " \"first\n \tinner 1\t\n \\ inner 2 \\\n last\"\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL "first inner 1 inner 2 last 9 | -DOC 10 | -STR 11 | - name: spec-09-04-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!str "first \ 16 | inner 1 \ 17 | inner 2 \ 18 | last" 19 | tree: | 20 | +STR 21 | +DOC --- 22 | =VAL "first inner 1 inner 2 last 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-05 4 | yaml: "- \"first\n \t\"\n- \"first\n\n \tlast\"\n- \"first\n inner\n \\ \tlast\"\ 5 | \n" 6 | tree: | 7 | +STR 8 | +DOC 9 | +SEQ 10 | =VAL "first 11 | =VAL "first\nlast 12 | =VAL "first inner \tlast 13 | -SEQ 14 | -DOC 15 | -STR 16 | - name: spec-09-05-canonical 17 | yaml: | 18 | %YAML 1.1 19 | --- 20 | !!seq [ 21 | !!str "first ", 22 | !!str "first\nlast", 23 | !!str "first inner \tlast", 24 | ] 25 | tree: | 26 | +STR 27 | +DOC --- 28 | +SEQ [] 29 | =VAL "first 30 | =VAL "first\nlast 31 | =VAL "first inner \tlast 32 | -SEQ 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-06 4 | yaml: |2 5 | 'here''s to "quotes"' 6 | tree: | 7 | +STR 8 | +DOC 9 | =VAL 'here's to "quotes" 10 | -DOC 11 | -STR 12 | - name: spec-09-06-canonical 13 | yaml: | 14 | %YAML 1.1 15 | --- 16 | !!str "here's to \"quotes\"" 17 | tree: | 18 | +STR 19 | +DOC --- 20 | =VAL "here's to "quotes" 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-07 4 | yaml: | 5 | 'simple key' : { 6 | 'also simple' : value, 7 | ? 'not a 8 | simple key' : 'any 9 | value' 10 | } 11 | tree: | 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL 'simple key 16 | +MAP {} 17 | =VAL 'also simple 18 | =VAL :value 19 | =VAL 'not a simple key 20 | =VAL 'any value 21 | -MAP 22 | -MAP 23 | -DOC 24 | -STR 25 | - name: spec-09-07-canonical 26 | yaml: | 27 | %YAML 1.1 28 | --- 29 | !!map { 30 | ? !!str "simple key" 31 | : !!map { 32 | ? !!str "also simple" 33 | : !!str "value", 34 | ? !!str "not a simple key" 35 | : !!str "any value" 36 | } 37 | } 38 | tree: | 39 | +STR 40 | +DOC --- 41 | +MAP {} 42 | =VAL "simple key 43 | +MAP {} 44 | =VAL "also simple 45 | =VAL "value 46 | =VAL "not a simple key 47 | =VAL "any value 48 | -MAP 49 | -MAP 50 | -DOC 51 | -STR 52 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-08 4 | yaml: " 'as space\t\N trimmed \N\N specific\L\N none'\n" 5 | - name: spec-09-08-canonical 6 | yaml: | 7 | %YAML 1.1 8 | --- 9 | !!str "as space \ 10 | trimmed\n\ 11 | specific\L\n\ 12 | none" 13 | # FIXME 14 | # tree: | 15 | # +STR 16 | # +DOC --- 17 | # =VAL "as space trimmed\nspecific\L\nnone 18 | # -DOC 19 | # -STR 20 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-09.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-09 4 | yaml: "- '\n last'\n- ' \t\n last'\n- ' \tfirst\n last'\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | +SEQ 9 | =VAL ' last 10 | =VAL ' last 11 | =VAL ' \tfirst last 12 | -SEQ 13 | -DOC 14 | -STR 15 | - name: spec-09-09-canonical 16 | yaml: | 17 | %YAML 1.1 18 | --- 19 | !!seq [ 20 | !!str " last", 21 | !!str " last", 22 | !!str " \tfirst last", 23 | ] 24 | tree: | 25 | +STR 26 | +DOC --- 27 | +SEQ [] 28 | =VAL " last 29 | =VAL " last 30 | =VAL " \tfirst last 31 | -SEQ 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-10.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-10 4 | yaml: " 'first\n \tinner\t\n last'\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL 'first inner last 9 | -DOC 10 | -STR 11 | - name: spec-09-10-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!str "first \ 16 | inner \ 17 | last" 18 | tree: | 19 | +STR 20 | +DOC --- 21 | =VAL "first inner last 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-11.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-11 4 | yaml: "- 'first\n \t'\n- 'first\n\n \tlast'\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | +SEQ 9 | =VAL 'first 10 | =VAL 'first\nlast 11 | -SEQ 12 | -DOC 13 | -STR 14 | - name: spec-09-11-canonical 15 | yaml: | 16 | %YAML 1.1 17 | --- 18 | !!seq [ 19 | !!str "first ", 20 | !!str "first\nlast", 21 | ] 22 | tree: | 23 | +STR 24 | +DOC --- 25 | +SEQ [] 26 | =VAL "first 27 | =VAL "first\nlast 28 | -SEQ 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-12.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-12 4 | yaml: | 5 | # Outside flow collection: 6 | - ::std::vector 7 | - Up, up, and away! 8 | - -123 9 | # Inside flow collection: 10 | - [ '::std::vector', 11 | "Up, up, and away!", 12 | -123 ] 13 | tree: | 14 | +STR 15 | +DOC 16 | +SEQ 17 | =VAL :::std::vector 18 | =VAL :Up, up, and away! 19 | =VAL :-123 20 | +SEQ [] 21 | =VAL '::std::vector 22 | =VAL "Up, up, and away! 23 | =VAL :-123 24 | -SEQ 25 | -SEQ 26 | -DOC 27 | -STR 28 | - name: spec-09-12-canonical 29 | yaml: | 30 | %YAML 1.1 31 | --- 32 | !!seq [ 33 | !!str "::std::vector", 34 | !!str "Up, up, and away!", 35 | !!int "-123", 36 | !!seq [ 37 | !!str "::std::vector", 38 | !!str "Up, up, and away!", 39 | !!int "-123", 40 | ] 41 | ] 42 | tree: | 43 | +STR 44 | +DOC --- 45 | +SEQ [] 46 | =VAL "::std::vector 47 | =VAL "Up, up, and away! 48 | =VAL "-123 49 | +SEQ [] 50 | =VAL "::std::vector 51 | =VAL "Up, up, and away! 52 | =VAL "-123 53 | -SEQ 54 | -SEQ 55 | -DOC 56 | -STR 57 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-13.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-13 4 | yaml: | 5 | simple key : { 6 | also simple : value, 7 | ? not a 8 | simple key : any 9 | value 10 | } 11 | - name: spec-09-13-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!map { 16 | ? !!str "simple key" 17 | : !!map { 18 | ? !!str "also simple" 19 | : !!str "value", 20 | ? !!str "not a simple key" 21 | : !!str "any value" 22 | } 23 | } 24 | tree: | 25 | +STR 26 | +DOC --- 27 | +MAP {} 28 | =VAL "simple key 29 | +MAP {} 30 | =VAL "also simple 31 | =VAL "value 32 | =VAL "not a simple key 33 | =VAL "any value 34 | -MAP 35 | -MAP 36 | -DOC 37 | -STR 38 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-14.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-14 4 | mark: { line: 2, column: 6 } 5 | mark2: { line: 2, column: 5 } 6 | yaml: | 7 | --- 8 | --- ||| : foo 9 | ... >>>: bar 10 | --- 11 | [ 12 | --- 13 | , 14 | ... , 15 | { 16 | --- : 17 | ... # Nested 18 | } 19 | ] 20 | ... 21 | fail: true 22 | error: | 23 | While scanning a block scalar, expected a chomping or indentation indicator, but found | 24 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-15.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-15 4 | yaml: | 5 | --- 6 | "---" : foo 7 | ...: bar 8 | --- 9 | [ 10 | ---, 11 | ..., 12 | { 13 | ? --- 14 | : ... 15 | } 16 | ] 17 | ... 18 | tree: | 19 | +STR 20 | +DOC --- 21 | +MAP 22 | =VAL "--- 23 | =VAL :foo 24 | =VAL :... 25 | =VAL :bar 26 | -MAP 27 | -DOC 28 | +DOC --- 29 | +SEQ [] 30 | =VAL :--- 31 | =VAL :... 32 | +MAP {} 33 | =VAL :--- 34 | =VAL :... 35 | -MAP 36 | -SEQ 37 | -DOC ... 38 | -STR 39 | - name: spec-09-15-canonical 40 | yaml: | 41 | %YAML 1.1 42 | --- 43 | !!map { 44 | ? !!str "---" 45 | : !!str "foo", 46 | ? !!str "..." 47 | : !!str "bar" 48 | } 49 | --- 50 | !!seq [ 51 | !!str "---", 52 | !!str "...", 53 | !!map { 54 | ? !!str "---" 55 | : !!str "..." 56 | } 57 | ] 58 | tree: | 59 | +STR 60 | +DOC --- 61 | +MAP {} 62 | =VAL "--- 63 | =VAL "foo 64 | =VAL "... 65 | =VAL "bar 66 | -MAP 67 | -DOC 68 | +DOC --- 69 | +SEQ [] 70 | =VAL "--- 71 | =VAL "... 72 | +MAP {} 73 | =VAL "--- 74 | =VAL "... 75 | -MAP 76 | -SEQ 77 | -DOC 78 | -STR 79 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-16.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-16 4 | yaml: "# Tabs are confusing:\n# as space/trimmed/specific/none\n as space \N trimmed\ 5 | \ \N\N specific\L\N none\n" 6 | - name: spec-09-16-canonical 7 | yaml: | 8 | %YAML 1.1 9 | --- 10 | !!str "as space \ 11 | trimmed\n\ 12 | specific\L\n\ 13 | none" 14 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-17.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-17 4 | yaml: " first line \n \n more line\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL :first line\nmore line 9 | -DOC 10 | -STR 11 | - name: spec-09-17-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!str "first line\n\ 16 | more line" 17 | tree: | 18 | +STR 19 | +DOC --- 20 | =VAL "first line\nmore line 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-18.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-18 4 | yaml: | 5 | - | # Just the style 6 | literal 7 | - >1 # Indentation indicator 8 | folded 9 | - |+ # Chomping indicator 10 | keep 11 | 12 | - >-1 # Both indicators 13 | strip 14 | tree: | 15 | +STR 16 | +DOC 17 | +SEQ 18 | =VAL |literal\n 19 | =VAL > folded\n 20 | =VAL |keep\n\n 21 | =VAL > strip 22 | -SEQ 23 | -DOC 24 | -STR 25 | - name: spec-09-18-canonical 26 | yaml: | 27 | %YAML 1.1 28 | --- 29 | !!seq [ 30 | !!str "literal\n", 31 | !!str " folded\n", 32 | !!str "keep\n\n", 33 | !!str " strip", 34 | ] 35 | tree: | 36 | +STR 37 | +DOC --- 38 | +SEQ [] 39 | =VAL "literal\n 40 | =VAL " folded\n 41 | =VAL "keep\n\n 42 | =VAL " strip 43 | -SEQ 44 | -DOC 45 | -STR 46 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-19.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-19 4 | yaml: | 5 | - | 6 | literal 7 | - > 8 | folded 9 | tree: | 10 | +STR 11 | +DOC 12 | +SEQ 13 | =VAL |literal\n 14 | =VAL >folded\n 15 | -SEQ 16 | -DOC 17 | -STR 18 | - name: spec-09-19-canonical 19 | yaml: | 20 | %YAML 1.1 21 | --- 22 | !!seq [ 23 | !!str "literal\n", 24 | !!str "folded\n", 25 | ] 26 | tree: | 27 | +STR 28 | +DOC --- 29 | +SEQ [] 30 | =VAL "literal\n 31 | =VAL "folded\n 32 | -SEQ 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-20.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-20 4 | yaml: "- |\n detected\n- >\n \n \n # detected\n- |1\n explicit\n- >\n \t\n detected\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | +SEQ 9 | =VAL |detected\n 10 | =VAL >\n\n# detected\n 11 | =VAL | explicit\n 12 | =VAL >\t\ndetected\n 13 | -SEQ 14 | -DOC 15 | -STR 16 | - name: spec-09-20-canonical 17 | yaml: | 18 | %YAML 1.1 19 | --- 20 | !!seq [ 21 | !!str "detected\n", 22 | !!str "\n\n# detected\n", 23 | !!str " explicit\n", 24 | !!str "\t\ndetected\n", 25 | ] 26 | tree: | 27 | +STR 28 | +DOC --- 29 | +SEQ [] 30 | =VAL "detected\n 31 | =VAL "\n\n# detected\n 32 | =VAL " explicit\n 33 | =VAL "\t\ndetected\n 34 | -SEQ 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-21.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-21 4 | fail: true 5 | mark: { line: 3, column: 2 } 6 | mark2: { line: 1, column: 1 } 7 | error: | 8 | While parsing a block sequence, expected block end, but found: scalar 9 | yaml: "- |\n \n text\n- >\n text\n text\n- |1\n text\n" 10 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-22.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-22 4 | yaml: "strip: |-\n text\Pclip: |\n text\Nkeep: |+\n text\L" 5 | - name: spec-09-22-canonical 6 | yaml: | 7 | %YAML 1.1 8 | --- 9 | !!map { 10 | ? !!str "strip" 11 | : !!str "text", 12 | ? !!str "clip" 13 | : !!str "text\n", 14 | ? !!str "keep" 15 | : !!str "text\L", 16 | } 17 | # FIXME 18 | # tree: | 19 | # +STR 20 | # +DOC --- 21 | # +MAP {} 22 | # =VAL "strip 23 | # =VAL "text 24 | # =VAL "clip 25 | # =VAL "text\n 26 | # =VAL "keep 27 | # =VAL "text\L 28 | # -MAP 29 | # -DOC 30 | # -STR 31 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-23.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-23 4 | yaml: " # Strip\n # Comments:\nstrip: |-\n # text\P \L # Clip\n # comments:\n\ 5 | \Nclip: |\n # text\N \P # Keep\n # comments:\n\Nkeep: |+\n # text\L\N # Trail\n\ 6 | \ # comments.\n" 7 | - name: spec-09-23-canonical 8 | yaml: | 9 | %YAML 1.1 10 | --- 11 | !!map { 12 | ? !!str "strip" 13 | : !!str "# text", 14 | ? !!str "clip" 15 | : !!str "# text\n", 16 | ? !!str "keep" 17 | : !!str "# text\L\n", 18 | } 19 | # FIXME 20 | # tree: | 21 | # +STR 22 | # +DOC --- 23 | # +MAP {} 24 | # =VAL "strip 25 | # =VAL "# text 26 | # =VAL "clip 27 | # =VAL "# text\n 28 | # =VAL "keep 29 | # =VAL "# text\L\n 30 | # -MAP 31 | # -DOC 32 | # -STR 33 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-24.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-24 4 | yaml: |+ 5 | strip: >- 6 | 7 | clip: > 8 | 9 | keep: |+ 10 | 11 | # FIXME 12 | # tree: | 13 | # +STR 14 | # +DOC 15 | # +MAP 16 | # =VAL :strip 17 | # =VAL > 18 | # =VAL :clip 19 | # =VAL > 20 | # =VAL :keep 21 | # =VAL | 22 | # -MAP 23 | # -DOC 24 | # -STR 25 | - name: spec-09-24-canonical 26 | yaml: | 27 | %YAML 1.1 28 | --- 29 | !!map { 30 | ? !!str "strip" 31 | : !!str "", 32 | ? !!str "clip" 33 | : !!str "", 34 | ? !!str "keep" 35 | : !!str "\n", 36 | } 37 | tree: | 38 | +STR 39 | +DOC --- 40 | +MAP {} 41 | =VAL "strip 42 | =VAL " 43 | =VAL "clip 44 | =VAL " 45 | =VAL "keep 46 | =VAL "\n 47 | -MAP 48 | -DOC 49 | -STR 50 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-25.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-25 4 | yaml: "| # Simple block scalar\n literal\n \ttext\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL |literal\n\ttext\n 9 | -DOC 10 | -STR 11 | - name: spec-09-25-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!str "literal\n\ 16 | \ttext\n" 17 | tree: | 18 | +STR 19 | +DOC --- 20 | =VAL "literal\n\ttext\n 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-26.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-26 4 | yaml: "|\n \n \n literal\n \n text\n\n # Comment\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL |\n\nliteral\n\ntext\n 9 | -DOC 10 | -STR 11 | - name: spec-09-26-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!str "\n\nliteral\n\ntext\n" 16 | tree: | 17 | +STR 18 | +DOC --- 19 | =VAL "\n\nliteral\n\ntext\n 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-29.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-29 4 | yaml: "> # Simple folded scalar\n folded\n text\n \tlines\n" 5 | tree: | 6 | +STR 7 | +DOC 8 | =VAL >folded text\n\tlines\n 9 | -DOC 10 | -STR 11 | - name: spec-09-29-canonical 12 | yaml: | 13 | %YAML 1.1 14 | --- 15 | !!str "folded text\n\ 16 | \tlines\n" 17 | tree: | 18 | +STR 19 | +DOC --- 20 | =VAL "folded text\n\tlines\n 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-09-30.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-09-30 4 | yaml: | 5 | > 6 | folded 7 | line 8 | 9 | next 10 | line 11 | 12 | * bullet 13 | * list 14 | 15 | last 16 | line 17 | 18 | # Comment 19 | tree: | 20 | +STR 21 | +DOC 22 | =VAL >folded line\nnext line\n\n * bullet\n * list\n\nlast line\n 23 | -DOC 24 | -STR 25 | - name: spec-09-30-canonical 26 | yaml: | 27 | %YAML 1.1 28 | --- 29 | !!str "folded line\n\ 30 | next line\n\n\ 31 | \ * bullet\n\ 32 | \ * list\n\n\ 33 | last line\n" 34 | tree: | 35 | +STR 36 | +DOC --- 37 | =VAL "folded line\nnext line\n\n * bullet\n * list\n\nlast line\n 38 | -DOC 39 | -STR 40 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-01.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-01 4 | yaml: | 5 | - [ inner, inner, ] 6 | - [inner,last] 7 | tree: | 8 | +STR 9 | +DOC 10 | +SEQ 11 | +SEQ [] 12 | =VAL :inner 13 | =VAL :inner 14 | -SEQ 15 | +SEQ [] 16 | =VAL :inner 17 | =VAL :last 18 | -SEQ 19 | -SEQ 20 | -DOC 21 | -STR 22 | - name: spec-10-01-canonical 23 | yaml: | 24 | %YAML 1.1 25 | --- 26 | !!seq [ 27 | !!seq [ 28 | !!str "inner", 29 | !!str "inner", 30 | ], 31 | !!seq [ 32 | !!str "inner", 33 | !!str "last", 34 | ], 35 | ] 36 | tree: | 37 | +STR 38 | +DOC --- 39 | +SEQ [] 40 | +SEQ [] 41 | =VAL "inner 42 | =VAL "inner 43 | -SEQ 44 | +SEQ [] 45 | =VAL "inner 46 | =VAL "last 47 | -SEQ 48 | -SEQ 49 | -DOC 50 | -STR 51 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-02.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-02 4 | yaml: | 5 | [ 6 | "double 7 | quoted", 'single 8 | quoted', 9 | plain 10 | text, [ nested ], 11 | single: pair , 12 | ] 13 | tree: | 14 | +STR 15 | +DOC 16 | +SEQ [] 17 | =VAL "double quoted 18 | =VAL 'single quoted 19 | =VAL :plain text 20 | +SEQ [] 21 | =VAL :nested 22 | -SEQ 23 | +MAP {} 24 | =VAL :single 25 | =VAL :pair 26 | -MAP 27 | -SEQ 28 | -DOC 29 | -STR 30 | - name: spec-10-02-canonical 31 | yaml: | 32 | %YAML 1.1 33 | --- 34 | !!seq [ 35 | !!str "double quoted", 36 | !!str "single quoted", 37 | !!str "plain text", 38 | !!seq [ 39 | !!str "nested", 40 | ], 41 | !!map { 42 | ? !!str "single" 43 | : !!str "pair" 44 | } 45 | ] 46 | tree: | 47 | +STR 48 | +DOC --- 49 | +SEQ [] 50 | =VAL "double quoted 51 | =VAL "single quoted 52 | =VAL "plain text 53 | +SEQ [] 54 | =VAL "nested 55 | -SEQ 56 | +MAP {} 57 | =VAL "single 58 | =VAL "pair 59 | -MAP 60 | -SEQ 61 | -DOC 62 | -STR 63 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-03.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-03 4 | yaml: | 5 | block: # Block 6 | # sequence 7 | - one 8 | - two : three 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL :block 14 | +SEQ 15 | =VAL :one 16 | +MAP 17 | =VAL :two 18 | =VAL :three 19 | -MAP 20 | -SEQ 21 | -MAP 22 | -DOC 23 | -STR 24 | - name: spec-10-03-canonical 25 | yaml: | 26 | %YAML 1.1 27 | --- 28 | !!map { 29 | ? !!str "block" 30 | : !!seq [ 31 | !!str "one", 32 | !!map { 33 | ? !!str "two" 34 | : !!str "three" 35 | } 36 | ] 37 | } 38 | tree: | 39 | +STR 40 | +DOC --- 41 | +MAP {} 42 | =VAL "block 43 | +SEQ [] 44 | =VAL "one 45 | +MAP {} 46 | =VAL "two 47 | =VAL "three 48 | -MAP 49 | -SEQ 50 | -MAP 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-04.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-04 4 | yaml: | 5 | block: 6 | - one 7 | - 8 | - two 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL :block 14 | +SEQ 15 | =VAL :one 16 | +SEQ 17 | =VAL :two 18 | -SEQ 19 | -SEQ 20 | -MAP 21 | -DOC 22 | -STR 23 | - name: spec-10-04-canonical 24 | yaml: | 25 | %YAML 1.1 26 | --- 27 | !!map { 28 | ? !!str "block" 29 | : !!seq [ 30 | !!str "one", 31 | !!seq [ 32 | !!str "two" 33 | ] 34 | ] 35 | } 36 | tree: | 37 | +STR 38 | +DOC --- 39 | +MAP {} 40 | =VAL "block 41 | +SEQ [] 42 | =VAL "one 43 | +SEQ [] 44 | =VAL "two 45 | -SEQ 46 | -SEQ 47 | -MAP 48 | -DOC 49 | -STR 50 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-05.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-05 4 | yaml: | 5 | - # Empty 6 | - | 7 | block node 8 | - - one # in-line 9 | - two # sequence 10 | - one: two # in-line 11 | # mapping 12 | tree: | 13 | +STR 14 | +DOC 15 | +SEQ 16 | =VAL : 17 | =VAL |block node\n 18 | +SEQ 19 | =VAL :one 20 | =VAL :two 21 | -SEQ 22 | +MAP 23 | =VAL :one 24 | =VAL :two 25 | -MAP 26 | -SEQ 27 | -DOC 28 | -STR 29 | - name: spec-10-05-canonical 30 | yaml: | 31 | %YAML 1.1 32 | --- 33 | !!seq [ 34 | !!null "", 35 | !!str "block node\n", 36 | !!seq [ 37 | !!str "one", 38 | !!str "two", 39 | ], 40 | !!map { 41 | ? !!str "one" 42 | : !!str "two", 43 | } 44 | ] 45 | tree: | 46 | +STR 47 | +DOC --- 48 | +SEQ [] 49 | =VAL " 50 | =VAL "block node\n 51 | +SEQ [] 52 | =VAL "one 53 | =VAL "two 54 | -SEQ 55 | +MAP {} 56 | =VAL "one 57 | =VAL "two 58 | -MAP 59 | -SEQ 60 | -DOC 61 | -STR 62 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-06.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-06 4 | yaml: | 5 | - { inner : entry , also: inner , } 6 | - {inner: entry,last : entry} 7 | tree: | 8 | +STR 9 | +DOC 10 | +SEQ 11 | +MAP {} 12 | =VAL :inner 13 | =VAL :entry 14 | =VAL :also 15 | =VAL :inner 16 | -MAP 17 | +MAP {} 18 | =VAL :inner 19 | =VAL :entry 20 | =VAL :last 21 | =VAL :entry 22 | -MAP 23 | -SEQ 24 | -DOC 25 | -STR 26 | - name: spec-10-06-canonical 27 | yaml: | 28 | %YAML 1.1 29 | --- 30 | !!seq [ 31 | !!map { 32 | ? !!str "inner" 33 | : !!str "entry", 34 | ? !!str "also" 35 | : !!str "inner" 36 | }, 37 | !!map { 38 | ? !!str "inner" 39 | : !!str "entry", 40 | ? !!str "last" 41 | : !!str "entry" 42 | } 43 | ] 44 | tree: | 45 | +STR 46 | +DOC --- 47 | +SEQ [] 48 | +MAP {} 49 | =VAL "inner 50 | =VAL "entry 51 | =VAL "also 52 | =VAL "inner 53 | -MAP 54 | +MAP {} 55 | =VAL "inner 56 | =VAL "entry 57 | =VAL "last 58 | =VAL "entry 59 | -MAP 60 | -SEQ 61 | -DOC 62 | -STR 63 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-07.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-07 4 | yaml: | 5 | { 6 | ? : value, # Empty key 7 | ? explicit 8 | key: value, 9 | simple key : value, 10 | [ collection, simple, key ]: value 11 | } 12 | tree: | 13 | +STR 14 | +DOC 15 | +MAP {} 16 | =VAL : 17 | =VAL :value 18 | =VAL :explicit key 19 | =VAL :value 20 | =VAL :simple key 21 | =VAL :value 22 | +SEQ [] 23 | =VAL :collection 24 | =VAL :simple 25 | =VAL :key 26 | -SEQ 27 | =VAL :value 28 | -MAP 29 | -DOC 30 | -STR 31 | - name: spec-10-07-canonical 32 | yaml: | 33 | %YAML 1.1 34 | --- 35 | !!map { 36 | ? !!null "" 37 | : !!str "value", 38 | ? !!str "explicit key" 39 | : !!str "value", 40 | ? !!str "simple key" 41 | : !!str "value", 42 | ? !!seq [ 43 | !!str "collection", 44 | !!str "simple", 45 | !!str "key" 46 | ] 47 | : !!str "value" 48 | } 49 | tree: | 50 | +STR 51 | +DOC --- 52 | +MAP {} 53 | =VAL " 54 | =VAL "value 55 | =VAL "explicit key 56 | =VAL "value 57 | =VAL "simple key 58 | =VAL "value 59 | +SEQ [] 60 | =VAL "collection 61 | =VAL "simple 62 | =VAL "key 63 | -SEQ 64 | =VAL "value 65 | -MAP 66 | -DOC 67 | -STR 68 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-08.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-08 4 | fail: true 5 | mark: { line: 3, column: 13 } 6 | mark2: { line: 1, column: 1 } 7 | error: | 8 | While parsing a flow mapping, expected ',' or '}', but got: value 9 | yaml: | 10 | { 11 | multi-line 12 | simple key : value, 13 | very long ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................(>1KB)................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... key: value 14 | } 15 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-09.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-09 4 | yaml: | 5 | { 6 | key : value, 7 | empty: # empty value↓ 8 | } 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP {} 13 | =VAL :key 14 | =VAL :value 15 | =VAL :empty 16 | =VAL : 17 | -MAP 18 | -DOC 19 | -STR 20 | - name: spec-10-09-canonical 21 | yaml: | 22 | %YAML 1.1 23 | --- 24 | !!map { 25 | ? !!str "key" 26 | : !!str "value", 27 | ? !!str "empty" 28 | : !!null "", 29 | } 30 | tree: | 31 | +STR 32 | +DOC --- 33 | +MAP {} 34 | =VAL "key 35 | =VAL "value 36 | =VAL "empty 37 | =VAL " 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-10.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-10 4 | yaml: | 5 | { 6 | ? explicit key1 : explicit value, 7 | ? explicit key2 : , # Explicit empty 8 | ? explicit key3, # Empty value 9 | simple key1 : explicit value, 10 | simple key2 : , # Explicit empty 11 | simple key3, # Empty value 12 | } 13 | tree: | 14 | +STR 15 | +DOC 16 | +MAP {} 17 | =VAL :explicit key1 18 | =VAL :explicit value 19 | =VAL :explicit key2 20 | =VAL : 21 | =VAL :explicit key3 22 | =VAL : 23 | =VAL :simple key1 24 | =VAL :explicit value 25 | =VAL :simple key2 26 | =VAL : 27 | =VAL :simple key3 28 | =VAL : 29 | -MAP 30 | -DOC 31 | -STR 32 | - name: spec-10-10-canonical 33 | yaml: | 34 | %YAML 1.1 35 | --- 36 | !!map { 37 | ? !!str "explicit key1" 38 | : !!str "explicit value", 39 | ? !!str "explicit key2" 40 | : !!null "", 41 | ? !!str "explicit key3" 42 | : !!null "", 43 | ? !!str "simple key1" 44 | : !!str "explicit value", 45 | ? !!str "simple key2" 46 | : !!null "", 47 | ? !!str "simple key3" 48 | : !!null "", 49 | } 50 | tree: | 51 | +STR 52 | +DOC --- 53 | +MAP {} 54 | =VAL "explicit key1 55 | =VAL "explicit value 56 | =VAL "explicit key2 57 | =VAL " 58 | =VAL "explicit key3 59 | =VAL " 60 | =VAL "simple key1 61 | =VAL "explicit value 62 | =VAL "simple key2 63 | =VAL " 64 | =VAL "simple key3 65 | =VAL " 66 | -MAP 67 | -DOC 68 | -STR 69 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-11.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-11 4 | yaml: | 5 | [ 6 | ? explicit key1 : explicit value, 7 | ? explicit key2 : , # Explicit empty 8 | ? explicit key3, # Implicit empty 9 | simple key1 : explicit value, 10 | simple key2 : , # Explicit empty 11 | ] 12 | tree: | 13 | +STR 14 | +DOC 15 | +SEQ [] 16 | +MAP {} 17 | =VAL :explicit key1 18 | =VAL :explicit value 19 | -MAP 20 | +MAP {} 21 | =VAL :explicit key2 22 | =VAL : 23 | -MAP 24 | +MAP {} 25 | =VAL :explicit key3 26 | =VAL : 27 | -MAP 28 | +MAP {} 29 | =VAL :simple key1 30 | =VAL :explicit value 31 | -MAP 32 | +MAP {} 33 | =VAL :simple key2 34 | =VAL : 35 | -MAP 36 | -SEQ 37 | -DOC 38 | -STR 39 | - name: spec-10-11-canonical 40 | yaml: | 41 | %YAML 1.1 42 | --- 43 | !!seq [ 44 | !!map { 45 | ? !!str "explicit key1" 46 | : !!str "explicit value", 47 | }, 48 | !!map { 49 | ? !!str "explicit key2" 50 | : !!null "", 51 | }, 52 | !!map { 53 | ? !!str "explicit key3" 54 | : !!null "", 55 | }, 56 | !!map { 57 | ? !!str "simple key1" 58 | : !!str "explicit value", 59 | }, 60 | !!map { 61 | ? !!str "simple key2" 62 | : !!null "", 63 | }, 64 | ] 65 | tree: | 66 | +STR 67 | +DOC --- 68 | +SEQ [] 69 | +MAP {} 70 | =VAL "explicit key1 71 | =VAL "explicit value 72 | -MAP 73 | +MAP {} 74 | =VAL "explicit key2 75 | =VAL " 76 | -MAP 77 | +MAP {} 78 | =VAL "explicit key3 79 | =VAL " 80 | -MAP 81 | +MAP {} 82 | =VAL "simple key1 83 | =VAL "explicit value 84 | -MAP 85 | +MAP {} 86 | =VAL "simple key2 87 | =VAL " 88 | -MAP 89 | -SEQ 90 | -DOC 91 | -STR 92 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-12.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-12 4 | yaml: | 5 | block: # Block 6 | # mapping 7 | key: value 8 | tree: | 9 | +STR 10 | +DOC 11 | +MAP 12 | =VAL :block 13 | +MAP 14 | =VAL :key 15 | =VAL :value 16 | -MAP 17 | -MAP 18 | -DOC 19 | -STR 20 | - name: spec-10-12-canonical 21 | yaml: | 22 | %YAML 1.1 23 | --- 24 | !!map { 25 | ? !!str "block" 26 | : !!map { 27 | ? !!str "key" 28 | : !!str "value" 29 | } 30 | } 31 | tree: | 32 | +STR 33 | +DOC --- 34 | +MAP {} 35 | =VAL "block 36 | +MAP {} 37 | =VAL "key 38 | =VAL "value 39 | -MAP 40 | -MAP 41 | -DOC 42 | -STR 43 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-13.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-13 4 | yaml: | 5 | ? explicit key # implicit value 6 | ? | 7 | block key 8 | : - one # explicit in-line 9 | - two # block value 10 | tree: | 11 | +STR 12 | +DOC 13 | +MAP 14 | =VAL :explicit key 15 | =VAL : 16 | =VAL |block key\n 17 | +SEQ 18 | =VAL :one 19 | =VAL :two 20 | -SEQ 21 | -MAP 22 | -DOC 23 | -STR 24 | - name: spec-10-13-canonical 25 | yaml: | 26 | %YAML 1.1 27 | --- 28 | !!map { 29 | ? !!str "explicit key" 30 | : !!null "", 31 | ? !!str "block key\n" 32 | : !!seq [ 33 | !!str "one", 34 | !!str "two", 35 | ] 36 | } 37 | tree: | 38 | +STR 39 | +DOC --- 40 | +MAP {} 41 | =VAL "explicit key 42 | =VAL " 43 | =VAL "block key\n 44 | +SEQ [] 45 | =VAL "one 46 | =VAL "two 47 | -SEQ 48 | -MAP 49 | -DOC 50 | -STR 51 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-14.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-14 4 | yaml: | 5 | plain key: # empty value 6 | "quoted key": 7 | - one # explicit next-line 8 | - two # block value 9 | tree: | 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL :plain key 14 | =VAL : 15 | =VAL "quoted key 16 | +SEQ 17 | =VAL :one 18 | =VAL :two 19 | -SEQ 20 | -MAP 21 | -DOC 22 | -STR 23 | - name: spec-10-14-canonical 24 | yaml: | 25 | %YAML 1.1 26 | --- 27 | !!map { 28 | ? !!str "plain key" 29 | : !!null "", 30 | ? !!str "quoted key" 31 | : !!seq [ 32 | !!str "one", 33 | !!str "two", 34 | ] 35 | } 36 | tree: | 37 | +STR 38 | +DOC --- 39 | +MAP {} 40 | =VAL "plain key 41 | =VAL " 42 | =VAL "quoted key 43 | +SEQ [] 44 | =VAL "one 45 | =VAL "two 46 | -SEQ 47 | -MAP 48 | -DOC 49 | -STR 50 | -------------------------------------------------------------------------------- /test/spec 1.1/spec-10-15.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: spec-10-15 4 | yaml: | 5 | - sun: yellow 6 | - ? earth: blue 7 | : moon: white 8 | tree: | 9 | +STR 10 | +DOC 11 | +SEQ 12 | +MAP 13 | =VAL :sun 14 | =VAL :yellow 15 | -MAP 16 | +MAP 17 | +MAP 18 | =VAL :earth 19 | =VAL :blue 20 | -MAP 21 | +MAP 22 | =VAL :moon 23 | =VAL :white 24 | -MAP 25 | -MAP 26 | -SEQ 27 | -DOC 28 | -STR 29 | - name: spec-10-15-canonical 30 | yaml: | 31 | %YAML 1.1 32 | --- 33 | !!seq [ 34 | !!map { 35 | ? !!str "sun" 36 | : !!str "yellow" 37 | }, 38 | !!map { 39 | ? !!map { 40 | ? !!str "earth" 41 | : !!str "blue" 42 | } 43 | : !!map { 44 | ? !!str "moon" 45 | : !!str "white" 46 | } 47 | } 48 | ] 49 | tree: | 50 | +STR 51 | +DOC --- 52 | +SEQ [] 53 | +MAP {} 54 | =VAL "sun 55 | =VAL "yellow 56 | -MAP 57 | +MAP {} 58 | +MAP {} 59 | =VAL "earth 60 | =VAL "blue 61 | -MAP 62 | +MAP {} 63 | =VAL "moon 64 | =VAL "white 65 | -MAP 66 | -MAP 67 | -SEQ 68 | -DOC 69 | -STR 70 | -------------------------------------------------------------------------------- /test/unclosed-bracket.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: unclosed-bracket 4 | fail: true 5 | mark: { line: 7, column: 1 } 6 | mark2: { line: 2, column: 7 } 7 | error: "While parsing a flow sequence, expected ',' or ']', but got: streamEnd" 8 | yaml: | 9 | test: 10 | - [ foo: bar 11 | # comment the rest of the stream to let the scanner detect the problem. 12 | # - baz 13 | #"we could have detected the unclosed bracket on the above line, but this would forbid such syntax as": { 14 | #} 15 | -------------------------------------------------------------------------------- /test/unclosed-quoted-scalar.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: unclosed-quoted-scalar 4 | fail: true 5 | mark: { line: 3, column: 1 } 6 | mark2: { line: 1, column: 1 } 7 | error: "While scanning a quoted scalar, found unexpected end of buffer" 8 | yaml: | 9 | 'foo 10 | bar 11 | -------------------------------------------------------------------------------- /test/undefined-anchor.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: undefined-anchor 4 | fail: true 5 | error: | 6 | Unable to load test/undefined-anchor.yaml#undefined-anchor:yaml: Found undefined alias: bat 7 | mark: { line: 3, column: 3 } 8 | yaml: | 9 | - foo 10 | - &bar baz 11 | - *bat 12 | -------------------------------------------------------------------------------- /test/undefined-tag-handle.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | - name: undefined-tag-handle 4 | fail: true 5 | mark: { line: 1, column: 5 } 6 | mark2: { line: 1, column: 5 } 7 | error: "While parsing a node, found undefined tag handle: !foo!" 8 | yaml: | 9 | --- !foo!bar baz 10 | - name: undefined-tag-handle-2 11 | fail: true 12 | mark: { line: 1, column: 9 } 13 | mark2: { line: 1, column: 1 } 14 | error: "While parsing a node, found undefined tag handle: !foo!" 15 | yaml: |- 16 | &anchor !foo!bar value 17 | -------------------------------------------------------------------------------- /testsuite/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testsuite", 3 | "targetType": "executable", 4 | "dependencies": 5 | { 6 | "dyaml": "*" 7 | } 8 | } 9 | --------------------------------------------------------------------------------