SWI-Prolog YAML library
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Regular Expression library
      • SWI-Prolog C-library
      • SWI-Prolog Source Documentation Version 2
      • SWI-Prolog Unicode library
      • SWI-Prolog YAML library
        • library(yaml): Process YAML data
      • SWI-Prolog Natural Language Processing Primitives
      • Prolog Unit Tests
      • Constraint Query Language A high level interface to SQL databases
      • SWI-Prolog SGML/XML parser
      • SWI-Prolog SSL Interface
      • SWI-Prolog RDF parser
      • mqi -- Python and Other Programming Languge Integration for SWI Prolog
      • Paxos -- a SWI-Prolog replicating key-value store
      • SWI-Prolog HTTP support
      • STOMP -- a SWI-Prolog STOMP client
      • Redis -- a SWI-Prolog client for redis
      • SWI-Prolog binding to BSD libedit
      • SWI-Prolog binding to zlib
      • SWI-Prolog ODBC Interface
      • A C++ interface to SWI-Prolog
      • SWI-Prolog binding to GNU readline
      • Pengines: Web Logic Programming Made Easy
      • Transparent Inter-Process Communications (TIPC) libraries
      • Google's Protocol Buffers Library
      • Managing external tables for SWI-Prolog
      • SWI-Prolog Semantic Web Library 3.0
      • SWI-Prolog binding to libarchive
SWI-Prolog YAML library
Jan Wielemaker
VU University Amsterdam
CWI, Amsterdam
The Netherlands
E-mail: J.Wielemaker@vu.nl
Abstract
This package reads and writes YAML documents from and to SWI-Prolog streams, files and strings. It is based on libyaml. This C library is being used by several languages. Using this C library provides good performance, and interoperability with YALM infrastructure used by other systems.

Table of Contents

1 library(yaml): Process YAML data

1 library(yaml): Process YAML data

This module parses YAML serialized data into a Prolog term with structure that is compatible with the JSON library. This library is a wrapper around the C library libyaml. This library forms the basis of the YAML support in several languages and thus guarantees compatibility of our YAML support with other languages.

[det]yaml_read(+Input, -DOM)
Parse Input to a YALM DOM. The DOM representation uses the following mapping:

  • A YAML sequence is mapped to a Prolog List.
  • A YAML mapping is mapped to a Prolog dict.
  • Untagged scalars follow the implicit tag rules defined by YAML, providing numbers (int, float and special floats), null and the booleans true and false. Other untagged values are returned as a Prolog string. Tagged values are returned as tag(Tag, String) which is processed by yalm_tagged/3. This internal predicate calls the user hook yaml:tagged/3 with the same arguments and, if the hook fails, provides the following defaults:

    • !!binary converts the Base64 to a string of bytes.
    • !!str explicitly keeps a string
    • !!null translates "null" to null
    • !!bool translates to true and false
    • !!int translates to an integer
    • !!float translates to a float
    • Anything else is returned as tag(Tag, String)
Input is one of (1) a stream, (2) a term string(Data) or (3) a file name.
[det]yaml_write(+Out:stream, +DOM)
[det]yaml_write(+Out:stream, +DOM, +Options)
Emit a YAML DOM object as a serialized YAML document to the stream Out. Options processed are:
canonical(+Boolean)
Use canonical representation. Default is false.
unicode(+Boolean)
Use unicode Default is true.
implicit(+Boolean)
Use implicit or explicit representation. Currently only affects the opening and closing the document. Default is true. Use false for embedded documents.
factorize(+Boolean)
If true, minimize the term by factoring out common structures and use &anchor and *anchor. Factorization is always used if DOM is a cyclic term.
[semidet,multifile]tagged(+Tag, ?String, ?Value)
Hook that allows convering !!tag values to be decoded or encoded.

Index

?
tagged/3
yaml_read/2
yaml_write/2
yaml_write/3