#include "pch.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <iostream>
#include "Random1.h"
struct cell {
int c, d;
// int label;
};
size_t width(const char* s)
{
const char* p;
for (p = s; *p && *p == *s; p++);
return p - s;
}
size_t nop_width(const char* s)
{
const char *p;
for (p = s; *p; p++) {
if (*p == '>' || *p == '<' || *p == '+' || *p == '-')
break;
if (*p == '.' || *p == ',' || *p == '[' || *p == ']')
break;
}
return p - s;
}
cell* find_square_bracket_right(cell* p)
{
int depth = 0;
for (; p->c; p++) {
if (p->c == '[')
depth++;
else if (p->c == ']') {
if (depth == 0)
break;
else
depth--;
}
}
return p;
}
cell* init_square_brackets(cell* b)
{
cell* p;
cell* q;
for (p = b; p->c; p++) {
if (p->c == '[') {
q = find_square_bracket_right(p + 1);
p->d = static_cast<int>(q - p + 1);
q->d = static_cast<int>(-(q - p) + 1);
}
}
return b;
}
cell* scan(const char* s)
{
cell* cells = static_cast<cell*>(std::malloc((sizeof(cell)) * (strlen(s) + 1)));
cell* p;
for (p = cells; *s; s += p->d, p++) {
switch (p->c = *s) {
case '>': case '<': case '+': case '-':
p->d = static_cast<int>(width(s));
break;
case '.': case ',': case '[': case ']':
p->d = 1;
break;
default:
p->d = static_cast<int>(nop_width(s));
break;
}
}
p->c = '\0';
p->d = 0;
return init_square_brackets(cells);
}
// putcharをバッファに溜めておいて一度に出力するバージョン
cell* f(cell* __restrict ip0, char* __restrict dp)
{
cell* __restrict ip = ip0;
static char buf[100000] = {0};
char* __restrict bufp = buf;
while (true) {
switch (ip->c) {
case '>': // increment pointer(IP)
dp += ip->d; ip++;
break;
case '<': // decrement pointer(DP)
dp -= ip->d; ip++;
break;
case '+': // increment value pointed by pointer(IVP)
*dp += ip->d; ip++;
break;
case '-': // decrement value pointed by pointer(DVP)
*dp -= ip->d; ip++;
break;
case '.': // write value to output pointed by pointer(WVP)
*bufp++ = *dp;
// putchar(*dp);
ip++;
break;
case ',': // read value from input and store to the point pointed by pointer(RVP)
*dp = getchar(); ip++;
break;
case '[': // when value pointed by pointer is zero, jump after correspoiding ']'(ZJC)
(*dp) ? ip++ : (ip += ip->d);
break;
case ']': // when value pointed by pointer is not zero, jump after correspoiding '['(NZJC)
(*dp) ? (ip += ip->d) : ip++;
break;
case '\0': // end of program
goto end;
default: // skip other characters
ip++;
break;
}
}
end:
bufp = '\0';
std::puts(buf);
return ip0;
}
void g(const char* s)
{
static char data[30000] = {0};
auto sw = std::make_shared<Stopwatch>();
sw->Start();
cell* cs = scan(s);
// std::cout << "Scan Completed." << std::endl;
cell* ds = f(cs, data);
// std::cout << "Interpret Completed." << std::endl;
std::free(ds);
sw->Stop();
std::cout << "Elapsed " << sw->ElapsedMillisecond() << "ms." << std::endl;
}
int main() {
const char *s =
" A mandelbrot set fractal viewer in brainf*** written by Erik Bosman"
"+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[["
">>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+"
"<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>"
">+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>"
">>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>"
">>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>"
">>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>"
"[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>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