Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces
Teuchos_YAML.hpp File Reference

A TeuchosParser Language for a subset of YAML. More...

#include <Teuchos_Language.hpp>
#include <Teuchos_ReaderTables.hpp>

Go to the source code of this file.

Namespaces

 Teuchos
 The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
 

Detailed Description

A TeuchosParser Language for a subset of YAML.

This is a grammar for a subset of the YAML language. Since YAML is indentation-sensitive, it is not context-free. An extension has been made to Teuchos::Reader to emit INDENT and DEDENT tokens in order to make indentation detectable by a context-free grammar.

Known limitations of this grammar compared to the full YAML language, in particular those which are relevant to Teuchos::ParameterList:

  1. INDENT and DEDENT tokens must be matched, meaning the indentation of the YAML file itself must be nicely nested. Examples of valid YAML that this grammar cannot handle, and workarounds:

    # nested block sequences compressed onto one line:
    - - - one
    - two
    - three
    - ten
    - twenty
    - one hundred
    # do not compress the first line:
    -
    -
    - one
    - two
    - three
    - ten
    - twenty
    - one hundred
    # comments not indented the same as subsequent lines:
    all:
    one: 1
    two: 2
    #bad comment
    three: 3
    # indent the comments:
    all:
    one: 1
    two: 2
    #good comment
    three: 3
    # flow sequences and maps that span multiple lines
    timesteps: [1, 2, 3,
    4, 5]
    # keep it on one line, or use block sequences
    timesteps: [1, 2, 3, 4, 5]
    timesteps:
    - 1
    - 2
    - 3
    - 4
    - 5
    # block scalars with non-nested indentation
    inline file: |
    if (a == 5) {
    strange();
    indentation();
    }
    # ensure block scalars have nested indentation
    inline file: |
    if (a == 5) {
    strange();
    indentation();
    }

  2. Scalars can start with a '.' or '-', but not two such symbols in a row

    # ".." at the beginning of a scalar
    filepath: ../cube.exo
    # quote the scalar
    filepath: "../cube.exo"

Definition in file Teuchos_YAML.hpp.