in reply to Parsing and Translation

speedyshady:

I've had to do similar language translations before. As mentioned previously, doing it perfectly is a rather large job. However, it's often easy to get an 85%+ solution working fairly simply. If you're the one writing the 4Test code, then it's even simpler, as you can avoid many constructions that you have difficulty translating.

The way I've handled it in the past is to learn to recognize certain items, and translate them. Start with the simplest. Feel free to make assumptions[1]. Then, during your translation process, print anything untranslatable to the screen, so you can see what construction to attack next. I generally choose either the most frequently-seen item on the screen or the simplest one among those remaining.

Then, as your program evolves, you'll fix broken assumptions, restructure parts of your code to do a better job, etc. You'll also find a good place to stop--after all, unless (a) you're really good, (b) you have plenty of spare time, and (c) you have no life, you'll eventually stop improving it. You'll likely have to translate a few things by hand here and there.

...roboticus

[1] You might, for example, choose to assume that expressions fit on a single line. If you normally code that way, you can probably get away with it for a good while.

Replies are listed 'Best First'.
Re^2: Parsing and Translation
by speedyshady (Novice) on Jul 19, 2010 at 19:17 UTC

    Thanks for all of your help, guys! The Parse::RecDescent module is a gem for this. It's exactly what I needed. I've written an intepreter in Scheme and this mirrors the sllgen generator, so it should be smooth sailing from here.