I'm trying to write a simple compiler in the Arduino language that I am making up for my lab. The compiler will have to be able to turn a string like this:
"do command_one 3 times"
into a data structure that represents this:
<command_one>, <command_one>, <command_one>
it should also be able to turn something more complicated like this:
"do do c_one do c_two 2 times 2 times c_thr 2 times"
into a data structure that represents this:
<c_one> <c_two> <c_two> <c_one> <c_two> <c_two> <c_thr> <c_one>
<c_two> <c_two> <c_one> <c_two> <c_two> <c_thr>
Another function will then read the commands out one by one.
These examples show all of the functionality that I would want from the compiler.
I'm having design issues for the compiler that I want to create. Initially, I just wanted to do some string manipulation and turn the input string into an array of integers representing commands. However, since the compiler will be outputting an arbitrarily large number of commands, and since arrays in Arduino need to be initialized with a length, this could be a problem.
I am not fluent in Arduino so I am hoping that an Arduino whiz can show me a quick solution. I have already come up with the suggested solution on my own in Python, however, my solution in Python has to do with the ability to change the length of lists on the fly.
You will also notice that I posted the same question in the C++ stackexchange. I am trying to write the same code for an Arduino and in C++. I know that Arduino code is based on C++, if the answer is the same in Arduino as it is in C++ that would be very helpful.