Dreadow

From Esolang
Jump to navigation Jump to search

Dreadow is an esolang by User:BoundedBeans that looks like a flowery meadow, and is textual, thus the meaning of the code is dependent on the color of the font in each character of the code. It was created after the author caused some minor confusion on the Esolangs wiki making a MediaWiki template that made it easier to color code (after difficulty highlighting a proof concerning THROBOL). It turns out it's fully possible without the template, but annoying. And then the author got obsessed with the idea of a language that's both color-based and textual, so he came up with Dreadow the next day.

Fundamental concepts

Both code and data are stored in a meadow, which is a grid of flowers with signed 32-bit integer coordinates. Positive x is to the right, positive y is down, negative x is to the left, and negative y is up. The code is stored starting at (1, 1), and along with other special data, the (+, +) quadrant is reserved for them. The code must be a rectangle that is a multiple of two flowers in width.

To the right of the code is the branch table. The branch table is 2 flowers wide and the same dimension in height as the code. Using relative coordinates to the top left, (0, x) is a red rose if the line is a currently valid branch point for a specific flower, a cornflower blue lupine if it is an else case, and a pink allium if it isn't a branch point. (1, x) is a flower. If the flower at (1, x) is equal to the pointed cell on the tape, the program will jump to line x in the code. The program checks all lines from top to bottom when a jump is performed, so if multiple lines work for a given flower, the uppermost one will be jumped to. If no lines work but there are one or more else cases, the topmost else case will be chosen. If no lines match and there is no else case, no jump will be performed.

The data of a Dreadow program consists of the meadow, an instruction pointer restricted to the code box, a data pointer, a stack of further data pointers (so that you can always get the pointer back to where you were before when you need to modify the branch table to perform a jump), and a stack of instruction pointers (used for iteration).

Execution

The code executes starting at command 1 of line 1 (which is stored at (1, 1) and (2, 1) in the meadow, command x of line y is stored in (2x - 1, y) and (2x, y)), and executes commands left to right in the line, jumping to the next line if it reaches the end of a line. Jumps can also be performed, but the jump will always be at the beginning of a line.

Flowers

The flowers come in these types, with the appearances of the characters used to represent them loosely matching their real life appearance:

  • Rose, represented by @
  • Allium, represented by *
  • Tulip, represented by U
  • Lupine, represented by %
  • Bean, represented by & (bean flowers are quite irregular in real life, so I feel the ampersand does it justice)

Any of them can come in the following colors (named after their HTML color names):

  • Red, #FF0000
  • Orange, #FFA500
  • Yellow, #FF0000
  • Purple, #800080
  • Pink, #FFC0CB
  • Plum, #DDA0DD
  • CornflowerBlue, #6495ED
  • LightSalmon, #FFA07A

Syntax

There are two syntaxes for this language, Authentic Syntax and Wiki Syntax.

Authentic Syntax

Authentic Syntax is preferable, it consists of multiple lines of the same length that must be a multiple of two. Each character should be one of the flower type representations listed in #Flowers. The character should be actually be colored according to the flower color hex codes listed in #Flowers (to store this in a computer file would require some representation for the color in binary bytes, but this syntax abstracts away how exactly the color is conveyed in a file).

The first line that does not conform to the line length matching is the end of the program, and that line and the line after that can contain any text, but it must not have color.

You can also put comments after a line by putting a colon (:). The comments should also not have color.

Wiki Syntax

Wiki Syntax is a way of representing Dreadow in MediaWiki syntax, so that it can be put on the wiki, and also in other situations where plain text is needed (such as stuff that needs to be copy and pasted, or more primitive interpreters). There is nothing stopping anyone from writing an implementation just for Wiki Syntax, but it is recommended for implementationss to support both.

