Skip to content
Srikanth R edited this page Nov 12, 2016 · 1 revision

Welcome to the GamesOfThronesC wiki!

A simple programming language that uses the dialogues and phrases of Game of thrones. Inspired by ArnoldC. The project uses Parboiled and ASM-java for parsing and java byte code construction.

Syntax

The syntax is synonymous to Java where everything is encapsulated inside a class. In GOTC (read GameOfThronesC), it's similar. Every program should start with WINTER IS COMING and end with MY WATCH HAS ENDED. A simple program which does nothing would be,

 WINTER IS COMING
 MY WATCH HAS ENDED

The name of the class is the same as the file you passed (without the extension)

Main method

A program should have a main method where execution begins. Main method starts with VALAR DOHAERIS and ends with VALAR MORGHULIS. This is a program that just has the source of execution is,

 WINTER IS COMING
 VALAR DOHAERIS
 VALAR MORGHULIS
 MY WATCH HAS ENDED

Printing something

Everything starts with a 'hello world' program. The command LET ME SEE IT ONE MORE TIME prints data to the console. It takes a variable (discussed next), a string or a number.

 WINTER IS COMING
 VALAR DOHAERIS
 LET ME SEE IT ONE MORE TIME hello world
 VALAR MORGHULIS
 MY WATCH HAS ENDED

 Output : hello world

Variable initialization

GOTC works all and all with only int datatype. A variable should be initialized and assigned to some int in a single line. The command THE NORTH REMEMBERS is used for it.

 WINTER IS COMING
 VALAR DOHAERIS
 THE NORTH REMEMBERS abc 5
 LET ME SEE IT ONE MORE TIME abc
 VALAR MORGHULIS
 MY WATCH HAS ENDED

 Output : 5

PS. The inbuilt variables HODOR and YOU KNOW NOTHING denote 1 and 0.

Arithmetic operations

The arithmetic operations work on a single operand and it affects the same. It takes another operand which can be a variable or an integer to affect the first operand.

Addition

 GIVE MY REGARDS TO THE NIGHT'S WATCH operand expression

Subtraction

 STAY LOW operand expression

Multiplication

 YOU GOT FAT operand expression

Division

 ANYONE CAN BE KILLED operand expression

Example,

WINTER IS COMING
VALAR DOHAERIS
THE NORTH REMEMBERS abc 5
STAY LOW abc 2
LET ME SEE IT ONE MORE TIME abc
VALAR MORGHULIS
MY WATCH HAS ENDED

Output : 3 

A much complicated example, int abc = ((5 - 2) * 4) / 6;

WINTER IS COMING
VALAR DOHAERIS
THE NORTH REMEMBERS abc 5
STAY LOW abc 2
YOU GOT FAT abc 4
THE NORTH REMEMBERS def 6
ANYONE CAN BE KILLED abc def
LET ME SEE IT ONE MORE TIME abc
VALAR MORGHULIS
MY WATCH HAS ENDED

Output : 2

Logical operations

As GOTC works only on integers, all non-zero numbers are considered as true and zero is considered as false.

Equal to

 I AM YOURS AND YOU ARE MINE operand expression

Lesser than

 YOU HAVE LESS HONOR THAN A BACK ALLEY WHORE operand expression

Or

 YOU WIN OR YOU DIE operand expression

And

 WE STAND TOGETHER operand expression

Not

 KILL THE BOY operand

For example,

 WINTER IS COMING
 VALAR DOHAERIS
 THE NORTH REMEMBERS abc -4
 THE NORTH REMEMBERS def -6
 WE STAND TOGETHER abc def
 LET ME SEE IT ONE MORE TIME abc
 VALAR MORGHULIS
 MY WATCH HAS ENDED

 Output : 1

Conditional statement

Any value but zero is evaluated as true condition.

If

if (value) 
[statements]
endif

In GOTC,

ARE YOU A VIRGIN expression
[statements]
FUCK OFF

If Else

if (value)
[statements]
else 
[statements]
endif

In GOTC,

ARE YOU A VIRGIN expression
[statements]
SHAME
[statements]
FUCK OFF

Example

