Welcome to the first entry of the second release of this blog.
I created C++ interpreter in clear Python, and its general principle of action is having source code in the memory, then compiling code after every passed line and returning the output on the screen.
List of assumptions(in general):
In the first line we call "python3 cpp_interpreter.py", it creates the directory "env1",
which we can see in the second line "env: env1".
In the next line, we are in actual interpreter already. Every line that that starts with ">>" accepts instructions. I type "2;" there, so we can see that it appears in source code. Lines that starts with number and colon "number:" represent current source code.
The next prompt line says "std::cout<<"test"" and we can see that the return output from the program is actually "test".
Then I removed the fourth line by typing "4:-", simply to say that the pattern to remove a line is "number:-".
Now, let's say that we want to have clear code again without restarting the script, in which case we could type "_r" in order to go back to very basic source code. Furthermore I just type Enter to run current code.
Okay on the next prompt we can see a super cool and awesome feature, namely changing specific lines, which we can achieve by typing the number and two colons with a new code on the end, "number::new code here;".
The next amazing feature allows us to add a few lines at a time without compiling each of them one by one, instead of they will be compiled only once at the end. To use that feature you have to space left at the end of the line.
Further I wanted to demonstrate what happens when you do something wrong. You will see output from the compiler, and your source code will be restored to the last correct one.
On the second-to-last line, I've added one more line to show that everything still works after incorrect input.
On the last line, I typed "_exit" to close script.
And here we can see one more thing(on the last bash command), namely that out environment directory has a "commands.log" file that contains everything we've entered.
Here, on the first bash command line, we specify where to create the environment directory,
after which I add some code and leave the script, and then do the same for another
Then I list directories to show that the script can calculate correctly to create the next catalog.
Then we can see what is in each directory, each of which always has 3 files, namely main.cpp, main.bin, and commands.log.
Last command display for us content from main.cpp files from both environments.