• entries
292
557
• views
155220

# BF Macros

151 views

This is not a "new" EPL.
This is not an EPL "enhancement".
This is a tool to assist in the writing of BF by raising the level of abstraction.
And if you think of this as "cheating": unless you program solely in machine code, you can STFU.

I've got an idea of what the macro language should look like (it is rather C/C++-ish):

#define ZERO(x) >(x)[-]<(x)#define POSITION 10ZERO(POSITION)

ZERO(POSITION)

expands to:

>(POSITION)[-]<(POSITION)

which expands to:

>(10)[-]<(10)

which expands to:

>>>>>>>>>>[-]<<<<<<<<<<

a negative value is represented with a leading '~' instead of '-', because '-' is already a BF instruction.

>(~x) becomes <(x)
<(~x) becomes >(x)
+(~x) becomes -(x)
-(~x) becomes +(x)
.(~x) becomes ,(x)
,(~x) becomes .(x)
[(~x) becomes ](x)
](~x) becomes [(x)

in the end, everything still winds up as BF code, suitable for any BF interpreter.

Of course, I'm doing the thing backwards, so step one becomes:

turn this:

+(8)[>+(9)<-]>.<+(5)[>+(6)<-]>-.+(7).(2)+(3).<+(8)[>(2)+(4)<(2)-]>(2).<(2)+(4)[>-(6)<-]>.<+(3)[>+(6)<-]>.+(3).-(6).-(8).>+.

into:

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

There are no comments to display.

## Create an account

Register a new account