Omgrofl

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

 * 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
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.

Conditionals
wtf</TT> condition – is a conditional statement (like if</TT> in C).

The statements until the matching brb</TT> 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</TT> – checks if one expression is greater than another.

usage: x iz uber y

iz liek</TT> - checks if two expressions are equal.

These may be modified by:

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

usage: x iz nope uber y lol iz nope liek 7

Loops
rtfm</TT> – begins a loop.

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

Example: rtfm lol iz 64 brb

4 variable iz initial-value 2 end-value</TT> - begins a "for" loop.

The variable is set to the initial-value, and then the statements between the 4</TT> statement and the matching brb</TT> 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.

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

I/O
<TT>stfw</TT> x – reads a value into x. A byte character is read from standard input, and its value is stored into x, like in brainfuck.

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

Stack/Queue
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.

<TT>n00b</TT> x – pushes x onto the stack / enqueues x.

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

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

Misc
<TT>stfu</TT> – 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 <TT>exit</TT> in C.)

<TT>brb</TT> – serves as <TT>end</TT> in Pascal, <TT>}</TT> in C. See <TT>wtf</TT> or <TT>rtfm</TT>.

<TT>afk</TT> x – pauses the program execution for x milliseconds.

Usage: loool iz 255 afk loool pauses the execution for 255 milliseconds.

variable <TT>iz</TT> x – is assignment – like <TT>=</TT> in C.

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

Variable manipulation
<TT>lmao</TT> x – increments x by one.

<TT>roflmao</TT> x – decrements value of x by one.

x <TT>to /dev/null</TT> – clears x. lol to /dev/null lol iz 0 do the same thing.

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

Hello, World!
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
Only a code snippet: loool iz lol looooool iz lool rtfm wtf looooool iz liek 0 tldr brb lmao loool roflmao looooool brb
 * <TT>lol</TT> is the first number (addend).
 * <TT>lool</TT> is the second number (addend).
 * We want to add these two numbers together and store the result in <TT>loool</TT> without losing the values of <TT>lol</TT> and <TT>lool</TT>.

The same code in C: uint8_t loool = lol; uint8_t looooool = lool; while (true) { if (looooool == 0) break; loool++; looooool--; }

External resources

 * Omgrofl Code Converter - A tool to convert Omgrofl code into Javascript & PHP.
 * Brainfuck 2 Omgrofl Converter
 * Omgrofl Interpreter in Java
 * Urban Dictionary - a handy resource for understanding internet slang and Omgrofl keywords.
 * a Vim syntax file for Omgrofl
 * a Vim syntax file for Omgrofl