|Computational class||Category: Unknown computational class|
|Influenced by||Thue, InterpretMe, Slashes|
This language is both impossible to describe and program in. Thankfully, the associated metalanguage is not quite so esoteric.
Grue is named for the creatures that consume adventurers lost in the dark. User:PixelatedStarfish stumbled into Grue on a sleepless night in 2021.
The metalanguage can describe a complete interpreter for the language, but it cannot do so in finite space or time.
The metalanguage is a simple string replacement language with one operation, the semi-colon.
The following rules apply:
- A line with no semi-colon is a comment.
- A string to the left of the semi-colon is assigned a string to the right of the semi-colon. A newline follows. At execution the string on the left is replaced with that on the right. This is called a replacement.
- A program in this metalanguage can have as many lines as a programmer would like.
- The output is printed when the last line executes. The input file should have a name equal to the output.
- Note that foo.grue is a stand-in for the current filename; it is replaced with the current file name in source at run time.
- The content of the file in use is unknowable to anyone that might open it. Whatever might be readable is not Grue source code, but an imperfect facsimile of Grue source code.
- An interpreter for this language is free to generate whatever errors it likes.
- Execution halts when a filename does not have an associated replacement such that the current name is on the left hand side and the next name is on the right.
- A blank string on the left side of a semi-colon is equivalent to a randomly selected non-blank string of the substrings listed in previous replacements. If there are no substrings available a random string is generated instead.
- A blank string on the right hand side of a semi-colon is equivalent to a random string or filename that has not been a substring in a previous replacement.
- Blank replacements evaluate from the left hand side to the right, such that the left side is defined first.
- If a collision occurs, such that two replacements have the same string on the left hand side, a replacement will be chosen at random from the replacements that have collided.
- A Grue interpreter is defined as an infinite sequence of blank replacements such that each one can be fully defined.
- A Grue meta-interpreter functions according to the above rules, such that it interprets its own designer’s interpretation of Grue.
File Name Generator
Random Number (1-10)
foo.grue;1 foo.grue;2 foo.grue;3 foo.grue;4 foo.grue;5 foo.grue;6 foo.grue;7 foo.grue;8 foo.grue;9 foo.grue;10
The interpreter should do the following:
- If there are no replacements execution ends. If there are replacements, continue to step 2.
- Identify the left and right sides of all replacements and stores them such that the index on the left is replaced by that on the right. Note that if there are multiple semicolons, the leftmost semicolon divides strings, others are part of a string.
- Process any blank strings.
- Construct a parse tree or replacements with root "foo.grue" and branches being all strings on the right side of replacement that have a left side of "foo.grue".
- Assigns priority to replacements based on depth from root on the left hand side, such that root has highest priority.
- Sort replacements by priority, and run them; substituting "foo.grue" with the filename as needed as a path down the parse tree is traversed.