An open API service indexing awesome lists of open source software.

https://github.com/msm-code/pseudobf


https://github.com/msm-code/pseudobf

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

PseudoBF
========

PseudoBF is simple language, that compiles to brainfuck itself. That is, you can write simple code similar to that:

```
function compare(varA, varB) {
if (varA == varB) {
print("equal. ");
} else {
print("not equal. ");
}
}

function main() : locals(a, b, c) {
a = 7;

print("Compare a to 5: ");
compare(a, 5);

print("Compare a to 7: ");
compare(a, 7);
}
```

And feed it into PseudoBF compiler, to get equivalent code... In brainfuck!

```
>[-]+++++++>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++.++++++++++++++++++++++++++++++++++++++++++++.--.+++.---------------.+++++++
++++++++++.-------------.-------------------------------------------------------
--------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.-----------------------------------------------------------------.+++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-----.--
-----------------------------------------------------------------------------.++
+++++++++++++++++++.+++++.--------------------------.>>>>[-]<<[-]<<<<<[>>>>>+>>+
<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[-]+++++<<>>>[-]<<<[-]>[<+>>>+<<-]>>[<<+>>-][
-]>[-]<<<<[>>>>+<<<<-]+>>[>+>-<<-]>[<+>-]>[<<<<->>>>[-]]<[-]>[-]<<<<[>>>+>+<<<<-
]>>>[<<<+>>>-]+>[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++.++++++++++++.++++.-------------------
-.+++++++++++.--------------------------------------------------------------.---
-----------.<<->[-]]<[>>>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+.+++++.-------------
-----------------------------------------------------------------------.++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++.++++.
--------------------.+++++++++++.-----------------------------------------------
---------------.--------------.<<<-]<<<[-]++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++.--.++
+.---------------.+++++++++++++++++.-------------.------------------------------
---------------------------------------.++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++.------------------------------------------------------
-----------.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++.-----.---------------------------------------------------------
----------------------.+++++++++++++++++++++++.+++.--------------------------.>>
>>[-]<<[-]<<<<<<[>>>>>>+>>+<<<<<<<<-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]<[-]+++++++<<>>
>[-]<<<[-]>[<+>>>+<<-]>>[<<+>>-][-]>[-]<<<<[>>>>+<<<<-]+>>[>+>-<<-]>[<+>-]>[<<<<
->>>>[-]]<[-]>[-]<<<<[>>>+>+<<<<-]>>>[<<<+>>>-]+>[>[-]++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++
++++++++.++++.--------------------.+++++++++++.---------------------------------
-----------------------------.--------------.<<->[-]]<[>>>[-]+++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++.+.+++++.------------------------------------------------------------
------------------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++.++++++++++++.++++.--------------------.+++++++++++.--------------
------------------------------------------------.--------------.<<<-]<<<<<<
```

After executing above code in any brainfuck interpreter, we get expected optput:

```
Compare a to 5: not equal. Compare a to 7: equal.
```

Note: this project is outdated. See also PseudoBF2 project, which is complete
ground-up rewrite of this idea but better designed, more complete, and more extensible.
https://github.com/msm-code/PseudoBF2