Writeover

From Esolang
Jump to navigation Jump to search

Writeover is a string-uncertainty language by User:PythonshellDebugwindow made in 2019 or 2020.

"String-uncertainty language"?

Rather than being a string-matching language, such as regex, Writeover is a string-uncertainty language. This means that each program produces a variety of possibilities. Consider the program {A|B}. In a string-matching language, this would match either A or B, but in a string-uncertainty language, it would produce a list of all possible options: [A, B]. Similarly, {A|{B|C}D} would produce the list [A, BD, CD]. For some reason, {A|B} is still said to match A or B.

Syntax

A program is a string of characters out of which a list of possibilities ("matches") will be derived. Some characters are metacharacters, and all other characters represent themselves. No newlines or carriage returns are allowed. The following is a list of metacharacters.

Backslash

The \ backslash character escapes the metacharacter in front of it, the only way to match a metacharacter. If followed by a normal character, it simply matches that character.

Curly braces

If there's no | pipe character in them, the { } curly braces match either their contents or nothing. Otherwise, their contents are separated by pipe characters, and any of those separated contents can be matched.

Dollars sign

The $ dollars sign is the same as the { } curly braces, except its contents are considered to be all characters between it and the next space character (the space isn't part of its contents). Also, if it ends with a | pipe character, a space can be matched as well as its contents. If followed immediately by a space character, matches that space or nothing. A{B$C}D matches AD, ABC, or ABCD.

Backquote

The ` backquote is the same as the $ dollars sign, except it terminates at any non-A-Za-z0-9_ character. If followed immediately by a terminating character, matches that character or nothing. $A`B|C produces [A, AB, C], not [ε, AB, AC], e.g. the pipe character associates with $ over ` when it can.

Pipe character

When outside of all other metacharacters, the | pipe character matches either that to its left or that to its right, delimited by spaces. For example, A B|C D doesn't produce [A B, C D] but instead produces [A B D, A C D].

Options

These options control the behaviour of the language. Lowercasing an option turns it on, capitalizing it turns it off.

Option Description Default
a Automatically fix capitalization (e.g., Hello. $Good day. matches [Hello. Good day., Hello. Day.]) On
b C D matches [A B, C D] instead of [A B D, A C D]) Off
i Case-insensitivity (exponentially raises the amount of possibilities generated) Off
q Automatically removes spaces after left-double-quotes and before right-double-quotes On
s Automatically removes double spaces, triple spaces, etc. On
u Make underscores match spaces (e.g., you can replace A {B C D} E with A $B_C_D E; good for golfing programs a bit) Off

Power

Obviously considerably less than that of regular expressions, as it has no wildcards or Kleene closures. Then again, it wasn't meant for programming in, but rather for representing multiple possible options at a time.

Examples

Hello World:

Hello World

Any of "Regular expression!", "Regex expression!", or "Regexp expression!", each optionally with an "s" before the exclamation mark:

Reg$ex`p|ular expression`s!