WINTER IS COMING
VALAR DOHAERIS
THE NORTH REMEMBERS abc 4
THE NORTH REMEMBERS def 6
I AM YOURS AND YOU ARE MINE abc def
ARE YOU A VIRGIN abc
LET ME SEE IT ONE MORE TIME abc is equal to def
SHAME
LET ME SEE IT ONE MORE TIME abc is NOT equal to def
FUCK OFF
VALAR MORGHULIS
MY WATCH HAS ENDED

It equates to

int abc = 4;
int def = 6;
if (abc == def) {
	print "abc is equal to def"
} else {
	print "abc is NOT equal to def"
}

While statement

Same as above. Any value that is not 0 is accounted as true.

MY REIGN HAS JUST BEGUN expression
[statements]
TURN US AWAY, AND WE WILL BURN YOU FIRST

For example, a full program printing all even numbers between 20-0 (descending order)

WINTER IS COMING
VALAR DOHAERIS
THE NORTH REMEMBERS a 20
MY REIGN HAS JUST BEGUN a
LET ME SEE IT ONE MORE TIME a
STAY LOW a 2
TURN US AWAY, AND WE WILL BURN YOU FIRST
VALAR MORGHULIS
MY WATCH HAS ENDED

Methods

A method can be defined outside the main method within the class. It can return a value, or not. It takes single, multiple or no argument(s). GOTC supports method overloading based on the number of arguments (yaayy!).

Syntax for a void method

FORGET THE BLOODY GODS AND LISTEN TO WHAT I'M TELLING YOU <methodName>
LANNISTERS SEND THEIR REGARDS arg1
LANNISTERS SEND THEIR REGARDS arg2
.
.
.
[statements]
GET OUT, YOU HATEFUL BITCH
I'M GOING HOME

Yes, the syntax is predictable. FORGET THE BLOODY GODS AND LISTEN TO WHAT I'M TELLING YOU denotes method declaration beginning, LANNISTERS SEND THEIR REGARDS denotes a single argument, GET OUT, YOU HATEFUL BITCH denotes return statement (can have an optional value) and I'M GOING HOME denotes the end of method declaration.

Syntax for a non-void method

FORGET THE BLOODY GODS AND LISTEN TO WHAT I'M TELLING YOU <methodName>
LANNISTERS SEND THEIR REGARDS arg1
LANNISTERS SEND THEIR REGARDS arg2
.
.
.
THERE'S NO CURE FOR BEING A CUNT
[statements]
GET OUT, YOU HATEFUL BITCH <compulsoryreturnvalue>
I'M GOING HOME

Here, the only new phrase denotes that the method is non-void method. It is THERE'S NO CURE FOR BEING A CUNT. It's given after all the arguments.

Syntax to invoke a method

WHERE IS THE GOD OF TITS AND WINE <methodName> <arg1> <arg2> ...
I DRINK AND I KNOW THINGS <variabletostorereturnedvalue>

The phrase WHERE IS THE GOD OF TITS AND WINE denotes the method call and if the invoked method returns some value, it can be stored in a variable using the phrase I DRINK AND I KNOW THINGS

Example for it, a program to calculate factorial of 10

WINTER IS COMING
VALAR DOHAERIS
THE NORTH REMEMBERS num 10
THE NORTH REMEMBERS f 0
WHERE IS THE GOD OF TITS AND WINE calculate num
I DRINK AND I KNOW THINGS f
LET ME SEE IT ONE MORE TIME f
VALAR MORGHULIS

FORGET THE BLOODY GODS AND LISTEN TO WHAT I'M TELLING YOU calculate
LANNISTERS SEND THEIR REGARDS n
THERE'S NO CURE FOR BEING A CUNT
THE NORTH REMEMBERS i n
THE NORTH REMEMBERS factorial 1
MY REIGN HAS JUST BEGUN i
YOU GOT FAT factorial i
STAY LOW i 1
TURN US AWAY, AND WE WILL BURN YOU FIRST
GET OUT, YOU HATEFUL BITCH 
I'M GOING HOME factorial
MY WATCH HAS ENDED

Output : 3628800

More examples might come later. Peace.