We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Gotolang
Jump to navigation
Jump to search
Gotolang is an esoteric programming language in which the primary instruction is goto (as the name suggests).
if you were looking for GotoLang which was created first go here
Syntax
- gotolang programs are line-oriented. Each line contains one instruction. Comments start with #.
# Count from 0 to 4. set i 0 label loop lt i 5 if body goto done label body print i print "\n" add i 1 goto loop label done halt
- Variables are created automatically and default to 0 when first read. Operands are either integer literals or variable names:
set x 10 add x 1 set y x
- Only string literals work for the print statement
print "Hello, World!"
Instructions
| Instruction | Description |
|---|---|
| label <name> | defines a jump target |
| goto <label> | unconditionally jumps to label |
| if <label> | conditionally jumps to a label
(the line before must contain the condition) |
| halt | stop the program |
| Instruction | Description |
|---|---|
| eq <a> | evaluates to true if a == b |
| lt <a> | evaluates to true if a < b |
| Instruction | Description |
|---|---|
| set <operand> | sets a variable to a literal or another variable |
| add <operand> | adds an opperand to a variable |
| sub <operand> | subtracts an operand from a variable |
| Instruction | Description |
|---|---|
| print <operand> | prints operand to STDOUT |
| read | reads into var from STDIN |
Notes
- Identifiers contain letters, digits, and underscores, and cannot start with a digit.
- Integers are signed 64-bit values.
- The comparison flag is overwritten by each eq or lt.
- if <label> means "if the current comparison flag is true, jump to <label>."
- Unknown labels, duplicate labels, and malformed instructions are reported as errors.
Examples
Factorial
print "Enter n: " read n set fact 1 set i 1 label loop lt n i if done set old fact set fact 0 set m 0 label multiply_loop eq m i if multiply_done add fact old add m 1 goto multiply_loop label multiply_done add i 1 goto loop label done print "n! = " print fact halt
Written by icitry
Brainfuck Interpeter
If you're not familiar with the language, see Brainfuck
Due to the limitations of Gotolang, the interpreter has the following restrictions and changes:
- The tape only has 10 cells
- Programs can be no longer than 29 characters long
- The program can only be in intergers
| Command | Integer Representation |
|---|---|
| > | 0 |
| < | 1 |
| + | 2 |
| - | 3 |
| . | 4 |
| , | 5 |
| [ | 6 |
| ] | 7 |
Written by icitry
Disclaimer
I'm saving this to work on later i.e THIS PAGE IS UNDER CONSTRUCTION P.S this is my first page