Parsing YAML into key:value tree nodes with C library
David Todd <[email protected]> Fri, 13 Aug 2021 17:22:11 -0400
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============1310462788872608235==
Content-Type: multipart/alternative;
boundary="------------448FABAE13B913A9FCDF7522"
Content-Language: en-US
This is a multi-part message in MIME format.
--------------448FABAE13B913A9FCDF7522
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Apologies in advance: couldn't see a way to reply to prior thread on the =
Sourceforge mailing list site so I'm repeating here.
In 2011 (!), @wuttke and @simonov exchanged email about simpler ways of=20
loading yaml files.
*Re: [Yaml-core] can I load entire node trees with the C library libyaml =
? <https://sourceforge.net/p/yaml/mailman/message/28445947/>*
From: Kirill Simonov <xi@re...> - 2011-11-24 15:23:20
Hi Joachim,
A high-level API for libyaml was planned, but never finished. I wasn't
able to design a satisfactory high-level API for C and it appeared to be
easier to expose the low-level interface and construct the document tree
in a scripting language.
On 11/17/2011 03:37 AM, Joachim Wuttke <j.wuttke@...> wrote:
> So far, the best introduction to libyaml I found is
> the tutorial by Andrew Poelstra at
> http://wpsoftware.net/andrew/pages/libyaml.html <http://wpsoftware=
=2Enet/andrew/pages/libyaml.html>
> It explains two ways of parsing a YAML file, by
> token or by event. Both are pretty low level; if
> I understand correctly, parsing by event is just
> a little less low level than parsing by token.
>
> In contrast, scripting languages offer a much
> simpler way of loading YAML files, basically:
> y =3D YAML.load( URL.open("http://yaml.org";) )
> print y["Projects"]["C/C++ Libraries"][0]
> would yield "libyaml".
>
> Is it possible under C to load in a similar way
> an entire YAML file into a node tree?
>
> There is a yaml_node_type_t, is there any example
> how to use it?
>
> Thanks in advance, Joachim
>
I have a similar question, but in a C program context.=C2=A0 I'm interest=
ed=20
in parsing YAML into a tree of key:value nodes for subsequent retrieval=20
and processing.
For a prior project I used XML and libxml2=20
(http://xmlsoft.org/example.html), and while XML has some advantages,=20
YAML is much more readable and (perhaps) easier to code.
libxml2 has a number of tools, including an XML parser that yields a=20
tree and functions to retrieve values from the tree given a key and=20
starting node.
Has anyone created such a package for YAML?=C2=A0 If so, would you be wil=
ling=20
to share it?
If not, would there be any value to others (apparently not, if no one=20
has done it).=C2=A0 It seems that it might be relatively easy to generate=
the=20
tree from the existing run-parse-tree-suite.c code (though I'm=20
sufficiently new to YAML, and have a very limited use case, that that's=20
probably a naive statement).
Thanks for any help you can offer.
David
--------------448FABAE13B913A9FCDF7522
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF=
-8">
</head>
<body>
<font size=3D"+1"><font face=3D"Calibri">Apologies in advance: couldn=
't
see a way to reply to prior thread on the Sourceforge mailing
list site so I'm repeating here.<br>
<br>
In 2011 (!), @wuttke and @simonov exchanged email about simpler
ways of loading yaml files.<br>
</font></font><br>
<table id=3D"msg28445947">
<tbody>
<tr>
<td class=3D"email-header">
<div>
<div><b><a
href=3D"https://sourceforge.net/p/yaml/mailman/messag=
e/28445947/">Re:
[Yaml-core] can I load entire node trees with the C
library libyaml ?</a></b></div>
<small>From: Kirill Simonov <a class=3D"moz-txt-link-rfc239=
6E" href=3D"mailto:xi@re..."><xi@re...></a> - 2011-11-24
15:23:20</small>
<div class=3D"attachments"> <small> </small> </div>
</div>
</td>
</tr>
<tr>
<td class=3D"email-body">
<pre>Hi Joachim,
A high-level API for libyaml was planned, but never finished. I wasn't=20
able to design a satisfactory high-level API for C and it appeared to be =
easier to expose the low-level interface and construct the document tree =
in a scripting language.
On 11/17/2011 03:37 AM, Joachim Wuttke <a class=3D"moz-txt-link-rfc2396E"=
href=3D"mailto:j.wuttke@..."><j.wuttke@...></a> wrote:
> So far, the best introduction to libyaml I found is
> the tutorial by Andrew Poelstra at
> <a href=3D"http://wpsoftware.net/andrew/pages/libyaml.html" rel=3D=
"nofollow">http://wpsoftware.net/andrew/pages/libyaml.html</a>
> It explains two ways of parsing a YAML file, by
> token or by event. Both are pretty low level; if
> I understand correctly, parsing by event is just
> a little less low level than parsing by token.
>
> In contrast, scripting languages offer a much
> simpler way of loading YAML files, basically:
> y =3D YAML.load( URL.open("<a rel=3D"nofollow">http://yaml.org"<=
/a>;) )
> print y["Projects"]["C/C++ Libraries"][0]
> would yield "libyaml".
>
> Is it possible under C to load in a similar way
> an entire YAML file into a node tree?
>
> There is a yaml_node_type_t, is there any example
> how to use it?
>
> Thanks in advance, Joachim
></pre>
</td>
</tr>
</tbody>
</table>
<font size=3D"+1"><font face=3D"Calibri"><br>
I have a similar question, but in a C program context.=C2=A0 I'm
interested in parsing YAML into a tree of key:value nodes for
subsequent retrieval and processing. <br>
<br>
For a prior project I used XML and libxml2
(<a class=3D"moz-txt-link-freetext" href=3D"http://xmlsoft.org/ex=
ample.html">http://xmlsoft.org/example.html</a>), and while XML has some
advantages, YAML is much more readable and (perhaps) easier to
code.<br>
<br>
libxml2 has a number of tools, including an XML parser that
yields a tree and functions to retrieve values from the tree
given a key and starting node.<br>
<br>
Has anyone created such a package for YAML?=C2=A0 If so, would yo=
u be
willing to share it?<br>
<br>
If not, would there be any value to others (apparently not, if
no one has done it).=C2=A0 It seems that it might be relatively e=
asy
to generate the tree from the existing run-parse-tree-suite.c
code (though I'm sufficiently new to YAML, and have a very
limited use case, that that's probably a naive statement).<br>
<br>
Thanks for any help you can offer.<br>
<br>
David<br>
<br>
<br>
<br>
</font></font>
</body>
</html>
--------------448FABAE13B913A9FCDF7522--
--===============1310462788872608235==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============1310462788872608235==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core
--===============1310462788872608235==--