Wiki Syntax can be defined as Authentic Syntax, except that:

  • Every line is preceded by a space
  • Every character is replaced with <span style="color:[color]">[character]</span>, where [color is replaced with the HTML color name as discussed in #Flowers, and [character] is replaced with the character that is being colors. Characters with no color (in comments) should not have this tag. Span tags should have exactly one character inside, even if there is an adjacent repeat of colors. One note is that & is not special and should not be written as &amp;.
  • Angle brackets and ampersands are not allowed in comments.

Commands

A command is represented by two flowers.

First color, second color, flower types Semantics
Red, any except Red, @* Moves the data pointer to the left.
Orange, any except Orange, U& Moves the data pointer to the right.
Yellow, any except Yellow, *% Moves the data pointer up.
Purple, any except Purple, &@ Moves the data pointer down.
Pink, any except Pink, *U Pushes the data pointer onto the data pointer stack, changes the data pointer to point at the top left of the branch table.
Plum, any except Plum, *U Pushes the data pointer onto the data pointer stack, changes the data pointer to point at the top left of the code.
CornflowerBlue, any except CornflowerBlue, U@ Pops the top of the data pointer stack and puts it into the data pointer.
LightSalmon, any except LightSalmon, ** Pushes the data pointer onto the data pointer stack.
Purple, any, *[Any] Sets the currently pointed cell in the meadow to the the second flower of the command.
Plum, any except Plum, &* Finds the first line assigned as a jump point for red rose by the branch table. Push the current instruction pointer onto the instruction pointer stack, then iterate through all flowers iterating through color first, then type, in the orders listed in the #Flowers section of this article, doing the following:
  • Set the currently pointer meadow cell to the flower.
  • Run the line and continue executing until the (LightSalmon, any except LightSalmon, @U) command is executed.
LightSalmon, any except LightSalmon, @U Pop an entry off the call stack and return to it, though that entry may have more to do (for example, the (Plum, any except Plum, &*) command calls the line again and again until all flowers have been iterated.
Yellow, any except Yellow, *@ Takes the colors of the three cells to the right of the currently pointed cell in the meadow, not including the current cell, forms the colors into octal digits (digits assigned to colors in increasing order based on the order of the flower colors listed in the #Flowers section of this article, most significant digit on the cell directly to the right of the data pointer). Takes the numeric result modulo 256, and outputs it as a byte.
Orange, any except Orange, *@ Takes in a byte of input, converts it to octal, changes the three flowers to the right of the currently pointed cell in the meadow, not including the current cell, to beans with a color corresponding to an octal digit, (digits assigned to colors in increasing order based on the order of the flower colors listed in the #Flowers section of this article, most significant digit on the cell directly to the right of the data pointer).
CornflowerBlue, any except CornflowerBlue, U% Halts the program
LightSalmon, any except LightSalmon, &U No-op.
Red, any except Red, &U Perform a branch based on the branch table and the current cell of the meadow.
Any, Any, (@@, **, or UU) Reserved for extensions.
Anything else Reserved for future expansion of the standard, execution of these may be inconsistent, use (LightSalmon, any except LightSalmon, &U) for a no-op.

Examples

Print "HI"

Authentic (background is green to make it easier to see the lighter colors while not sacrificing the purple, also giving it the grassy feel):

*U&@*@@**@U% @U*&@%U&&@*U

Wiki:

 <span style="color:Plum">*</span><span style="color:LightSalmon">U</span><span style="color:Purple">&</span><span style="color:Orange">@</span><span style="color:Yellow">*</span><span style="color:Pink">@</span><span style="color:Red">@</span><span style="color:Orange">*</span><span style="color:Yellow">*</span><span style="color:Plum">@</span><span style="color:CornflowerBlue">U</span><span style="color:Pink">%</span>
 <span style="color:Orange">@</span><span style="color:Orange">U</span><span style="color:Orange">*</span><span style="color:Red">&</span><span style="color:Pink">@</span><span style="color:Plum">%</span><span style="color:Purple">U</span><span style="color:Yellow">&</span><span style="color:Plum">&</span><span style="color:CornflowerBlue">@</span><span style="color:Red">*</span><span style="color:LightSalmon">U</span>