Qwerty

From Esolang
Jump to navigation Jump to search
Qwerty
Paradigm(s) Imperative
Designed by User:Purah126
Appeared in 2023
Memory system Cell-based, Stack-based
Computational class Turing complete
Major implementations Python 3
Influenced by brainfuck, Super Stack!, ///
File extension(s) .qwertyp

Qwerty, an esoteric programming language designed so you can easily translate other languages into it.

The capitalization and only accepted form of the name is "Qwerty".

Specification

Programs are a sequence of commands.

It has a LIFO stack and a tape that is infinite on both sides.

Commands:

Command Meaning
` Reverse the stack
~ Put the last item of the stack on top
! Print the current tape cell’s matching Unicode character
@ Set the nth character of the program to the Unicode character given by the current tape cell, where n is a popped value
# Duplicate the top item of the stack
$ Push the value at the memory address given by the current tape cell
% Set the current tape cell to itself modulo a popped value
^ Negate the current tape cell
& Pop a value and store it at a memory address given by the current tape cell
* Pop a value and multiply the current tape cell by it
( Start a comment
) End a comment
- Pop a value and subtract it from the current tape cell
_ Subtract 1 from the current tape cell
= Jump past the next ] if a popped value is equal to the current tape cell
+ Pop a value and add it to the current tape cell
[ Used as a loop marker
{ Swap top 2 items of stack
] Jump to the matching [
\} Set the current tape cell to the length of the stack
\ Pop a value and floor divide the current tape cell by it
} Print numeric value of the current tape cell, and then a space
; Push the current tape cell onto the stack, setting the current tape cell to 0
: Pop the stack into the current tape cell
Add 1 to the current tape cell
Toggle string mode. In string mode, the characters given are translated into numbers using Unicode and put onto the stack. Also, preceding a character with a \ inserts that literal character
, Move the tape left 1
< Jump past the next ] if a popped value is greater than the current tape cell
. Move the tape right 1
> Jump past the next ] if a popped value is greater than the current tape cell
? Take input, transform it into numbers using Unicode, push it onto the stack
/a/b/ Replace all occurrences of a with b (This is evaluated before the rest of the program)

Computational Class

It is Turing-complete because of the following translation from Brainfuck, which is Turing-complete:

Brainfuck Translation
Program start ;
+ '
- "
< .
> ,
[ [#=
] ]
. !
, ?

Note that it can take multiple input characters, but only the first one will be accepted. Also, the cell width is infinite, but that version of brainfuck is still Turing-complete.

Examples

Hello, World!:

"!dlroW ,olleH":![;=:!]

Cat:

[?`:![;=:!]]

Fibonacci sequence:

';#[:|#+;`]

99 bottles of beer:

/ps/,`:![;=:!]./'''''';''''*[|"bottles of beer on the wall, "ps|"bottles of beer. "ps"Take one down, pass it around, "ps_|"bottles of beer on the wall.

"ps;#=:]

Translations

These are some ways to translate other languages into Qwerty.

Deadfish:

Deadfish Qwerty
i '
d _
s ;#:*
o |

Optional extension commands

These are some optional extension commands: (Will be extended in the future)

Command Meaning
Immediately followed by a comment, that comment will be put into a new thread, thread #current tape cell value
Like ≠ but creates a daemon thread
§ Wait until thread #current tape cell value is finished

Interpreters

Python 3 (Does not support extension commands yet)