Skip to content

Commit 9209722

Browse files
authored
Merge pull request #550 from biojppm/flow_ml
Implement FLOW_ML style
2 parents d820acb + f8ee5fb commit 9209722

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+5320
-2847
lines changed

.github/workflows-in/embedded.ys

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
!yamlscript/v0:
22

3+
# DOCKER DEBUGGING EXAMPLES AT THE END!
4+
5+
36
:use common: :all
47
:: workflow-setup()
58

@@ -113,3 +116,41 @@ jobs:
113116
needs: [canary11, canary20]
114117
:: setup-job('embedded' 'xcompile')
115118
:: define-job(rest(matrix-items) steps20 'c++20')
119+
120+
121+
122+
# command examples to test in docker
123+
#
124+
#
125+
# apt-get install g{cc,++}-arm-linux-gnueabi
126+
# docker exec -it 7e711fd09471 bash -c '( set -xe ; \
127+
# arch=armv4 ; flags=" -march=armv4" ; bt=Release ; std=11 ; \
128+
# bd=build/docker/$arch-$bt ; \
129+
# export C4_EXTERN_DIR=`pwd`/build/extern ; \
130+
# function cm() { \
131+
# cmake -B $bd -D CMAKE_TOOLCHAIN_FILE=ext/c4core/.github/toolchains/$arch.cmake \
132+
# -DCMAKE_BUILD_TYPE=$bt -DC4_CXX_STANDARD=$std -D CXX_STANDARD=$std \
133+
# -DCMAKE_CXX_FLAGS=" $flags" -DCMAKE_C_FLAGS=" $flags" \
134+
# -DRYML_BUILD_TESTS=ON -D RYML_VALGRIND=OFF ; \
135+
# cmake --build $bd -j --target "$@" ; \
136+
# } ; \
137+
# tgt=ryml-test-parser ; \
138+
# exe=./$bd/test/$tgt ; \
139+
# cm $tgt ; \
140+
# qemu-arm-static -L /usr/arm-linux-gnueabi $exe --gtest_filter="*in_arena_noparser_4*" \
141+
# )'
142+
#
143+
#
144+
#
145+
# ( set -xe ; \
146+
# arch=aaarch64 ; flags="" ; bt=Release ; std=11 ; \
147+
# bd=build/docker/$arch-$bt ; \
148+
# export C4_EXTERN_DIR=`pwd`/build/extern ; \
149+
# function cm() { \
150+
# cmake -B $bd -D CMAKE_TOOLCHAIN_FILE=ext/c4core/.github/toolchains/$arch.cmake \
151+
# -DCMAKE_BUILD_TYPE=$bt -DC4_CXX_STANDARD=$std -D CXX_STANDARD=$std \
152+
# -DCMAKE_CXX_FLAGS="$flags" -DCMAKE_C_FLAGS="$flags" \
153+
# -DRYML_BUILD_TESTS=ON -D RYML_VALGRIND=OFF ; \
154+
# cmake --build $bd -j --target "$@" ; \
155+
# } ; \
156+
# cm ryml-test-run )

changelog/current.md

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1-
### Changes
1+
### New features
22

3-
- [PR#547](https://github.com/biojppm/rapidyaml/pull/547) - Fix parsing of implicit first documents with empty sequences, caused by a problem in `Tree::set_root_as_stream()`:
4-
```yaml
5-
[] # this container was lost during parsing
6-
---
7-
more data here
8-
```
9-
- [PR#561](https://github.com/biojppm/rapidyaml/pull/561) (fixes [#559](https://github.com/biojppm/rapidyaml/issues/559)) - Byte Order Mark: account for BOM when determining block indentation
10-
- [PR#563](https://github.com/biojppm/rapidyaml/pull/563) (fixes [#562](https://github.com/biojppm/rapidyaml/issues/562)) - Fix bug in `NodeRef::cend()`
11-
- [PR#565](https://github.com/biojppm/rapidyaml/pull/565) (fixes [#564](https://github.com/biojppm/rapidyaml/issues/564)) - `Tree` arena: allow relocation of zero-length strings when placed at the end (relax assertions triggered in `Tree::_relocated()`)
12-
- [PR#557](https://github.com/biojppm/rapidyaml/pull/557) - `Tree` is now non-empty by default, and `Tree::root_id()` will no longer modify the tree when it is empty. To create an empty tree now, it is necessary to use the capacity constructor with a capacity of zero:
3+
- [PR#550](https://github.com/biojppm/rapidyaml/pull/550) - Implement flow multiline style (`FLOW_ML`):
4+
- The parser now detects this style automatically for flow seqs or maps when the terminating bracket sits on a line different from the opening bracket.
5+
- Added `ParserOptions::detect_flow_ml()` to enable/disable this behavior
6+
- Added `EmitOptions::indent_flow_ml()` to control indentation of FLOW_ML containers
7+
- The emit implementation logic was refactored, and is now significantly cleaner
8+
- Emitted YAML will now have anchors emitted before tags, as is customary ([see example](https://play.yaml.io/main/parser?input=LSAhdGFnICZhbmNob3IgfAogIG5vdGUgaG93IHRoZSBhbmNob3IgY29tZXMKICBmaXJzdCBpbiB0aGUgZXZlbnRz)). Previously this
9+
- Added `ParserOptions` defaulted argument to temp-parser overloads of `parse_{yaml,json}_in_{place,arena}()`
10+
11+
12+
### API changes
13+
14+
- **BREAKING** [PR#503](https://github.com/biojppm/rapidyaml/pull/503) (fixes [#399](https://github.com/biojppm/rapidyaml/issues/399)): change error callbacks.
15+
- Errors in ryml now have one of these types:
16+
- parse error: when parsing YAML/JSON. See: `pfn_error_parse`, `ErrorDataParse`, `ExceptionParse`, `err_parse_format()`, `sample_error_parse`.
17+
- visit error: when visiting a tree (reading or writing). See: `pfn_error_visit`, `ErrorDataVisit`, `ExceptionVisit`, `err_visit_format()`, `sample_error_visit`.
18+
- basic error: other, non specific errors. See: `pfn_error_basic`, `ErrorDataBasic`, `ExceptionBasic`, `err_basic_format()`, `sample_error_basic`.
19+
- parse and visit errors/exceptions can be treated/caught as basic errors/exceptions.
20+
- Add message formatting functions to simplify user-provided implementation of error callbacks:
21+
- `err_parse_format()`: format/print a full error message for a parse error
22+
- `err_visit_format()`: format/print a full error message for a visit error
23+
- `err_basic_format()`: format/print a full error message for a basic error
24+
- `location_format()`: format/print a location
25+
- `location_format_with_context()`: useful to create a rich error message showing the YAML region causing the error, maybe even for a visit error if the source is kept and locations are enabled.
26+
- `format_exc()`: format an exception (when exceptions are enabled)
27+
- See the new header `c4/yml/error.hpp` (and `c4/yml/error.def.hpp` for definitions of the functions in `c4/yml/error.hpp`)
28+
- See the relevant sample functions in the quickstart sample: `sample_error_basic`, `sample_error_parse` and `sample_error_visit`.
29+
- There are breaking user-facing changes in the `Callbacks` structure:
30+
- Removed member `m_error `
31+
- Added members `m_error_basic`, `m_error_parse`, `m_error_visit`
32+
- Added methods `.set_error_basic()`, `.set_error_parse()` and `.set_error_visit()`.
33+
- **BREAKING** [PR#557](https://github.com/biojppm/rapidyaml/pull/557) - `Tree` is now non-empty by default, and `Tree::root_id()` will no longer modify the tree when it is empty. To create an empty tree, it is now necessary to use the capacity constructor with a capacity of zero:
1334
```c++
1435
// breaking change: default-constructed tree is now non-empty
1536
Tree tree;
@@ -24,32 +45,25 @@
2445
```
2546
This changeset also enables the python library to call `root_id()` on a default-constructed tree (fixes [#556](https://github.com/biojppm/rapidyaml/issues/556)).
2647
- [PR#560](https://github.com/biojppm/rapidyaml/pull/560) (see also [#554](https://github.com/biojppm/rapidyaml/issues/554)): python improvements:
27-
- expose `Tree::to_arena()` in python. This allows safer and easier programatic creation of trees in python by ensuring scalars have the same lifetime as the tree:
48+
- expose `Tree::to_arena()` in python. This allows safer and easier programatic creation of trees in python by ensuring scalars are placed into the tree and so have the same lifetime as the tree:
2849
```python
2950
t = ryml.Tree()
30-
s = t.to_arena(temp_string()) # Save a temporary string to the tree's arena.
51+
s = t.to_arena(temp_string()) # Copy/serialize a temporary string to the tree's arena.
3152
# Works also with integers and floats.
3253
t.to_val(t.root_id(), s) # Now we can safely use the scalar in the tree:
3354
# there is no longer any risk of it being deallocated
3455
```
3556
- improve behavior of `Tree` methods accepting scalars: all standard buffer types are now accepted (ie, `str`, `bytes`, `bytearray` and `memoryview`).
36-
- [PR#503](https://github.com/biojppm/rapidyaml/pull/503) (fixes [#399](https://github.com/biojppm/rapidyaml/issues/399)): change error callbacks.
37-
- Errors in ryml now have one of these types:
38-
- parse error: when parsing YAML/JSON. See: `pfn_error_parse`, `ErrorDataParse`, `ExceptionParse`, `err_parse_format()`, `sample_error_parse`.
39-
- visit error: when visiting a tree (reading or writing). See: `pfn_error_visit`, `ErrorDataVisit`, `ExceptionVisit`, `err_visit_format()`, `sample_error_visit`.
40-
- basic error: other, non specific errors. See: `pfn_error_basic`, `ErrorDataBasic`, `ExceptionBasic`, `err_basic_format()`, `sample_error_basic`.
41-
- parse and visit errors/exceptions can be treated/caught as basic errors/exceptions
42-
- Add message formatting functions to simplify implementation of error callbacks:
43-
- `err_parse_format()`: format/print a full error message for a parse error
44-
- `err_visit_format()`: format/print a full error message for a visit error
45-
- `err_basic_format()`: format/print a full error message for a basic error
46-
- `location_format()`: format/print a location
47-
- `location_format_with_context()`: useful to create a rich error message showing the YAML region causing the error, maybe even for a visit error if the source is kept and locations are enabled.
48-
- `format_exc()`: when exceptions are enabled
49-
- See the new header `c4/yml/error.hpp` (and `c4/yml/error.def.hpp` for definitions of the functions in `c4/yml/error.hpp`)
50-
- See the relevant sample functions in the quickstart sample: `sample_error_basic`, `sample_error_parse` and `sample_error_visit`.
51-
- There are breaking user-facing changes in the `Callbacks` structure:
52-
- Removed member `m_error `
53-
- Added members `m_error_basic`, `m_error_parse`, `m_error_visit`
54-
- Added methods `.set_error_basic()`, `.set_error_parse()` and `.set_error_visit()`.
57+
- [PR#565](https://github.com/biojppm/rapidyaml/pull/565) (fixes [#564](https://github.com/biojppm/rapidyaml/issues/564)) - `Tree` arena: allow relocation of zero-length strings when placed at the end (relax assertions triggered in `Tree::_relocated()`)
58+
- [PR#563](https://github.com/biojppm/rapidyaml/pull/563) (fixes [#562](https://github.com/biojppm/rapidyaml/issues/562)) - Fix bug in `NodeRef::cend()`
59+
60+
61+
### Fixes in YAML parsing
5562

63+
- [PR#561](https://github.com/biojppm/rapidyaml/pull/561) (fixes [#559](https://github.com/biojppm/rapidyaml/issues/559)) - Byte Order Mark: account for BOM length when determining block indentation
64+
- [PR#547](https://github.com/biojppm/rapidyaml/pull/547) - Fix parsing of implicit first documents with empty sequences, caused by a problem in `Tree::set_root_as_stream()`:
65+
```yaml
66+
[] # this container was lost during parsing
67+
---
68+
more data here
69+
```

0 commit comments

Comments
 (0)