Language Converter
To import the legacy simulation models, a language translator was required. One option was to use simple parsing to convert the language. For example, I could provide a simple substitution to convert Example 1(a) to the C# in Example 1(b).
<b>(a)</b> if(x <> y) then start(1), suspend(2), a = a + 1; <b>(b)</b> if(x != y) { Model.Start(1); Model.Suspend(2); a = a + 1; }
Unfortunately, this system quickly fell apart with the case of Example 2, where x, y, and z are integers. Example 2 could run in the old language (although it was probably a mistake). However, it was not valid C# because you cannot implicitly cast an integer to a Boolean. I decided that I needed to implement a real parser to do the model translation. Since our company was already using Antlr (www.antlr.org), I used it to write a translator between the original C-like language and C#. While the resulting translated code is difficult to understand in some cases, we know it will always compile. Antlr is a great tool, and if I have to do compiler/translation tasks in the future, I would definitely consider it.
if (x < y < z) { a = 2; }