Writing PCRL
Introduction
Automancer protocols are defined in PCRL, a configuration language close to YAML. It is designed to be lightweight and human-readable. It is also used in setup configuration files.
The extension of PCRL is .pcrl
and its media (MIME) type is text/pcrl
. The recommended case is snake case, i.e. snake_case
.
Examples
The following PCRL:
# A comment
database:
server: 192.168.1.1
ports: [8000, 8001, 8002]
connection_max: 5000
options: { enabled: true }
servers:
- name: alpha
ip: 10.0.0.1
dc: eqdc10
- name: beta
ip: 10.0.0.2
dc: eqdc10
Maps to the following JSON:
{
"database": {
"server": "192.168.1.1",
"ports": [8000, 8001, 8002],
"connection_max": 5000,
"options": {
"enabled": true
}
},
"servers": [
{
"name": "alpha",
"ip": "10.0.1",
"dc": "eqdc10"
},
{
"name": "beta",
"ip": "10.0.2",
"dc": "eqdc10"
}
]
}
Comparison with YAML
PCRL is conceptually close to YAML and YAML's syntax highlighting definitions can be used to highlight PCRL, such as in snippets embedded within a Markdown file. When taking a closer look, however, YAML and PCRL have major differences:
- Values in PCRL are either a dictionary, a list, a string or null.
foo: null # foo is None foo: 32 # foo is 32 foo: false # foo is false
- PCRL has no support for nested dictionaries on a single line.
foo: bar: 23 # or foo: { bar: 23 } # instead of foo: bar: 34
- PCRL has no support for JSON structures.
- PCRL has no support for anchors and references.
- PCRL has no support for data typing.
- PCRL has no support for multiple documents.
- PCRL only has the
|
syntax for multiline strings but no support for>
.key: | Not like the brazen giant of Greek fame, With conquering limbs astride from land to land; ... # instead of key: > Not like the brazen giant of Greek fame, With conquering limbs astride from land to land; ...
- PCRL enforces two-spaces indentation.
- PCRL requires one more indentation level when dealing with lists of dictionary of lists.
- a: - b # instead of - a: - b