-
Notifications
You must be signed in to change notification settings - Fork 10
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
How hard would it be to include support for { } and [ ]? #3
Comments
Thanks for considering this - it has been on our wish list for a while. The starting point would be the read_value routine in yaml.F90, where you would determine whether the next character in the stream is a [ or {. That's similar to how block lists are detected and handled there: Line 166 in 2d20331
(it then repeatedly calls "read_value" to read list elements). However, the read_value routine will likely need to be updated then to (optionally) operate in flow (rather than block) mode, and stop reading a new value when a , is encountered. Doable but not entirely trivial. If you'd like to give it a go, great! We probably should also look into putting together a test suite of yaml files then, and verify for instance whether they survive read-dump-read round-tripping. Cheers, Jorn |
Thanks for the information! I might try to do this at some point in the next few weeks as I'm working on a project that depends on fortran-yaml. |
I gave it a try. I was able to do almost any nested list in flow style, but had some problems with the very end of the last nested list. I did not try to do dictionaries. My attempt is attached. Overall, I just added two I don't love what I have done, but maybe the overall approach is along the right lines. |
@jornbr I used your type system with the parser in yaml-cpp to make a new package fortran-yaml-cpp. The API is nearly identical to fortran-yaml. But now it can deal with a flow style yaml. |
That seems a great way to get more robust yaml parsing while still preserving compatibility with the fortran-yaml interfaces. That could be useful for my own applications too, particularly if the underlying C++ code is not too particular about compilers. I'll hope to take a close look soon. |
I've tested the following two C++ and Fortran compiler combinations on MacOS. They both seem to work. I'll get around to testing other compiler combinations and OSs at some point.
|
@jornbr I am new to Licenses. What license should I put on fortran-yaml-cpp, so it does not violate fortran-yaml license. I also have another project which depend on fortran-yaml which I'm going to publish really soon. I want to use the proper license. |
Really useful package. Thanks. I'm considering trying to add support for flow style dictionaries and lists using {} and [] . I'm just wondering how hard this would be?
The text was updated successfully, but these errors were encountered: