CAESAR

From Esolang
Jump to navigation Jump to search

CAESER (named after the Roman general Julius Caesar) is an esoteric programming language that was created solely to annoy developers. Unlike many esolangs, It features a fairly readable syntax. It was made in one evening by a 15 year old with little experience in the subject of programming language design over the course of a single evening, and is loosely inspired by the Caesar problem from a children's algorithmization book. The interpreter can be found here.

Concepts

The esolang features three main that are used in programs:

  • Caesar/Commander (male) - Performs most operations. Controls program flow, prints to the output, and decides when to stop the program. He is canonically stupid and is only able to remember/contain one piece of information at a time.
  • Basket (no gender) - A stack with a fancy name
  • Army (varying genders) - Operates the stack. Receives commands from Caesar, perform basic operations (like addition or shuffling the stack), and can receive/send information to Caesar.

Commands

This esolang contains 10 commands that are as follows:

  • raise x - Raise x as a flag
  • yell - Prints the content of Caesar's memory to the output
  • listen - Listens for user input and saves it to Caesar's memory
  • save x - Saves x to Caesar's memory
  • signal - Appends the value in Caesar's memory to the basket
  • # - Used for comments
  • if x doY - If the value in the Caesar's memory is equal to x, do y. x cannot contain spaces.
  • if! x doY - If the value in Caesar's memory is not equal to x, do y. x cannot contain spaces.
  • move - Moves Caesar to the beginning of the program
  • stop - Stops the program's execution

Flags:

  • A - Put the item on top of the basket in the bottom
  • B - Take the item from the top of the basket and put it in the bottom
  • C - Add the first and last basket items and send the value to Caesar
  • D - Add the first and second basket items and send the value to Caesar
  • E - Send the item on top of the basket to Caesar
  • F - Send the bottom basket item to Caesar
  • G - Remove the top item from the basket

Syntactic quarks

Every command MUST END WITH SEMICOLON! Quotes do nothing here, this language is weakly typed without type declaration. The language supports multiline commands, which means that this code is valid:

save hello
world; yell;

There are no code blocks in this language, but commands can be placed on the same line, and all commands on the line will execute in order assuming the stop command is not used on the line.

if 5 {yell; yell;} #invalid;
if 5 yell; yell; #invalid;
if 5 yell; if 5 yell; #valid;

Entered argument x in if commands cannot contain spaces, but memory can. Comments are regarded as regular commands, so they must end in semicolon.

save foo bar; #valid
if foo bar yell; #invalid
if foobar yell; #valid with no output
#valid;
#invalid

Also, the code isn't interpreted in real time, instead it shows output after it's finished running. The program allows up to 5000 iterations and the default value of memory is non

Example code

Hello world:

save Hello World;
yell;

Receive and output user input:

listen;
yell;

Truth-machine (Takes in input, if 0, print and terminate, if 1, prints input forever. Can only output 0 once or 1 infinitely):

if non listen;
if 0 yell;
if 1 yell; 
if 1 move;

addition of two numbers:

listen;
signal;
listen;
signal;
raise D;
yell;