I'm on a quest to write a LISP-ish language that compiles to Brainfuck. Well, it's a stack of intermediate compilers actually. Currently I'm trying to write the one that transforms this code:a++b+ainto:++>+<It's standard Brainfuck, but with variables added.The compiler is responsible for two things:Assigning a and b some address in the memory, say, 0 and 1Translating each occurrence of a and b into a number of <'s or >'s so the memory pointer ends up at the right locationNow, here's the thing: in order for the compiler to know how many <'s to put, it needs to know where the memory pointer currently points to. At first it points to 0, but as the code gets executed, the pointer moves around and to get to a you need to move relatively from where you're at.So the only way to know the value of the memory pointer would be to execute the code and replace variable names as you go. Oh, mempoint is now 4, I see an a and it's location is 1 so i need to move three places left: <<<If I close my eyes I can hear a voice saying: you're trying to solve the Halting ProblemSo my question is: am I really? Is there any way around?
Is is possible to write a Brainfuck with variables compiler?
brainfuck