Flatconf markup language

This document describes markup language used e.g. for creating configuration in Flatconf 2.0.

Syntax

# this is a comment
variable1 = "value1"
variable2="value2"     # spaces around '=' are optional

# simple list, order matters
list1 = { "foobar", "foo", "bar" }

# commas are optional, other formatting
list2 = {
  "element1"
  "element2"
  "element3"
}

# hashes are lists with keys
list3 = { key1: "value1", key2: "value2", "value3", key3: "value4" }

# long text
file = >THIS-MARK
All
    these
          are
              file
                   contents
THIS-MARK

# read file contents
file2 = @"filename.txt"

# other filespaces (ie. virtual root dirs)
file3 = @space1:"/filename.txt"
file4 = @space2:"/dir/file.txt"

# execs - interpret the output
file5 = !"/usr/bin/program arg1 arg2"
file6 = !mybin:"/program arg1 arg2"

# execs, but only shell scripts
file7 = !@"script.sh"            # note: impossible to pass any arguments like in file6
file8 = !>EOF
echo '{ "foobar1", "foobar2" }'
EOF

# adding new elements to list3
list3 += { "value5", @"value6.txt", !space:"/script7.sh arg3" }

# overwriting elements in list3
list3 += { key1: "newvalue" }

## inclusion of other FCML files or their portions
# include (add to current root) whole $space1/dir/file.fc
include %"/dir/file.fc"

# include one specific var
var1 = %space1:"/dir/file.fc":list3/key1/slot3

# merge external array
list3 += %"var.fc":somearray

Remarks

  1. when parsing <file>, if <file>.d directory is present, all files in this directory having the same extension as <file>, are virtually appended to the basic file; however, the basic file has to already exist
  2. arrays can be multidimensional and have entries with textual keys apart of numerical indices
  3. filespaces are simply different real (physical) paths of conceptual "/" directory
  4. execution of embedded scripts should happen via providing script contents to stdin of 'sh -s -- arg1 arg2 ...'
    • filespace paths should be exported via FCML_<space name>