Gaot++

From Esolang
Jump to navigation Jump to search

Description

Gaot++ is a stack-based programming language with 2 types of commands: baas and bleets.

Gaot++ has an instruction pointer that initially moves to the right and down, but the direction can be reversed.

baa commands

A baa command is matched by the following regex: ba{2,}. (i.e. the letter 'b' followed by two or more 'a's).

A baa command pushes the number of its a's minus 1.

bleet commands

A bleet command is matched by the following regex: ble{2,}t. (i.e. the letters 'bl' followed by two or more 'e's and a final 't').

A bleet command executes an action based on the number of e's that it has:

Count of e Action on stack Description
2 a, b -> a + b Push the sum of the two values on the top of the stack
3 a, b -> b - a Push the difference of the two values on the top of the stack
4 -> Skip the next command
5 -> Terminate the program
6 -> Reverse the IP direction
7 a -> Skip the next instruction if the value on the top of the stack is not zero
8 a -> Skip the next instruction if the value on the top of the stack is zero
9 a -> Pop a value and print it as a number
10 a -> Pop a value and print it as a character
11 -> a Read a number from stdin
12 -> a Read a character from stdin
13 a -> a, a Duplicate the top of the stack
14 a, b -> b, a Swap the top of the stack
15 a... -> ...a Reverse the stack
16 a...b -> ...b, a Rotate the stack

Example programs

Hello World version 1

Prints the string Hello, World!.

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeet
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeet
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeet
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeet
baaaaaaaaaaaaaa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bleeeeeeeeeet
baaaaaaaa
bleet
bleeeeeeeeeeeeet
bleeeeeeeeeet
bleeeeeeeeeeeeet
bleeeeeeeeeet
baaaa
bleet
bleeeeeeeeeet
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeeeeet
bleeeeeeeeeeeeet
bleeeeeeeeeet
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeet
bleet
baa
bleeet
bleeeeeeeeeeeeet
bleeeeeeeeeet
baaaaaaaaaaaaaa
bleet
bleeeeeeeeeeeeet
baaaaaaaaa
bleet
bleeeeeeeeeeeeet
baaaa
bleet
bleeeeeeeeeeeeet
bleeeeeeeeeet
baaaa
bleet
bleeeeeeeeeet
bleeeeeeeeeet
bleeeeeeeeeet
baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bleeeeeeeeeet

Truth machine

bleeeeeeeeeeet
bleeeet bleeeeeet
bleeeeeeeeeeeeet
bleeeeeeeeeeeeet
bleeeeeeeeeeeeet
bleeeeeeeeeeeeet
bleeeeeeeeet
bleeeeeeeet bleeeeeet

Cat program

bleeeeeeeeeeeet
bleeeet bleeeeeet
bleeeeeeeeeet bleeeet blet
bleeeeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeet bleeeeeet

Reverse cat program

bleeeet bleeeeeet
bleeeeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeet bleeeeeet
bleet
bleet
bleeeet bleeeeeet
bleeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeet bleeeeeet

Multiply two numbers

Reads two numbers from user input and prints their product. Aside from the first and last lines, this program provides a reusable block of code for replacing the top two values on the stack with their product without disturbing the other contents of the stack.

Stack semantics: a, b -> a * b Note: b must be non-negative!

bleeeeeeeeeeet bleeeeeeeeeeet

bleeeeeeeeeeeeeeet
baa baa bleeet
bleeeeeeeeeeeeeeet
bleeeet bleeeeeet
blet bleeeet bleeet
blet bleeeet bleeeeeeeeeeeeeet
blet bleeeet baa
blet bleeeet bleeeeeeeeeeeeeet
blet bleeeet bleeeeeeeeeeeeeeet
blet bleeeet bleet
blet bleeeet bleeeeeeeeeeeeeeeet
blet bleeeet bleeeeeeeeeeeeeeet
blet bleeeet bleeeeeeeeeeeeet
blet bleeeet bleeeeeeeeeeeeeet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeeeeeeet bleeeet blet
bleeeeeeeet bleeeeeet
bleeeeeeeet blet
bleeeeeeeet blet
bleeeeeeeet blet
bleeeeeeeeeeeeeeeet

bleeeeeeeeet

Implementations

External resources

  • GaotppTranslator.py - Converts Gaot++ code to and from Forth-like code that is easier to read and write.