It is an interface to the C++ package yaml-cpp. I use yaml-cpp to parse a yaml document, then I load the data into Fortran derived types created by fortran-yaml. So it’s just knitting two packages together. The API is nearly identical to fortran-yaml.
The reason I did this was because fortran-yaml isn’t a full yaml parser. It can’t deal with flow style, or multiline strings, and a bunch of other stuff. Initially, I tried improving the parser in fortran-yaml so that it could parse more yaml syntax, but this turned out to be really hard. Knitting together yaml-cpp and fortran-yaml was much easier.
I would appreciate any feedback/issues/suggestions! This is the most involved merger of Fortran and C++ I’ve tried, so I probably made mistakes that need catching.
Many thanks for doing this @nicholaswogan. I am really excited by this news and I can’t wait to test it (although I might not have time for this in the near future ).
Although it is probably not the sort of feedback that you are expecting, I’d ask if you can package the library with fpm. For my use case, it would be a big improvement.
Also, have you compared the features of your parser with the young but excellent yaFyaml?
@nicholaswogan thanks for doing that. As @epagone asked, if you wouldn’t mind adding fpm build system that would make it much easier for others to try.
yaFyaml does looks excellent!! I think I like the API more than fortran-yaml. But I can’t figure out how to build yaFyaml. It has some dependencies which are not included in the github repo (GFTL).
@certik@epagone I will package fortran-yaml-cpp with fpm, but I have to work out how to do this when CMake is involved. CMake has to be involved because it needs to build the C++ package yaml-cpp.
my_build_script.sh is never executed. Instead, fpm compiles src/yaml.f90 and src/yaml_types.f90 and does not compile src/yaml.cpp, and makes libfortran-yaml-cpp.a. Then fpm tries to build and link the executable runTests, but fails because symbols from src/yaml.cpp are not contained in libfortran-yaml-cpp.a.
We currently don’t support build scripts in Fortran fpm. The key in library is still leftover from the Haskell implementation, but we didn’t get around to actually implement a build script hook yet in the Fortran version. So this is an open issue at the moment.
I don’t think fpm’s support for C++ files is there yet either. It might work in some cases just because the gcc or icc compiler commands by default enable both C and C++. I think there can be some issues with choosing the right linker.
The related issue for fpm is here:
To work with fpm currently, you’ll have to install your C++ dependency first as a system library, and then add something like:
link = ["yaml-cpp", "stdc++"]
into your TOML file.
Improved C++ support in fpm is something that should definitely be pursued.
The way I’ve laid out the package currently, I think this method won’t quite work because fortran-yaml-cpp has a little bit of C++ code in it, which needs compiling.
So I think I would need to fork yaml-cpp, add my C++ code to libyaml-cpp, and make this modified version of yaml-cpp a dependency.
But there would still be the issue of the linker. I think fpm would need to use a C++ linker to make an executable.
I’m the primary developer of yaFyaml - and only incidentally stumbled into this thread just now.
I recently released yaFyaml v1.0 which changes some of the interfaces. I’d be happy to help anyone that is having difficulty with installation - it does indeed depend on 2 other packages: gFTL and gFTL-shared. gFTL is a utility that generates templates for software containers with similar interfaces to C++ STL containers. gFTL-shared is a library that instantiates those containers for common cases of intrinsic types. And gFTL-shared includes gFTL as a submodule, so you really only need to install it - installs in a canonical CMake manner.