-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to parse other map keys after a sequence if the sequence items are not indented #28
Comments
Possibly not even related to map keys. I get the same message here:
|
Hmm, well I'm not sure that document is well formed? Is each sequence/array item supposed to be a map? If so, you'd need to make "Lumi" and the last "mu" either keys or values. For what it's worth, PyYAML doesn't like it either. |
Well, the document was written with rapidyaml. So irrespective of whether it's valid YAML or not, I'd hope it would at least be able to parse back what it emitted :-) |
Heh, indeed, though that really does sound more like a bug with the emitter as the YAML is invalid. |
@leoetlino Thanks for writing up. Your YAML is valid indeed, so this is a parser bug. The parser code in ryml has trouble with the first non-indented sequence item on line 2. From there on, all bets are off. So you are right that indenting the sequence will allow ryml to parse it correctly. |
So I did a small test, and it looks like changing Parser::_handle_seq_impl (in the RNXT state) to fall back to assuming the sequence was unindented and ending it lets ryml parse the example document correctly: rapidyaml/src/c4/yml/parse.cpp Lines 589 to 598 in e1216d4
- _c4err("parse error");
+ _c4dbgp("end the indentless sequence");
+ _pop_level();
+ return true; enemy:
- actors: 1
test_array:
- a
test: x
test: 2 parses correctly into this: enemy:
-
actors: 1
test_array:
- a
test: x
test: 2 That is most likely just a hacky workaround though. I'm not sure how to fix this correctly. |
@leoetlino thanks for the note - it did help. All the unit tests pass, so I'm going to go with that. This is in the dev branch, and I'm going to look next at #32 in the same branch. When it's fixed, I'll merge dev to master, and only then will I close. |
First, let me thank you for making this library! I am currently in the process of switching from PyYAML to ryml for performance reasons, and so far the initial results are very encouraging. ryml is typically 20-25x faster for emitting and one file that took 2s to emit with PyYAML or yaml-cpp only takes ~90ms with ryml.
However, parsing existing documents that were emitted by PyYAML (or libyaml) is proving to be a bit more problematic.
Currently any documents that look like this fail to parse with ryml:
If the actors array is indented as follows:
then the file is parsed correctly. It seems that the lack of extra indentation for the array is throwing ryml off and causing it to miss the end of the sequence?
The text was updated successfully, but these errors were encountered: