TOML¶
Usage
use TOML;
or
import TOML;
Submodules
Chapel’s Library for Tom’s Obvious, Minimal Language (TOML). This module provides support for parsing and writing toml files.
Note
The planned features and known limitations of this module can be found in Improve Toml issue.
- proc parseToml(input: file): unmanaged 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: channel): unmanaged Toml
Receives a channel to a TOML file as a parameter and outputs a Toml object.
- proc parseToml(input: string): unmanaged Toml
Receives a string of TOML format as a parameter and outputs a Toml object