Parse this sic: Revised
Parse this sic: Revised is a self-modifying one-dimensional stack-based esoteric programming language created by User:Digital Hunter in 2024. The idea to create a streamlined successor to Parse this sic had been stewing for some time. The language name may be read in any way that allows it to end in "-ic".
Language overview
Parse this sic: Revised (henceforth also "PTSR") is a one-dimensional language; programs are executed by way of an instruction pointer that obeys simple rules. Parse this sic: Revised is stack-based; the primary data structure is a global stack, with which most of the basic instructions interact. Parse this sic: Revised programs may be self-modifying; a program may alter its own source code at runtime, and most values can be redefined.
The datatypes in PTSR are strings (of at least zero characters) and integers.
By inherited tradition from Parse this sic, the strings are called words and the integers are called numbers.
There are no integer literals in PTSR, but every word has an associated numerical value (details to follow) and can be used for math directly.
For this documentation, words will be denoted with a "
and numbers are expressed in decimal and denoted with #
.
For example, "yippee
and #256
are a word and a number, respectively.
A PTSR program's source code is indexed by character, starting with the first character with index 1 up to the last character with index equal to the length of the program. Greater positive indices effectively "wrap around" the edge of the program; for a program of length 9, characters 9 through 10 are the final and first characters of the program, respectively. Zero and negative indices are legal as well, with the caveat that they are effectively aliases for indices of value greater than their own by the length of the program; if a program is length 9, then index 0 is treated exactly like index 9 would be;
- Characters -9 through 1 are the final and first characters of the program, respectively.
- Characters 1 through 0 are the entire program.
- Characters 0 through 1 are the entire program, reversed.
Word value
The numerical value of a word s is determined as follows:
- If s is empty, its value is zero.
- Otherwise, if s is a single character, its value is one.
- Otherwise, interpret the first character of s as a delineator for buckets.
- Each bucket represents a prime number (2, 3, 5, 7, 11, ..) in order, and the value of the substring contained in each bucket is used as the power of the corresponding prime number.
For example, the word "yippee
is greater than one character long, so we use the character y
to separate the rest of the word into buckets.
There is only one bucket, containing "ippee
, so "yippee
has a value of 2^(value of "ippee
).
The process is recursive, naturally, and a few steps later we find that "yippee
has a value of #256
.
The value of a number is itself.
Commands
The character under the instruction pointer is checked against a table like the below.
Note, the stack behaves as though it begins initialised with infinitely many empty words "
.
Instruction | Description | Nickname |
---|---|---|
( and )
|
Delimit "parentheticals", structures containing zero to three parameters that do different things depending on the number of parameters. When an instruction or parenthetical is found inside of a parenthetical, it is said to evaluate to something. | |
+
|
Pops a word or number from the stack, and jumps the instruction pointer to an index corresponding to the popped value. Evaluates to whatever was popped. | Jump star |
-
|
Flips the direction of the instruction pointer (which begins moving left-to-right). Indices of characters of the program source code update based on the direction the code pointer is moving. Evaluates to the empty word. | Flip bar |
*
|
Pops a word or number from the stack. If inside of a parenthetical, simply evaluates to whatever was popped. Otherwise, writes as output what was popped iff it was a word (fails to output numbers). | Pop star |
/
|
Peeks the top of the stack. If the peeked's value is less than one and the instruction pointer is moving left-to-right, or if the value is positive and the instruction pointer is moving right-to-left, then the instruction pointer is moved past the next / in the program. Otherwise, nothing happens. Evaluates to whatever was peeked.
|
Conditional bar |
&
|
Evaluates to the "current word" and resets it to empty, ending word-reading, described later. | Existential star |
|
|
Moves the instruction pointer to past the next | , and evaluates to its own index in the program (smallest valid positive value).
|
Skip bar |
=
|
Halts program execution. | "Gargargar" |
Anything else | Begins "word-reading": the instruction pointer advances as normal, but every character (including this one) is added to the "current word" instead of being executed, until a & is encountered.
|
Parentheticals
(
s serve to open parentheticals when the instruction pointer is moving right and close them otherwise, just as )
s open parentheticals when the instruction pointer is moving left and close them otherwise.
Parentheticals with zero parameters evaluate to user input; this must be a string but is otherwise implementation-defined. Parentheticals with one parameter push their contents to the stack, and evaluate to whatever was pushed. Parentheticals with two parameters evaluate to what would be the result of word-reading beginning at the index set by their first parameter's value and ending at that set by their second's.
Parentheticals with three parameters behave differently depending on what their first parameter ("head") is:
Head | Description | Nickname |
---|---|---|
"ame
|
Evaluates to the sum of the values of the other two parameters. | ameliorate |
"dom
|
Evaluates to a difference, where the values of the second and third parameters are the minuend and subtrahend, respectively. | dominate |
"tim
|
Evaluates to the product of the values of the other two parameters. | times |
"spa
|
Evaluates to a quotient, where the values of the second and third parameters are the dividend and divisor, respectively. If the value of the third parameter is zero, this instead evaluates to the empty word " .
|
spaces |
"wal
|
The second parameter is executed as a PTSR program that inherits its parent's memories, though the only side effect after completion is in changes made to the stack. Instead of evaluating to user input, zero-params evaluate to the third parameter. Instead of writing to output, surface * inside the second parameter concatenate to form the word to which this evaluates.
|
walking |
"suc
|
Attempts to replace the next instance of the second parameter in the program body with the third parameter; if this attempt results in a change, evaluates to the second parameter. It evaluates to the empty word " otherwise.
|
succeed |
"dit
|
If the second and third parameters are equal (and the same type), evaluates to them. It evaluates to the empty word " otherwise.
|
ditto |
Anything else | Declares a "redefinition", which affects henceforth whenever the head is used as a parameter to a parenthetical anywhere except as the head of another three-param. If either of the other two parameters is empty, then the redefinition is to the other. Otherwise, both must be words and the redefinition is to their concatenation. If a redefined word or number is a parameter to a parenthetical anywhere except as the head of a three-param, it is treated as though it were its redefinition instead. Evaluates to the redefinition. | redef |
"wal
, "suc
, and redefinitions will fail in certain situations involving numbers, just as surface *
does.
walking
The "inherited memories" are the current state of the stack, existing redefinitions, and instruction pointer direction. The first character executed of the child program is the one that would have an index of 1. Note, as described in the table, only changes to the stack are communicated back to the parent program; new redefinitions (and changes to the instruction pointer's direction) are not.
succeed
The replacee must exist somewhere as a substring of the program's code; this is the only feature of PTSR that fails to pretend that the program is a circle. Note, if the replacee is expressed as a "literal" in the parenthetical itself, it will always be able to be replaced at least once.
Computational class
It stands to reason that PTSR is computationally equivalent to its predecessor, though a formal proof or demonstration has yet to be constructed.
Examples
Look-and-say sequence
Uses the version also known as the "Say what you see sequence": the rule starting with "1"
and continuing indefinitely. No end condition.
(o&&,&)(p&&aah&)(suc&((n&&1&)ollyoop&)&)123&-/(&*)(s&&*)(c& &&)|(*&pp&p)(&&&n)(&*&o)(*&o&cus)*((((&,&n&t))))(*&)/(((&,((&p&p))&tid)&.&mod))& |((((dom&)1&(p&&(ame&p&1&)))(*1&p&)))((dit&(*)s&))/(**)(c&&(ame&c&1&))(yeetyi&)+ /(**)(n&n&(t&(c&c&)s&))(.&)+,|_