Re: Parsing YAML into key:value tree nodes with C library
Oliver Fischer <[email protected]> Sun, 15 Aug 2021 10:34:55 +0200
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============6609948458706956428==
Content-Type: multipart/alternative;
boundary="------------9A4CCBB6EAC199EEAF949662"
This is a multi-part message in MIME format.
--------------9A4CCBB6EAC199EEAF949662
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Hi David,
did you have a look at the available libraries for C and C++ listed at
https://yaml.org/?
Oliver
Am 13.08.21 um 23:22 schrieb David Todd:
> 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 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.net/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 = 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. I'm interested
> in parsing YAML into a tree of key:value nodes for subsequent
> retrieval and processing.
>
> For a prior project I used XML and libxml2
> (http://xmlsoft.org/example.html), and while XML has some advantages,
> YAML is much more readable and (perhaps) easier to code.
>
> 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.
>
> Has anyone created such a package for YAML? If so, would you be
> willing to share it?
>
> If not, would there be any value to others (apparently not, if no one
> has done it). It seems that it might be relatively easy 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).
>
> Thanks for any help you can offer.
>
> David
>
>
>
>
>
> _______________________________________________
> Yaml-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/yaml-core
--
N Oliver B. Fischer
A Schönhauser Allee 64, 10437 Berlin, Deutschland/Germany
P +49 30 44793251
M +49 178 7903538
E [email protected]
S oliver.b.fischer
J oliver.b.fischer-/[email protected]
X http://xing.to/obf
--------------9A4CCBB6EAC199EEAF949662
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Hi David,<br>
<br>
did you have a look at the available libraries for C and C++ listed
at <a class="moz-txt-link-freetext" href="https://yaml.org/">https://yaml.org/</a>?<br>
<br>
Oliver<br>
<br>
<br>
<div class="moz-cite-prefix">Am 13.08.21 um 23:22 schrieb David
Todd:<br>
</div>
<blockquote type="cite"
cite="mid:a0627e81-3820-92da-6ca8-a870e5762dc8-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<font size="+1"><font face="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="msg28445947">
<tbody>
<tr>
<td class="email-header">
<div>
<div><b><a
href="https://sourceforge.net/p/yaml/mailman/message/28445947/"
moz-do-not-send="true">Re: [Yaml-core] can I load
entire node trees with the C library libyaml ?</a></b></div>
<small>From: Kirill Simonov <a
class="moz-txt-link-rfc2396E" href="mailto:xi@re..."
moz-do-not-send="true"><xi@re...></a> -
2011-11-24 15:23:20</small>
<div class="attachments"> <small> </small> </div>
</div>
</td>
</tr>
<tr>
<td class="email-body">
<pre>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 <a class="moz-txt-link-rfc2396E" href="mailto:j.wuttke@..." moz-do-not-send="true"><j.wuttke@...></a> wrote:
> So far, the best introduction to libyaml I found is
> the tutorial by Andrew Poelstra at
> <a href="http://wpsoftware.net/andrew/pages/libyaml.html" rel="nofollow" moz-do-not-send="true">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 = YAML.load( URL.open("<a rel="nofollow" moz-do-not-send="true">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="+1"><font face="Calibri"><br>
I have a similar question, but in a C program context. 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="moz-txt-link-freetext"
href="http://xmlsoft.org/example.html"
moz-do-not-send="true">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? If so, would you
be willing to share it?<br>
<br>
If not, would there be any value to others (apparently not, if
no one has done it). It seems that it might be relatively
easy 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> <br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Yaml-core mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/yaml-core">https://lists.sourceforge.net/lists/listinfo/yaml-core</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
N Oliver B. Fischer
A Schönhauser Allee 64, 10437 Berlin, Deutschland/Germany
P +49 30 44793251
M +49 178 7903538
E <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
S oliver.b.fischer
J <a class="moz-txt-link-abbreviated" href="mailto:oliver.b.fischer-/[email protected]">oliver.b.fischer-/[email protected]</a>
X <a class="moz-txt-link-freetext" href="http://xing.to/obf">http://xing.to/obf</a>
</pre>
</body>
</html>
--------------9A4CCBB6EAC199EEAF949662--
--===============6609948458706956428==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============6609948458706956428==
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
--===============6609948458706956428==--