Gura is a file format for configuration files. Gura is as flexible as YAML and simple and readable like TOML. Its syntax is clear and powerful, yet familiar for YAML/TOML users (from https://github.com/gura-conf/gura). To learn more about Gura, you can read the Official Gura Documentation.
This Gura implementation in Nim emphasizes code that is easy to write and read (NPeg is used in both lexing and parsing), rather than optimizing for execution speed.
https://github.com/khchen/gura
Example:
import gura, json, strutils
const guraString = """
# This is a comment in a Gura configuration file.
# Define a variable named `title` with string value "Gura Example"
title: "Gura Example"
# Define an object with fields `username` and `age`
# with string and integer values, respectively
# Indentation is used to indicate nesting
person:
username: "Stephen"
age: 20
# Define a list of values
# Line breaks are OK when inside arrays
hosts: [
"alpha",
"omega"
]
# Variables can be defined and referenced to avoid repetition
$foreground: "#FFAH84"
color_scheme:
editor: $foreground
ui: $foreground
""".unindent(2)
# Transforms to json node
let node = fromGura(guraString)
# Access a specific field
echo "Title -> ", node["title"]
echo "My username is ", node["person"]["username"]
for host in node["hosts"]:
echo "Host -> ", host
This seems very interesting. I especially like this piece from the Gura spec: