3 ms·
If you can get (or write) a lexer/parser to generate an AST from the code, can't you easily translate it to any other language?
by sdp 16y ago
If you can get (or write) a lexer/parser to generate an AST from the code, can't you easily translate it to any other language?
- ramchip 16y agoThe semantics may be very, very different. Let's take an example with two similar languages, Java and C++. You have the AST for a piece of code which creates a struct, zeroes its memory, calls a function pointer, then calls Qt library functions to display a GUI with a few signal/slots to handle user input. How does a program 'easily' translate this into Java? Now, imagine a similar problem with Haskell, Prolog, Factor or 8-bit assembly...
- gaius 16y agoThe stuff he's talking about is mainly algorithmic e.g. pricing, the sort of stuff that you could easily write in vanilla code (e.g. no platform specific libraries).