From: Rudolf Polzer Date: Tue, 29 Jan 2013 12:21:15 +0000 (+0100) Subject: add some useless file ;) X-Git-Tag: xonotic-v0.7.0~116 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b8bcdc0c7b0482c660e5bea5987e176467e663ec;p=xonotic%2Fxonotic-data.pk3dir.git add some useless file ;) --- diff --git a/bf.cfg b/bf.cfg new file mode 100644 index 000000000..4195aeb05 --- /dev/null +++ b/bf.cfg @@ -0,0 +1,98 @@ +// DP console is TURING COMPLETE! + +alias _bf_vcall "${$1} ${2- ?}" + +// number system +// Xon RPN: set $_bf_zero 0 +// Xon RPN: alias _bf_inc "rpn /$1 $2 1 add def" +// Xon RPN: alias _bf_dec "rpn /$1 $2 1 sub def" + +// unary +// decimal | unary +// 0 | 0 +// 1 | + +// 2 | ++ +// -1 | - +// -2 | -- +alias _bf_zero "set $1 0" +alias _bf_one "set $1 +" +alias _bf_minus_one "set $1 -" +alias _bf_return_3 "set $1 $3" +alias _bf_return_4 "set $1 $4" +set _bf_zero "0" +alias _bf_inc_loop1 "set _bf_tmp_$3 _bf_inc_loop2; set _bf_tmp_+$2 _bf_return_3; _bf_vcall _bf_tmp_$3 $*" +alias _bf_inc_loop2 "set _bf_tmp_$2 _bf_inc_loop3; set _bf_tmp_-$4 _bf_return_4; _bf_vcall _bf_tmp_$2 $*" +alias _bf_inc_loop3 "_bf_inc_loop1 $1 $2 +$3 -$4" +alias _bf_inc "set _bf_tmp_$2 _bf_inc_loop1; set _bf_tmp_0 _bf_one; set _bf_tmp_- _bf_zero; _bf_vcall _bf_tmp_$2 $1 $2 + -" +alias _bf_dec_loop1 "set _bf_tmp_$3 _bf_dec_loop2; set _bf_tmp_-$2 _bf_return_3; _bf_vcall _bf_tmp_$3 $*" +alias _bf_dec_loop2 "set _bf_tmp_$2 _bf_dec_loop3; set _bf_tmp_+$4 _bf_return_4; _bf_vcall _bf_tmp_$2 $*" +alias _bf_dec_loop3 "_bf_dec_loop1 $1 $2 -$3 +$4" +alias _bf_dec "set _bf_tmp_$2 _bf_dec_loop1; set _bf_tmp_0 _bf_minus_one; set _bf_tmp_+ _bf_zero; _bf_vcall _bf_tmp_$2 $1 $2 - +" +// end of unary + +// interpreter state +set bf_input "" +alias _bf_clearstate "set _bf_left \"\"; set _bf_right \"\"; set _bf_register $_bf_zero; set _bf_execstack \"\"" +alias _bf_dumpstate "echo rev($_bf_left) < $_bf_register > $_bf_right" + +// a STACK! +alias _bf_pop_get "set $2 \"${3 ?}\"; set $1 \"${4- ?}\"" +alias _bf_pop_dispatch "_bf_pop_get $1 $2 $_bf_popstack_" +// usage: _bf_pop stackvar outvar defaultvalue +alias _bf_pop "set _bf_popstack_ \"${$1 ?}\"; set \"_bf_popstack_${$1 ?}\" \"${3 ?}\"; _bf_pop_dispatch $*" +// usage: _bf_push stackvar value +alias _bf_push "set $1 \"$2 ${$1 ?}\"" + +// skip mode: skip until matching ] (1 on _bf_execstack), then continue executing +alias _bf_skip_ "echo PROGRAMM FELL OFF THE EDGE" +alias _bf_skip_+ "_bf_skip_${* ?}" +alias _bf_skip_- "_bf_skip_${* ?}" +alias _bf_skip_< "_bf_skip_${* ?}" +alias _bf_skip_> "_bf_skip_${* ?}" +alias _bf_skip_. "_bf_skip_${* ?}" +alias _bf_skip_, "_bf_skip_${* ?}" +alias _bf_skip_endloop_0 "_bf_skip_${* ?}" // continue skipping +alias _bf_skip_endloop_1 "bf_${* ?}" // back to execution +alias _bf_skip_endloop_dispatch "_bf_skip_endloop_$_bf_stackval ${* ?}" +alias _bf_skip_] "_bf_pop _bf_execstack _bf_stackval; _bf_skip_endloop_dispatch ${* ?}" +alias _bf_skip_[ "_bf_push _bf_execstack 0; _bf_skip_${* ?}" +// enter +alias _bf_skiploop "_bf_push _bf_execstack 1; _bf_skip_${* ?}" + +// run mode: execute until matching ] (1 on _bf_execstack), then exit +alias bf_ "echo PROGRAMM FELL OFF THE EDGE" +alias bf_+ "_bf_inc _bf_register $_bf_register; bf_${* ?}" +alias bf_- "_bf_dec _bf_register $_bf_register; bf_${* ?}" +alias bf_< "_bf_push _bf_left $_bf_register; _bf_pop _bf_right _bf_register $_bf_zero; bf_${* ?}" +alias bf_> "_bf_push _bf_right $_bf_register; _bf_pop _bf_left _bf_register $_bf_zero; bf_${* ?}" +alias bf_. "echo $_bf_register; bf_${* ?}" +// note: on EOF, we don't change the register value! +alias _bf_input_get "set _bf_register $_bf_inputval; bf_${* ?}" // read input +alias _bf_input_eof "bf_${* ?}" // at EOF, just continue +alias _bf_input_dispatch "set _bf_inputval_ _bf_input_get; set _bf_inputval_$_bf_inputval _bf_input_eof; _bf_vcall _bf_inputval_ ${* ?}" +alias bf_, "_bf_pop bf_input _bf_inputval; _bf_input_dispatch ${* ?}" +alias _bf_endloop_0 "echo _bf_endloop_0 WTF?; bf_${* ?}" // continue executing +alias _bf_endloop_1 "" // back to caller +alias _bf_endloop_ "echo PROGRAMM FELL OFF THE EDGE" // back to caller +alias _bf_endloop_dispatch "_bf_endloop_$_bf_stackval ${* ?}" +alias bf_] "_bf_pop _bf_execstack _bf_stackval; _bf_endloop_dispatch ${* ?}" +// enter +alias _bf_runloop "_bf_push _bf_execstack 1; bf_$*; bf_[ ${* ?}" +// loop dispatcher +alias bf_[ "set _bf_runloop_$_bf_zero _bf_runloop; set _bf_runloop_$_bf_register _bf_skiploop; _bf_vcall _bf_runloop_$_bf_zero ${* ?}" + +// start it +alias bf_exec "_bf_clearstate; _bf_push _bf_execstack 1; bf_$1 ]" + +// "cat" +// Xon RPN: bf_input "1 2 3 4 5" +bf_input "+ ++ +++ ++++ +++++" +bf_exec "[ - ] - , + [ - . + [ - ] - , + ]" + +// output 42 +// Xon RPN: bf_input "12 6 9" +bf_input "++++++++++++ ++++++ +++++++++" +bf_exec ", > , > , < [ > [ - > + > + < < ] > > [ - < < + > > ] < < < - ] < [ - > > > - < < < ] > > > ." + +// hello world +bf_exec "+ + + + + + + + + + [ > + + + + + + + > + + + + + + + + + + > + + + > + < < < < - ] > + + . > + . + + + + + + + . . + + + . > + + . < < + + + + + + + + + + + + + + + . > . + + + . - - - - - - . - - - - - - - - . > + . > ."