This project is read-only.
IronBrainF-ck is a .Net 3.5 library witch provides ability to run BF machine to execute pure BF code.
With BrainF-ckCompiler you can compile pure BF code into managed assembly.
Finally, SimpleBrainF-ck is a BF IDE where you can write SimpleBrainF*ck code. Then SBF translates it into pure BF code.

Simple BrainF-ck Syntax

See Examples/general.sbf for more examples.

Comments
// comment

Procedure definition
def name param1 param2 param3
   // body
end

def swap x y t
    $shift @x
    @t~x = @t - @x
    $move @t~x
    @y~x = @y - @x
    $shift @y~x
    $move @-y~x
    @t~y = @t - @y
    $shift @t~y
    $move @-t~y
    $shift @-t
end

Procedure call
$name arg1 arg2 arg3
$copy 1 1
$shift 10
$type "Hello, world!" 1
$type @text
$swap 0 1 2 // before: 1 2 3   after: 2 1 0

Macro definition
@name = value
@a = 1
@b = -1
@text = "hello world"
@other = b

Macro assignment
@val = 5
@a = @b + @c // Warning: spaces required (@name_=_v1_+_v2)
@foo = @val * 10
@bar = @foo / 5
@val = - @a
@text = "hello"
@text = @text . " world
@substring = @text take 4 // "hell"
@other = @text skip 6 // "world"

If statment
if @temp
    // if cells[current] != 0
else
    // if cells[current] == 0
end

Standart procedures
$error "Not implemented" // raise compile-error
$zero // current cell = 0
$shift @k // ">>>" or "<<<" k times
$add @k // add current cell to another (destructively)
$sub @k // subtract current cell from another (destructively)
$move @k // move current cell to another (destructively)
$copy @k @t // copy current cell to k using temp cell t
$value @k @t // current cell = @k using temp cell t
$text "text" // cells[curr+0] = 't' cells[curr+1] = 'e' cells[curr+2] = 'x' cells[curr+3] = 't' using temp cell cells[curr+4]
$print @k // ".>.>.<<" or ".<.<.>>" to print k chars
$type @text @t // print @text using temp cell t

Pure code
def print3times @text @temp~3
    @t = @temp~3
    $shift @t
    +++
    [->
        $type @text 1
    <]
    $shift @-t
end

Last edited Jan 12, 2011 at 10:28 PM by ZackFlame, version 2

Comments

No comments yet.