Skip to main content

module lang::yaml::Model


AST model for YAML (loosely based on the serialization model of


import lang::yaml::Model;


import List;
import Map;
import Set;

data Node

data Node  
= sequence(list[Node] \list)
| scalar(value \value)
| reference(int anchor)
| mapping(map[Node, Node] \map)

function loadYAML

Node loadYAML(str src)

function dumpYAML

str dumpYAML(Node yaml)

function checkYAML

set[str] checkYAML(Node n)

function badAnchors

set[Node] badAnchors(Node n)

function wronglyTypedScalars

set[Node] wronglyTypedScalars(Node n)

function okValue

bool okValue(type[&T <: value] _, value v)

function unsupportedTypes

set[type[value]] unsupportedTypes(Node n)

function untaggedScalars

set[Node] untaggedScalars(Node n)

function duplicateAnchors

set[int] duplicateAnchors(Node n)

function undefinedRefs

tuple[set[int], set[int]] undefinedRefs(reference(i), set[int] seen, set[int] dupl)

tuple[set[int], set[int]] undefinedRefs(s:sequence(ns), set[int] seen, set[int] dupl)

tuple[set[int], set[int]] undefinedRefs(nod:mapping(m), set[int] seen, set[int] dupl)

default tuple[set[int], set[int]] undefinedRefs(Node n, set[int] seen, set[int] dupl)

function equalNodes

bool equalNodes(Node x, Node y)


test testLoadDump

public test bool testLoadDump() {
Node n = loadYAML(TEST_YAML);
str y = dumpYAML(n);
return equalNodes(n, loadYAML(y));