Omgrofl

From Esolang
Jump to: navigation, search

Omgrofl is an esoteric programming language created in 2006 by Juraj Borza. It is equipped with a stack/queue, has support for byte-sized variables and keywords resembling Internet slang. The name comes from combining the slang "words" omg and rofl. Rofl is actually one of Omgrofl's commands.

Syntax[edit]

  • Omgrofl programs consist of statements, that are written on separate lines.
  • Each command denotes a type of statement.
  • Some statements may also contain conditions or expressions.
  • An expression is a variable or a number.
  • Indentation is optional, it may improve code readability.
  • If there are two statements on one line, the second is ignored.
  • Empty lines are ignored.
  • Omgrofl is not case-sensitive, thus lol is the same as LoL. You may use this to produce nicer code.

Variables[edit]

The programmer may use variables in Omgrofl. These must be a form of the slang word lol, like lol, lool, loool, looool, etc.

A variable can be defined as:

lol iz 4

This statement creates a new variable named lol, assigning the value 4 to it.

Statements[edit]

Conditionals[edit]

wtf condition – is a conditional statement (like if in C).

The statements until the matching brb are executed only if the condition is true.

Usage:

lol iz 1
wtf lol iz liek 1
rofl lol
lmao lol
brb

Possible conditions are:

iz uber – checks if one expression is greater than another.

usage:

x iz uber y

iz liek - checks if two expressions are equal.

These may be modified by:

nope – negation (like ! in C) - needs to be placed in front of liek or uber.

usage:

x iz nope uber y
lol iz nope liek 7

Loops[edit]

rtfm – begins a loop.

The statements between rtfm and the matching brb are repeated indefinitely. Thus, a loop must be broken with tldr.

Example:

rtfm
 lol iz 64
brb

4 variable iz initial-value 2 end-value - begins a "for" loop.

The variable is set to the initial-value, and then the statements between the 4 statement and the matching brb are repeated until the variable reaches the end-value. The initial-value and end-value are evaluated only once.

Usage:

4 variable iz initial-value 2 end-value
 w00t some code
brb

If the initial-value is lower than end-value the variable is increased by 1 after each iteration. If the initial-value is greater than end-value the variable is decreased by 1 after each iteration. If the initial-value equals the end-value the body of the loop executes exactly once. The variable may be modified inside the loop.

tldr – breaks a loop – like break in C. May only be placed between rtfm and brb or between a 4 statement and brb.

I/O[edit]

stfw x – reads a value into x. A byte character is read from standard input, and its value is stored into x, like in brainfuck.

rofl x – prints out the value of x as a byte character. Also like in brainfuck.

Stack/Queue[edit]

The stack/queue is one data structure that acts as a stack and a queue simultaneously, aka. an input-restricted (as there is no way to push to the back of the queue) deque.

n00b x – pushes x onto the stack / enqueues x.

l33t x – pops a value from the stack and stores it into x. If the stack/queue is empty, 0 is stored into x.

haxor x - dequeues a value. If the stack/queue is empty, 0 is stored into x.

Misc[edit]

stfu – exits application immediately. It is unnecessary at the end of the program, use it only when you want to terminate the execution of the program in another place (like exit in C.)

brb – serves as end in Pascal, } in C. See wtf or rtfm.

afk x – pauses the program execution for x milliseconds.

Usage:

loool iz 255 
afk loool

pauses the execution for 255 milliseconds.

variable iz x – is assignment – like = in C.

w00t – starts a comment, characters after w00t until the end of the line are treated as a comment (like // in C).

Variable manipulation[edit]

lmao x – increments x by one.

roflmao x – decrements value of x by one.

x to /dev/null – clears x.

lol to /dev/null
lol iz 0

do the same thing.

Computational class[edit]

Because Omgrofl has a queue (which can act like a Turing machine's tape), it is Turing-complete.

Examples[edit]

Hello, World![edit]

w00t a Hello, World! program by poiuy_qwert
lol iz 72
rofl lol
lol iz 101
rofl lol
lol iz 108
rofl lol
rofl lol
lool iz 111
rofl lool
loool iz 44
rofl loool
loool iz 32
rofl loool
loool iz 87
rofl loool
rofl lool
lool iz 114
rofl lool
rofl lol
lol iz 100
rofl lol
lol iz 33
rofl lol
stfu

Addition of two numbers[edit]

Only a code snippet:

  • lol is the first number (addend).
  • lool is the second number (addend).
  • We want to add these two numbers together and store the result in loool without losing the values of lol and lool.
loool iz lol
looooool iz lool
rtfm
 wtf looooool iz liek 0 
  tldr
 brb
 lmao loool
 roflmao looooool
brb

The same code in C:

uint8_t loool = lol;
uint8_t looooool = lool;
while (true)
{
 if (looooool == 0)
  break;
 loool++;
 looooool--;
}

External resources[edit]