SNUSP


SNUSP (acronym for SNUSP’s Not Unix, goal Structured PATH ) is a programming language exotic resulting from the processing Brainfuck in a language in two dimensions, based on a language called PATH [ref. Required] .

The instruction set of SNUSP is closer brainfuck as PATH, maintaining the same syntax for memory instructions ( + , - , > and < ) and input / output ( . And , ). Flow control instructions of brainfuck ( ] and [ ) are replaced by four SNUSP instructions to manage the two-dimensional flow: / , \ , ? And ! .

Features

All statements are represented by a non-numeric character.

The execution of an SNUSP program starts with the $ character , or if it is absent from the source code, with the topmost and left-hand character of the program, ie the first character of the file. The execution begins to the right in a straight line, one character at a time, until a change of direction instruction changes the execution flow.

The two basic flow control commands , ruld ( \ ) and lurd ( / ), cause a 90 ° turn to change direction of execution. They can be seen as mirrors. As in brainfuck , all alphanumeric characters are ignored and can be used as comments. In fact, comments may even contain valid statements, as long as the execution stream does not pass through. Adding valid statements to areas where the execution stream does not pass allows you to write impenetrable code . In the following example, execution starts at $ and follows the path traced around the comment.

As a result, the program will not display anything, despite the presence of an output instruction ( . ). The characters = and | Are ignored during execution and allow the programmer and possible readers to better follow the execution flow.

 / =========== #
 | This is a
$ == / comment.

In addition to the instructions to change the direction of the execution stream, there is an unconditional jump instruction ( ! ) That ignores the next character, and a conditional jump instruction ( ? ) That ignores the next character if and only if If the current memory cell contains zero.

Functions can be created by the enter ( @ ) and leave ( # ) statements :

$ === before ==== @ \ === after === #
 |
 \ === la = function === #

The enter statement ‘stacks’ its position and the direction of the execution stream in the call stack . This information is used by the leave statement , which ‘unpacks’ (resumes the last information) the call stack and returns to the saved location. To avoid making an infinite loop, the character following @ is ignored. If the stack is empty, the leave statement causes the program to stop.

Specification

The language is compartmentalized in 3 languages ​​of increasing power, each containing the preceding one:

Core SNUSP
Equivalent of the potential Brainfuck with a quasi-equivalent semantics.
Modular SNUSP
Add functions by entering a call stack and the enter ( @ ) and leave ( # ) statements .
Bloated SNUSP
Adds simultaneity and non-determinism.

However, here is the address of an interview to evolve in a language SRFI -style extension model more scalable 1 .

Example

This SNUSP code calculates the quotient and the remainder obtained by the Euclidean division of two single – digit decimal numbers from the standard input :

 / ==! / ============ atoi = @@@@ = ​​@@ = - #
 | | / ==! / ==== itoa = @@@@ = ​​@@ = ++ #
 | | | |
$, @ />, @ / @ \ @ /. <@ /. #
 | / - \
 \ === div =? \ <! \? / #! === + <<< \ / -
 \ <== @ \> @ \ >>! /?! / = <? \>! \? / << #
 | | # \ -> -> + </
 \ =! \ =?! / - >> + <<? \ #
 # \? << + >> - /

In the above program, the conversion of ASCII digits into an integer is made by the atoi and itoa functions , while the actual calculation is performed by the div function . Finally, the result is displayed by the standard output .

Another example implanting the function of Ackermann :

 / ==! / == atoi = @@@@ = ​​@@ = - #
 | |
 | | [J] {i} -> {A (i, j)}, where A is the function of Ackermann
 | | / ========= \! == \! ==== \ ** recursive **
$, @ />, @ / == ack =! \? \ <+ # | | | A (0, j) -> j + 1
 Ji \ <? \ +> - @ / # | | A (i, 0) -> A (i-1.1)
 (I, j) -> A (i-1, A (i, j-1))
 {A} [] [0] # # | | |
 {0} [] [a] / - << + >> \! = / \ ===== | == @ \ >>> @ \ << # {a}
 (A> 0)? ? | | | [A] {} [a]
 [0] [] {a} \ >> + << - /! ========== / | |
 [A] [] {0} # # | |
 {A} [] [0] [0] | | [0] [] [] {a}
 {0} [] [a] [a] | | [A] [] [] {0}
 # /? ======== \! == / \ ==! / =======? \ #
 \ - >> +> + <<< / \ >>> + <<< - /

As in the previous example, this program reads two decimal ASCII digits, converts them to integers, and uses them as parameters of the ack function .
However, in this case, the result of the function is never displayed by the standard output; It can only be retrieved by using a debugger. Due to the extreme rate of growth function of Ackermann, the result of the majority of entries would not fit in a single decimal number to a single digit; Thus, a simple call to the ito function would not suffice here.

Comments resembling {a} [] [0] comment on the state of the stack for each function. The layout of the stack prior to execution of the function is written first, while the resulting layout is written below or to the right. Each cell is framed, and the braces surround the current cell.

The program that uses the Ackermann function demonstrates a remarkable property of Befunge derived languages : code can be executed in two directions. This is used by the loop that moves a value of two cells upward, while being able to move a value of two cells down simply by running in the opposite direction!

To complete the program, the following function can be used to display the result in a multi-digit decimal ASCII number:

 / Recursive \ # /? \ Zero
== print10 =! \ @ \>?! \ @ / <@ \.! \ - /
 | \ = / \ == itoa = @@@ + @ +++++ #
 ! / +! / +! / +! / + \ Mod10
 / <?> - \!? - \!? - \!? - \!? - \!
 \?! \ -?! \ -?! \ -?! \ -?! \ -? / \ Div10
 # + /! + /! + /! + /! + /

Notes and references

  1. ↑ ” Snusp Language [ archive ] .

GeekPrank.com will make everyone believe they are looking at a real Windows XP operating system, but the thruth is that this is just a simulator running in a web browser.