Tbf

= tbf =

tbf is a language that can be used to write Brainfuck programs in a simpler way. Programs written in tbf are compiled to Brainfuck, where they then can be compiled using any BF compiler. tbf includes the following constructs:

General:
 * Everything is case insensitive (“hello” is the same as “Hello” as “HELLO” etc)
 * Every command has to end with a ”;”
 * You can do comments by using ”%” to start a comment. The comment will end at the end of the line (as in Bash for example).
 * All new identifiers (variables) will be automatically allocated and initialized as zero.

Basic commands:
 * “moveto ;” moves the tape at the place designed by
 * “inc;” increment the current position
 * “dec;” decrement the current position
 * “put;” output the current position as a character on the screen
 * “get;” read a character from keyboard into the current position
 * “zero;” set the current position to zero
 * “print;” output the string that starts at the current position (yes tbf has strings. I'll get into more detail later)
 * “Add ” adds the value stored at to the current cell. Be carefull, there still might be a bug that makes your program go into an infinite loop when you add an identifier to itself. I meant to fix it, nut I am not sure if I ever did.
 * “Sub ” similar to add, but does subtraction
 * “Store ” store the value that is designated by at a the current position
 * “Retrieve ” restore the value of an from the current cell

Identifier can consist of the following:
 * names of variables in the form [A-Z a-z _][A-Z a-z _ 1-9]*
 * integer literals (e.g 10, 11, -1234 etc)
 * single characters in ' '
 * Strings in ” ”
 * “new” this identifier always indicates a newly produced value
 * ”.” to current position
 * ”& ” yes this works to, take a c-guess what it does

More complex constructs:
 * “While do ” Loops. When you enter the loop the tape will point to identifier that was used in the test
 * “Begin ;[ ;…] end” blocks of code, used to group several instructions
 * “declare as ” this introduces an alias for a previously used identifier

Tests:
 * “isneg ” tests whether an identifier is negative
 * “ispos ” tests whether an identifier is positive
 * ” ” tests for zero

Example Programs:
Hello World: moveto "Hello World!\n"; print;

(Yes, strings are this simple) Output all chars from 255 backwards: while 255 do begin put; dec; end

Echo from input (cat): moveto new; inc; while. do begin get; put; end

Multiplication of two numbers as a macro: define mult(a,b) as begin zero; moveto hlp; add a;      while hlp do begin dec; moveto mult; add b;      end end moveto new; mult(10,9); put;

External resources

 * tbf homepage