pantoniou / libfyaml

Fully feature complete YAML parser and emitter, supporting the latest YAML spec and passing the full YAML testsuite.
MIT License
241 stars 74 forks source link

API to get parsed comments #26

Closed jlblancoc closed 4 years ago

jlblancoc commented 4 years ago

I've been trying to add an API to get the parsed comments, via adding this commit https://github.com/MRPT/libfyaml/commit/2e67a1528fabb9f8478ebadc66d744a3b4227bea both, over your project "master", and over the "comment-wip" branch (both result in the same error described next).

Token values with a comment correctly have fy_atom_is_set() to TRUE, but trying to get the comment text from a parser event loop with the new function fy_token_get_comment() only returns a pointer to rubbish...

Please, take a look at my use of fy_atom_format_text() since something must be wrong but can't find it.

PS: Thanks for this amazing library!

jlblancoc commented 4 years ago

Ok, problem solved: fy_atom_format_text() returns a pointer to the next char after the stored string. :+1:

jlblancoc commented 4 years ago

@pantoniou : If you are interested, I can open a PR to provide the fy_token_get_comment() function...