High-level programming language that can be compiled to Brainfuck.
$ git clone git@github.com:dqn/bigbrain.git
$ cd bigbrain
$ yarn
$ yarn bigbrain ./example.bigbrain
x = input();
for (i = 1; i <= x; ++i) {
if (i % 3 == 0 && i % 5 == 0) {
putchar(102);
putchar(105);
putchar(122);
putchar(122);
putchar(98);
putchar(117);
putchar(122);
putchar(122);
// => fizzbuzz
} else if (i % 3 == 0) {
putchar(102);
putchar(105);
putchar(122);
putchar(122);
// => fizz
} else if (i % 5 == 0) {
putchar(98);
putchar(117);
putchar(122);
putchar(122);
// => buzz
} else {
print(i);
// => (raw number)
}
putchar(10);
// => \n
}
Output:
>>,<<[-]>>[<<+>>>+<-]>[-]+<<[-]>>[<<+>+>-]<[-]<[>+>+<<-]>>[<<+>>-]<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<[-<[>>+>+<<<-]>>>[<<<+>>>-]+<[<<->>>-<[-]]>[<<[-]>>-]<<]+<[>-<[-]]>[<<[>+>>+<<<-]>>>[<<<+>>>-]+++<<[>>->+<[>>+>+<<<-]>>>[<<<+>>>-]+<[>-<[-]]>[<<[<+>-]>>-]<<<<<-]>>[-]>[<<<->>>-]+<<<[>>>-<<<[-]]<[>+>>+<<<-]>>>[<<<+>>>-]+++++<<[>>->>+<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]+<[>-<[-]]>[<<[<<+>>-]>>-]<<<<<<-]>>[-]>>[<<<<->>>>-]+<<<<[>>>>-<<<<[-]]>>>[<<<+>>>[-]]>[<<<<+>>>>[-]]++<<<<[>>>>-<<<<-]+>>>>[<<<<->>>>[-]]<+<<<[>>>>>++++++++++[<<<++++++++++>>>-]<<<++.[-]>>>+++++++[<<<+++++++++++++++>>>-]<<<.[-]>>>+++++++++++[<<<+++++++++++>>>-]<<<+.[-]>>>+++++++++++[<<<+++++++++++>>>-]<<<+.[-]>>>+++++++[<<<++++++++++++++>>>-]<<<.[-]>>>+++++++++[<<<+++++++++++++>>>-]<<<.[-]>>>+++++++++++[<<<+++++++++++>>>-]<<<+.[-]>>>+++++++++++[<<<+++++++++++>>>-]<<<+.[-]>-<<<[-]]>>>[<<<<[>+>>+<<<-]>>>[<<<+>>>-]+++<<[>>->>>+<<<[>>>>+>+<<<<<-]>>>>>[<<<<<+>>>>>-]+<[>-<[-]]>[<<[<<<+>>>-]>>-]<<<<<<<-]>>[-]>>>[<<<<<->>>>>-]+<<<<<[>>>>>-<<<<<[-]]+>>>>>[>>++++++++++[<++++++++++>-]<++.[-]>+++++++[<+++++++++++++++>-]<.[-]>+++++++++++[<+++++++++++>-]<+.[-]>+++++++++++[<+++++++++++>-]<+.[-]<<<<<<->>>>>[-]]<<<<<[<[>>>>>>+>+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]+++++<[>->+<[>>+>+<<<-]>>>[<<<+>>>-]+<[>-<[-]]>[<<[<+>-]>>-]<<<<-]>[-]>[<<->>-]+<<[>>-<<[-]]+>>[>>+++++++[<++++++++++++++>-]<.[-]>+++++++++[<+++++++++++++>-]<.[-]>+++++++++++[<+++++++++++>-]<+.[-]>+++++++++++[<+++++++++++>-]<+.[-]<<<->>[-]]<<[<<<<<<[>>>>>>>>+>+<<<<<<<<<-]>>>>>>>>>[<<<<<<<<<+>>>>>>>>>-]++++++++++<[->->+<[>>+>+<<<-]>>>[<<<+>>>-]+<[>-<[-]]>[<<[<+>-]>>>+<-]<<<<]>>[>>>>>+<<<<<-]>>>[<<<<<+>>>>>-]<<<<[-]++++++++++<[->->+<[>>+>+<<<-]>>>[<<<+>>>-]+<[>-<[-]]>[<<[<+>-]>>>+<-]<<<<]>>[>>>>+<<<<-]>>>[++++++++++++++++++++++++++++++++++++++++++++++++.<+>>+<[-]]>[<<[>>-<<-]>>++++++++++++++++++++++++++++++++++++++++++++++++.[-]]>++++++++++++++++++++++++++++++++++++++++++++++++.[-]<<<<<<[-]<<<-]>[<<<<+>>>>-]<<<<<<-]>>[>>+<<-]>-]>[-]++++++++++.[-]<<<<<+[>>>>>+<+<<<<-]>>>>[<<<<+>>>>-]>[-]<<<[-]<<[>>>>>+<+<<<<-]>>>>[<<<<+>>>>-]<<<<<[>>>>>+<+<<<<-]>>>>[<<<<+>>>>-]>[->[<<+<<+>>>>-]<<<<[>>>>+<<<<-]+>>[>>-<<<<->>[-]]<<[>>>[-]<<<-]>>>]+>[<->[-]]<[<<+>>-]<<]
foo = 10;
bar = 20;
As in brainfuck: ,
.
x = input();
As in brainfuck: .
.
putchar(65); // => A
Print value as decimal.
print(65); // => 65
Block is an expression.
y = {
print(10);
putchar(65);
20 + 15 + 7;
};
print(y); // => 42
if
is an expression.
x = 20;
if (x > 10) {
print(65);
}
if (x > 10) {
print(65);
} else {
print(66);
}
if (x > 10) {
print(65);
} else if (x < 10) {
print(66);
} else {
print(67);
}
y = if (x > 10) {
1;
} else {
2;
};
print(y); // => 1
for (i = 0; i < 10; i++) {
print(i % 3);
}
print(1 + 2); // => 3
print(4 - 1); // => 3
print(1 + +1); // => 2
print(1 + -1); // => 0
print(2 * 4); // => 8
print(13 / 3); // => 4
print(13 % 3); // => 1
print(2 ** 3); // => 8
print(2 * (3 + 4)); // => 14
print(!0); // => 1
print(1 == 2); // => 0
print(1 != 2); // => 1
print(1 < 2); // => 1
print(1 > 2); // => 0
print(1 <= 1); // => 1
print(1 >= 1); // => 1
print(1 && 0); // => 0
print(1 || 0); // => 1
x = 5;
print(++x); // => 6
print(x++); // => 6
print(x--); // => 7
print(--x); // => 5
MIT