in reply to Translating from one programming language to another automated

To translate one language into another, you need in general to write a compiler. This involves lexing the text to get tokens, parsing the tokens into an intermediate language or syntax tree, and stepping through the tree to generate the code for your new language.

In perl, lexing is easily taken care of using regexps. People oftern turn to Parse::RecDescent for parsing and conversion needs. If you have used Yacc or Bison in the C world, this module should be very easy.

A necessary ingredient for this is a VHDL grammar . The grammar describes the structure of the language and will handle things like multi-line statements automatically.

It is also possible to write your own parser, creating a top-down structure in which each nonterminal in your grammar is represented by a subroutine, but it is more work and more error prone than using Parse::RecDescent.

-Mark

  • Comment on Re: Translating from one programming language to another automated