I'm trying to understand how to work with Ada and AdaYaml library (https://github.com/yaml/AdaYaml/). I have several yaml files and I need to transform them into Ada records for further processing.
After several hours of playing with library I have no clue how use Accessor to access yaml data.
My minimal somehow working code is
with Ada.Text_IO;
with Ada.Command_Line;
with Yaml.Source.File;
with Yaml.Source.Text_IO;
with Yaml.Dom.Loading;
with Yaml.Dom.Node;
with Yaml; use Yaml;
with Text; use Text;
procedure Load_Dom is
Input : Source.Pointer;
begin
if Ada.Command_Line.Argument_Count = 0 then
Input := Yaml.Source.Text_IO.As_Source (Ada.Text_IO.Standard_Input);
else
Input := Yaml.Source.File.As_Source (Ada.Command_Line.Argument (1));
end if;
declare
Document : Yaml.Dom.Document_Reference :=
Yaml.Dom.Loading.From_Source (Input);
begin
Ada.Text_IO.Put_Line ("Root node is a " & Yaml.Dom.Node.Instance'(Document.Root.Value).Kind'Img);
Ada.Text_IO.Put_Line ("Root node is a " & Yaml.Dom.Node.Instance'(Document.Root.Value).Tag);
Ada.Text_IO.Put_Line ("Root node is a " & Yaml.Dom.Node.Instance'(Document.Root.Value).Mapping_Style'Img);
end;
end Load_Dom;
I think the explicit conversion Yaml.Dom.Node.Instance'(Document.Root.Value) is not right and I must be missing something.
Any idea or code example how to read yaml file in correct way?