user4335: 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.

user10007: You may have more luck investigating standard C ways of dealing with this issue, instead of the common C++ methods. 
Although it is typically not advised, you can use malloc and free on the Arduino. This allows you to dynamically use memory. I would provide a more detailed code example than below but when using dynamic memory it can be hard to troubleshoot what is going on without the use of a library to simplify the process. I would strongly advise doing a little study and understanding both dynamic memory management, and the repercussions of doing so on the Arduino platform. A solid foundation in this will pay off tenfold in time saved when debugging.
Note that you should check each time that you call malloc that it is successful
These resources might help:

Dynamic Arrays
Check Malloc Succeded
Malloc and Free on Arduino Discussion
Is it a bad idea?

Simple Example:
// Make a pointer to your array
someType *A;

// The size of your array, may be changed programmatically.
int arraySize = 5;

// Reserve memory for your array.
A = malloc(arraySize * sizeof(someType));

// Use Array
A[0] = someData;

// Release A's memory when complete.
free(A);


user353: 
The Arduino IDE features nearly full C++ language support (at least for C++03 features).
library support is limited, but any standard component you need, you should be able to get an open source implementation that compiles.
That said, you have 2K of RAM to work with on an Arduino, so the kind of C++ code you would write for a general purpose computer just won’t get you very far.
I could be wrong, but I very much doubt there are full Python implementations for Arduino.

Edit: Thanks to Mr. Penguin for pointing out that we’re dealing with an Arduino Due, not an Uno (I had overlooked the OP’s tag). 96K of memory is actually a decent amount to play with, so grab a library implementation like this one and use the C++ techniques you wish to use.

user220: You question isn't totally clear to me, so this is just a pile of advice:

I think that you might be looking for a run() type of command, where you can run any function in code. However, since C++ is a compiled language, this is not possible. You can only do this in scripting languages.
Besides that, you want a variable length array? I haven't been able to confirm that this works with Arduino, but I know in standard C++ it is called dynamic memory allocation and you can do this with a pointer.
As for the string to store your data, where you're heading is wrong if you care about efficiency. I'd go with an array of integers (unsigned int myData[2] = {1, 290};) since you can store a lot more data in two bytes than you could typing out the function names.

For the "multiple run" function of your language, a simple for loop might work better to save space:
for(int x = 5; x <3; x++) {
  //Code here
}


Another thing you might want to do is store this "code" on a SD card encoded in two characters to yield a number like this:
byte valOne = SD.read();
byte valTwo = SD.read();
int outputVal = (valOne << 8) + valTwo;

This would solve the whole variable array crisis in the first place.
End of unorganized thoughts...

4335: <p>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:</p>

<pre><code>"do command_one 3 times"
</code></pre>

<p>into a data structure that represents this:</p>

<pre><code>&lt;command_one&gt;, &lt;command_one&gt;, &lt;command_one&gt; 
</code></pre>

<p>it should also be able to turn something more complicated like this:</p>

<pre><code>"do do c_one do c_two 2 times 2 times c_thr 2 times"
</code></pre>

<p>into a data structure that represents this:</p>

<pre><code>&lt;c_one&gt; &lt;c_two&gt; &lt;c_two&gt; &lt;c_one&gt; &lt;c_two&gt; &lt;c_two&gt; &lt;c_thr&gt; &lt;c_one&gt;
                &lt;c_two&gt; &lt;c_two&gt; &lt;c_one&gt; &lt;c_two&gt; &lt;c_two&gt; &lt;c_thr&gt;
</code></pre>

<p>Another function will then read the commands out one by one.</p>

<p>These examples show all of the functionality that I would want from the compiler.  </p>

<p>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.  </p>

<p>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.  </p>

<p>You will also notice that I posted the <a href="https://stackoverflow.com/questions/26303582/simple-compiler-design-help-variable-length-arrays-for-c">same question</a> 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.</p>
 10007: <p>You may have more luck investigating standard C ways of dealing with this issue, instead of the common C++ methods. </p>

