Fucklang
Fucklang is an assembly-like but human-readable lanugage that is compiled to brainfuck. It's main purpose is to make programming in brainfuck faster, better and more efficient.
Syntax
Variables
Fucklang uses normal named variables, that are declared using var
command:
var a 2;
If you want to change value of already exisitng variable, you can use command val
:
val a 2; val a 3; val a "Hi!";
As you can see, Fucklang is dynamically typed, although all value types it supports is int and string. Arrays are not supported in Fucklang.
If, for, while and loop
If statement is based partly on assembler and partly on c:
ifeq a 2; //code; else; //another code; ifend;
Possible variations of if statement are: ifeq (if equal), ifneq (if not equal), ifgr (if greater than), ifls (if less than), ifgrq (if greater or equal), iflsq (if less or equal), ifst (if same value type).
For statement is limited to incrementation by one starting on zero:
for a 6; //code; forend;
As explanation, this is similar code written in c:
for (int i = 0; i < 6; i++) { //code }
While loop is simply based on if statement, so that you won't have to remember bunch of different commands:
while ifgr a 3; //code; whileend;
And finally, loop
command is used in infinite loops:
loop; //this code will be executed forever; loopend;
Math operations
Math operations are performed using commands add
, sub
, mult
, div
as follows:
var a 3; //a = 3; add a 6; //a = 3+6 = 9; sub a 1; //a = 9-1 = 8; div a 2; //a = 8/2 = 4;
Input/Output
Input and output operations are performed by commands in
and out
:
//Multiplication program in a; in b; mult a b; out a;
The in
operation always saves input as an integer, so if you want to save it as string use instr [variable name] [length of the string]
Comments
Comments starts normaly with //
, but they must be ended with semicolon like a command.
Examples
Hello World
out "Hello, World!";
Cat
loop; in a; out a; loopend;
Calculator
out "Enter two numbers: "; in a; in b; var sum a; add sum b; out "Sum is: "; out sum; var dif a; sub dif b; out "Difference is: "; out dif; var prod a; mult prod b; out "Product is: "; out prod; var port a; div port b; out "Portion is: "; out port;
Compiler
Not yet done.