The delim system is a small collection of rules in the design of programming and data languages. Any language that follows these rules can be embedded in any other language that follows these rules.
In the delim system, there are 3 pairs of delims: (), [], and {}. There are also raw delims, which start with a backtick, then have a sequence of characters called the pattern, and finally an opening delim. They are then closed by the matching closing delim, followed by a repeat of the pattern, and finally another backtick.[1!]
Valid delims:
(A delim in parentheses) `(A raw delim)` `hello(A raw delim with "hello" as the pattern)hello` `x( A `x()` confusing )y` raw ]x` delim ` that ends here->)x`
Invalid delims:
(This delim doesn't match with the correct one] (This delim contains a ` backtick) `!(This delim contains an illegal character in the pattern)!`
There is also an additional rule for raw line delims, explained below.
To preserve this system, comments that go to the end of line stop when they encounter a closing delim. And if they contain an open delim, they keep going until the end of the line after that delim is closed.
# This is a comment. (It ends not here, -> and not here->), but here -> print("Hello, world!" # This is a comment, and it ends here->);
Note that this is just a suggestion for how to support line comments in a delim language. Line comments like this are not part of the delim system. They can never cause delim errors, so any delim language can safely treat "#" like any other character.
Also note that line comments must not be removed, since that would make them be a sort of escape character. Instead they should be skipped over by the interpreter or compiler. For example if you have the following code, the text after the # should clearly not be removed:
html(<a href="#toc">Jump To Table Of Contents</a>)
Even though line comments are not part of the delim system, the fact that delim systems that support line comments cannot contain unmatched delims can be less pleasant. For this reason, we add these extra rules for raw line delims:
The rule is this: given a "delim language" following the delim rules and an "escape language" that has escape codes, the delim language can contain the escape language, but the escape language cannot contain the delim language.
For two simple examples where escape codes cause problems, if you tried to embed a delim language in html:
html(<delimLang>( [1, 2, 3]</delimLang>) html(<p></p>) html(<delimLang>html(<p></p>)</delimLang>)
In the first example, ( is the escape code for an open parenthesis. This means the content of the html does not actually follow the delim rules, even though someone who didn't know html would think it did.
In the second example, we can see that due to escape codes, html cannot be embedded into itself without escaping, which breaks the delim system.
This idea is original to us. See the original blog post on the subject:
[1!] ^ 0 1 2 3 4 Galene's Personal Blog. Delim System. 2021. Retrieved 2021-02-15.[^]
Date: 2021-02-15
Latest Edit: 2021-02-16
Author: Galene