[meta] {
[title] Sona, a new markup language
[subtitle] Yes, another one.
[author] Vince Mutolo
[date] \today
}
[content] {
// The `paragraph` environment knows to concatenate all the `TextBlock`s in its scope.
[paragraph] {
This is very interesting. Now, how do I ensure that this paragraph actually stays
intact when I create a new environment? I want to create the environment *within*
the paragraph. That's the tricky part.
Now you can have as many line breaks as your heart desires.
}
[section] {
[name] The Spec
[code] {
[lang] ebnf
\raw##{
scope = scope name, [whitespace], scope body, [whitespace];
scope name = "[" , ident , "]";
scope body = (scope explicit body | scope implicit body);
scope explicit body = scope body open , { scope body contents } , scope body close;
scope body contents = ? TODO ?;
(*
* Everything below here should probably be part of the lexer. The following rules
* won't be context-free. They should be matched with higher rules having higher
* precedence.
*)
escaped pipe = "\|";
escaped left brace = "\{";
escaped right brace = "\}";
escaped left bracket = "\[";
escaped right bracket = "\]";
ident = ident char, { ident char };
ident char = codepoint - (whitespace | reserved);
reserved = "{" | "}" | "[" | "]" | "|";
codepoint = ? any valid UTF-8 codepoint ?;
whitespace = ? a codepoint with Unicode Derived Core Property White_Space=yes ?;
(*
* Macros begin with "|ident{" and end with "}|", like: |math{a}| or |today{}|.
* Once the lexer identifies a MACRO_OPEN token, it must continue through the
* stream of bytes until it finds a MACRO_CLOSE with the same number of closing
* braces as the MACRO_OPEN has opening braces. Everything between the MACRO_NAME
* and MACRO_CLOSE must be considered part of the MACRO_BODY token.
*)
macro = macro open, macro name, "{", { "{" } macro body, { "}" }, "}" macro close;
macro open = "|";
macro close = "|";
macro name = ident;
macro body = { codepoint }
scope name open = "[";
scope name close = "]";
scope body open = "{";
scope body close = "}";
}##
}
}
[section] {
Let's try it out. Here's a mathematical equation.
\t[ A^2 + B^2 + C^2 \leq \mathrm{hi} ]
\macro_name#[today]#
\m#{ A^2 + \frac{A}{B} }#
}
[section] {
Here's how one might do a config file.
[config] {
[num_tries] 30
[max_score] 100.0
[waypoint] {
[x] 10
[y] -3
}
}
}
}