Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FeepingCreature/59db0470a21d6c4729ed201278fee111 to your computer and use it in GitHub Desktop.
Save FeepingCreature/59db0470a21d6c4729ed201278fee111 to your computer and use it in GitHub Desktop.
SEML: Somewhat Easier Markup Language
# SEML - Somewhat Easier Markup Language
This is a YAML fork intended to avoid having to read the absurdly large YAML spec. Every SEML document is also valid YAML, but not the reverse.
Each file corresponds to a JSON object.
## Grammar
```
ALNUM := Unicode alpha plus digit properties
LETTER := Everything except '\n'
WHITE := ' '*
KEY := ALNUM+
VALUE := LETTER+
INDENT := WHITE*
COMMENT := '/' '/' LETTER*
OBJECT_ENTRY := KEY ':' VALUE?
ARRAY_ENTRY := '-' VALUE?
LINE := INDENT ( | OBJECT_ENTRY | ARRAY_ENTRY ) COMMENT? '\n'
SEML := LINE*
```
## Parsing
Split the file into lines. Remove comments from the end of each line.
Remove empty lines, ie. lines containing only whitespace.
Each line has an indentation, which is the number of spaces in front.
The first line must have an indentation of 0.
### The parsing operation
The parsing operation may recurse. As such, it is parameterized with a minimum indentation.
The parsing operation returns a list of entries, with a length of at least one. Either all entries are
object entries, or all are array entries.
The first line's indentation is the expected indentation. It must be **greater** than the minimum indentation.
Repeat while the current line's indentation is equal to the expected indentation:
If the current element has an optional value, add this
element to the list to be returned.
If the current line is an array element without a value, recurse with the expected indentation.
Add an array of the returned elements to the list to be returned.
If the current line is an object element without a value, recurse with the expected indentation.
Add an object of the returned elements to the list to be returned.
## Example:
```
foo:
bar: baz
whee:
- 1
- 2
-
key: value
```
This corresponds in the JSON object:
```
{
"foo": {
"bar": "baz",
"whee": [
1,
2,
{
"key": "value"
}
]
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment