TOML

Usage

use TOML;

or

import TOML;

Submodules

Support for parsing and writing TOML files.

Chapel’s Library for Tom’s Obvious, Minimal Language (TOML).

Note

The planned features and known limitations of this module can be found in Improve Toml issue.

proc parseToml(input: file): shared Toml

Receives a TOML file as a parameter and outputs a Toml object.

use TOML;

const tomlFile = open("example.toml", ioMode.r);
const toml = parseToml(tomlFile);

To read tables of a TOML file, use the same syntax as accessing associative arrays. For example, to access to the following TOML file’s project name,

[root]
author = "Sam Partee"
name = "example"
version = "1.0.0"

Use the following code in chapel.

use TOML;

const tomlFile = open("example.toml", ioMode.r);
const toml = parseToml(tomlFile);
const projectName = ["root"]["name"] // returns a TOML object
writeln(projectName.toString());     // to turn TOML object into string representation

Note

As of Chapel 1.26.0, TOML objects will print their values in the following manner: If the object contains a root table, it will be printed first. Keys within the root table will be printed in sorted order. All other tables will be printed in a sorted order after root, if it exists. All table keys will be printed in a sorted order. Prior to this change, the root table would print first, followed by keys and other tables in what may have been a non-deterministic manner.

proc parseToml(input: fileReader): shared Toml

Receives a channel to a TOML file as a parameter and outputs a Toml object.

proc parseToml(input: string): shared Toml

Receives a string of TOML format as a parameter and outputs a Toml object

class TomlError: Error
var msg: string
proc init(msg: string)
override proc message()