1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
begingroupundo;
gofiletop;
$code['>'] = "#ptr=#ptr+1;";
$code['<'] = "#ptr=#ptr-1;";
$code['+'] = "#buf[#ptr]=#buf[#ptr]+1;";
$code['-'] = "#buf[#ptr]=#buf[#ptr]-1;";
$code['.'] = "insert char(#buf[#ptr]);";
$code[','] = "call get;";
$code['['] = "while(#buf[#ptr]){";
$code[']'] = "}";
#isUsedGetchar = false;
while( code != eof ) {
    if( code == ',' ) #isUsedGetchar = true;
    insert $code[code];
    delete;
}
if( #isUsedGetchar ) {
    insert "endmacro;get:if($get==\"\"&&#c<=0)$get=input(\"入力\");#c=ascii($get);if($get==\"\")#c=-1;$get=rightstr($get,strlen($get)-strlen(char(#c)));#buf[#ptr]=#c;return;";
}
endgroupundo;