HQ9^

From Esolang
Jump to navigation Jump to search

HQ9^ is an esolang by User:BoundedBeans, which is a lot like HQ9+, but capable of computation and much, much weirder.

Storage

There are many storage locations:

  • An accumulator. It is unbounded and can be positive, negative, or zero, but Emmental evaluation only deals with the last 8 bits (others are left intact), and Deadfish cannot have it be -1 or 256.
  • A stack of unbounded integers just like the accumulator.
  • A tape of unbounded integers, unbounded to the right. (used for Brainfuck).
  • A stack of bytes. (used for Emmental)
  • A queue of bytes. (used for Emmental)
  • A stack that can contain characters, operations, and interpreters. (used for Mascarpone)
  • A current interpreter. (used for Mascarpone).
  • A bit storage. (used for Bit**)
  • A stack of characters. (used for PDAsephone)
  • A stack of push-down automata. (used for PDAsephone)

Commands

H - Prints "Hello world!" and pushes 47 to the stack.
Q - Prints the source code up to the accumulatorth character. 
However, this actually runs the code while printing it, making loops possible with Q.
It prints each character after that character has executed, so if a program is H++Q, it will print "Hello world!Hello world!H+". 
Once that is done, it goes back to where it was previously, along with interpreting the next 103 characters as PDAsephone (the two stacks are saved).
9 - Prints the lyrics to accumulator bottles of beer on the wall, and throws an error with a
number printed corresponding to the accumulator
^ - Pops from the stack into the accumulator
+ - Increments the accumulator and adds the top two values on the stack, if they exist
- - Decrements the accumulator and subtracts 5 from the top value on the stack
I - Throws an error based on a Unicode character of input.
D - deletes all code before this character upon reaching it. This affects the Q command.
If it deletes the opening bracket of the current try-finally, it makes the code interpret as:
  * Deadfish for 173 characters
  * Brainfuck for 409 characters 
    (the final pointed cell becomes the new accumulator, but all other cells are saved)
  * Emmental for 722 characters
    (the stack, queue, and definitions are saved across calls, and the top of the stack is the accumulator)
  * Mascarpone for 531 characters
    (the stack and currents interpreter are saved across calls, and the accumulator is set to its previous value)
    (accumulator 'H' characters are pushed onto the stack, and the number of H characters becomes the new accumulator at the end)
Then, it repairs the try-finally by inserting opening brackets before it.
[(code)|(number):(code)] - Try finally.
This does not actually catch any errors, but runs the code no matter what, but only if either there is no error 
or the error matches. If an error actually has occurred, the program halts after the finally block finishes, but these can be arbitrarily nested, allowing the program to
continue based on the accumulator. This can have as many finally blocks as needed.
! - don't print anything for the following command, but do all the other things the command does,
plus interpreting the next 296 characters as Bit** (accumulator is the accumulator, storage is saved)

Examples

Hello world

H

Run PDAsephone code

Q@"z_"1"0"0"0%"1_"1"1"0"0%"2_"1"2"0"0%"3_"1"3"0"0%"0"0"1"0"z"0%"0"1"1"1"z"0%"0"2"1"2"z"0%"0"3"1"3"z"0%"0Q"1"1"0"1"0%"0"2"1"1"1"0%"0"3"1"2"1"0%"0"4"1"3"1"0%"0"2"1"0"2"0%"0"3"1"1"2"0%"0"4"1"2"2"0%"0"5"1"3"2"0%"0Q$"0"3"1"0"3"0%"0"4"1"1"3"0%"0"5"1"2"3"0%"0"6"1"3"3"0%,,vv"0!"0!^.

Run four languages

(Newline inserted for clarity, in reality they would count as characters.) (This is the kind of length you have to type to execute any Deadfish, Brainfuck, Emmental, or Mascarpone.)

[Diiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
iiiiiiiiiiiiiiiiiiiiiiioioioioiiiiiiiiiiiiiiodoiooooo
ooooooooiiiiiiio+++++++++++++++[->++<]>++.[-]<[-]++++
+++++++++++[->++<]>++.[-]<[-]+++++++++++++++[->++<]>+
+.[-]<[-]+++++++++++++++[->++<]>++.[-]<[-]+++++++++++
++++[->++<]>++.[-]<[-]+++++++++++++++[->++<]>++.[-]<[
-]+++++++++++++++[->++<]>++.[-]<[-]+++++++++++++++[->
++<]>++.[-]<[-]+++++++++++++++[->++<]>++.[-]<[-]+++++
++++++++++[->++<]>++.[-]<[-]+++++++++++++++[->++<]>++
.[-]<[-]+++++++++++++++[->++<]><[-]++++++++++,.#65.#6
5.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65
.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.
#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#
65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#6
5.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65
.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.
#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#
65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#6
5.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65
.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.
#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#
65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#6
5.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65.#65
.#65.#65.#65.#65.#65.#65.,.[.seulav ssalc-tsrif era s
reterpretni ralucric-atem ,enopracsaM nI .latnemmE ot
rosseccus a sa 7002 ni yesserP sirhC yb dengised egau
gnal gnimmargor p gninifeder-fles ,desab-kcats a si e
nopracsaM]$..........................................
.....................................................
.....................................................
.............................................$[.gnirt
s a gnitnirp yltnerruc era ew dna ,enopracsaM si sihT
]$...................................................
........$[!olleH]$......$'!.|0:]