Hello monks,

I'm about to begin a large project of porting half a million lines of old 4D business logic to perl (4D's language is similar to PASCAL, but with more database features). I've written a code converter using regular expressions that does a pretty decent job, but I'm having trouble making it much better.

It seems that the best way to do such a project would be to parse the legacy code into a tree-structure and then build the perl code up from that tree. Has this been your experience? And more importantly, which tools (CPAN or otherwise) would you recommend to make this process easier. I've seen Parse::RecDescent; is this the best tool for this project?

My goal isn't to generate perfect code, only code that requires the least debugging. Also, if you have any general suggestions about writing a code translator, let me know that too.

Thanks so much,

Andrew


In reply to Translating Legacy Code to Perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.