<p>Although it is typically not advised, you can use malloc and free on the Arduino. This allows you to dynamically use memory. I would provide a more detailed code example than below but when using dynamic memory it can be hard to troubleshoot what is going on without the use of a library to simplify the process. I would strongly advise doing a little study and understanding both dynamic memory management, and the repercussions of doing so on the Arduino platform. A solid foundation in this will pay off tenfold in time saved when debugging.</p>

<p>Note that you should check each time that you call malloc that it is successful</p>

<p>These resources might help:</p>

<ul>
<li><p><a href="http://forum.codecall.net/topic/51010-dynamic-arrays-using-malloc-and-realloc/" rel="nofollow noreferrer">Dynamic Arrays</a></p></li>
<li><p><a href="https://stackoverflow.com/questions/5607455/checking-that-malloc-succeeded-in-c">Check Malloc Succeded</a></p></li>
<li><p><a href="http://forum.arduino.cc/index.php?topic=37796.0" rel="nofollow noreferrer">Malloc and Free on Arduino Discussion</a></p></li>
<li><p><a href="https://arduino.stackexchange.com/questions/682/is-using-malloc-and-free-a-really-bad-idea-on-arduino">Is it a bad idea?</a></p></li>
</ul>

<p>Simple Example:</p>

<pre><code>// Make a pointer to your array
someType *A;

// The size of your array, may be changed programmatically.
int arraySize = 5;

// Reserve memory for your array.
A = malloc(arraySize * sizeof(someType));

// Use Array
A[0] = someData;

// Release A's memory when complete.
free(A);
</code></pre>
 353: <ol>
<li>The Arduino IDE features nearly full C++ <em>language</em> support (at least for C++03 features).</li>
<li><em>library</em> support is limited, but any standard component you need, you should be able to get an open source implementation that compiles.</li>
<li>That said, you have <strong>2K</strong> of RAM to work with on an Arduino, so the kind of C++ code you would write for a general purpose computer just won’t get you very far.</li>
<li>I could be wrong, but I very much doubt there are full Python implementations for Arduino.</li>
</ol>

<p><strong>Edit:</strong> Thanks to Mr. Penguin for pointing out that we’re dealing with an Arduino Due, not an Uno (I had overlooked the OP’s tag). 96K of memory is actually a decent amount to play with, so grab a library implementation like <a href="https://github.com/maniacbug/StandardCplusplus" rel="nofollow">this one</a> and use the C++ techniques you wish to use.</p>
 220: <p>You question isn't totally clear to me, so this is just a pile of advice:</p>

<ul>
<li>I think that you <em>might</em> be looking for a <code>run()</code> type of command, where you can run any function in code. However, since C++ is a <em>compiled</em> language, this is not possible. You can only do this in scripting languages.</li>
<li>Besides that, you want a variable length array? I haven't been able to confirm that this works with Arduino, but I know in standard C++ it is called <em>dynamic memory allocation</em> and you can do this with a pointer.</li>
<li>As for the string to store your data, where you're heading is wrong if you care about efficiency. I'd go with an array of integers (<code>unsigned int myData[2] = {1, 290};</code>) since you can store a <em>lot</em> more data in two bytes than you could typing out the function names.</li>
</ul>

<p>For the "multiple run" function of your language, a simple for loop might work better to save space:</p>

<pre><code>for(int x = 5; x &lt;3; x++) {
  //Code here
}
</code></pre>

<hr>

<p>Another thing you might want to do is store this "code" on a SD card encoded in two characters to yield a number like this:</p>

<pre><code>byte valOne = SD.read();
byte valTwo = SD.read();
int outputVal = (valOne &lt;&lt; 8) + valTwo;
</code></pre>

<p>This would solve the whole variable array crisis in the first place.</p>

<p><em>End of unorganized thoughts...</em></p>
