RAGE!!!

From Esolang
Jump to navigation Jump to search

RAGE!!! is an esoteric programming language created in 2013 by Sean Doyle that is based on Python and is designed to be somewhat functional and useless at the same time. It involves the use of statements of rage as part of the syntax and uses !!! in the same way ; is used to end the line in Java or C++.

In RAGE!!! you must have a few things:

  1. A declaration (<rant>)
  2. !!! to end each line
  3. A stop statement (</rant>).

Functions can be defined with the statement WHY WOULD YOU CREATE A FUNCTION CALLED functionName(args): There are also the built in functions to get input (WHY DOES varName MEAN THE SAME THING AS WHAT YOU'RE ABOUT TO TELL ME) and declare variables (WHY DOES varName MEAN THE SAME THING AS value).

If... then... else... statements are also usable. While loops are implemented, but For loops are not.

Examples

Hello world

<rant>
SCREAM "Hello world"!!!
</rant>

Example program

<rant>
SCREAM "HI!!!"!!!
WHY DOES thisVar MEAN THE SAME THING AS 1!!!
WHY DOES thatVar MEAN THE SAME THING AS 2!!!
WHY WOULD YOU CREATE A FUNCTION CALLED derp(this,that):!!!
	SCREAM this+that!!!
WHY DOES durp MEAN THE SAME THING AS WHAT YOU'RE ABOUT TO TELL ME!!!
WHAT IF durp MEANS THE SAME THING AS "1":!!!
	SCREAM "ONE"!!!
BUT WHAT IF durp MEANS THE SAME THING AS "2":!!!
	SCREAM "TWO"!!!
WELL THEN I WILL:!!!
	WHY DOES infinite MEAN THE SAME THING AS True!!!
	AS LONG AS infinite MEANS THE SAME THING AS True:
		SCREAM "SOMETHING ELSE"!!!
SCREAM durp!!!
derp(thisVar,thatVar)!!!
</rant>

Implementation

The Python 3 compiler, itself written in Python 3, is as follows: (Note: Due to how horribly written this is, it doesn't produce valid Python3 print() calls, and as such one should run 2to3 on it to fix that. It also doesn't check much syntax. See talk page. --Malltog (talk) 12:48, 6 June 2014 (UTC))

import sys

if len(sys.argv) < 3:
	print('Command use:' + sys.argv[0] + ' <input> <output>')
	exit(1)

openfile = file(sys.argv[1],"r")
theFile = openfile.read()
openfile.close()

if theFile.find("<rant>")!=-1:
	print("Syntax error: missing <rant>")
	exit(1)
if theFile.find("</rant>")==-1:
	print("Syntax error: missing </rant>")
	exit(1)
if theFile.find("</rant>") <= theFile.find("<rant>"):
	print("Syntax error: </rant> before <rant>")
	exit(1)

array = theFile.split("\n")
array2 = theFile.split("!!!")

if len(array2) < len(array)-2:
	print "Syntax error: unterminated command"
	exit(1)

theFile = theFile.replace("<rant>","## START OF RAGE PROGRAM")
theFile = theFile.replace("</rant>","## END OF RAGE PROGRAM")
theFile = theFile.replace("SCREAM","print")
theFile = theFile.replace("WHY DOES ","")
theFile = theFile.replace("MEAN THE SAME THING AS","=")
theFile = theFile.replace("WHAT YOU'RE ABOUT TO TELL ME","raw_input('')")
theFile = theFile.replace("!!!","")
theFile = theFile.replace("WHY WOULD YOU CREATE A FUNCTION CALLED","def")
theFile = theFile.replace("BUT WHAT IF","elif")
theFile = theFile.replace("WHAT IF","if")
theFile = theFile.replace("HAPPENS","")
theFile = theFile.replace("WELL THEN I WILL","else")
theFile = theFile.replace("AS LONG AS","while")
theFile = theFile.replace("MEANS THE SAME THING AS","==")
outp = file(sys.argv[2],"w")
outp.write(theFile)
outp.close()