Parsing aliases (not)

Aliases in the YAML are processed and replaced with the aliased anchor when the document gets parsed.

maps:
    seq1: &alias1
    - scalar1
    - scalar2
    seq2: *alias1

Parsing this document results in a x::yaml::document whose root() returns a x::yaml::mappingnode with one mapping. Its key is a x::yaml::scalarnode maps, and its value is another x::yaml::mappingnode with two mappings.

The first of the two mappings has a x::yaml::scalarnode key of seq1, and the value of a x::yaml::sequencenode containing two x::yaml::scalarnodes of scalar1 and scalar2. The second mapping's x::yaml::scalarnode key is seq2, and the value is the same x::yaml::sequencenode. Each alias, in the YAML document gets replaced by its anchor node. The resulting document should be processed without making any particular considerations for aliases.

Note

It's possible to create circular references using aliases, like this:

yaml:
    name1: &alias1
        key1: value1
        key2: *alias1

Retrieving the value of the key2 mapping comes back with the value of the name1 mapping, the same mapping with the alias reference.

This gets handled by the underlying LibYAML parser, and due to the nature of LibYAML's internal structures this does not create an internal circular reference or a memory leak. Provided, of course, that a circular reference or a memory leak does not get created indirectly as a result of processing the recursive alias.