> what if I replace Python's Grammar file with a Java grammar (for > example, the java grammar included in the ANTLR distribution). Hacked > appropriately to map java source to the tokens defined in python's > Grammar would in theory make python 'understand' java. If you're planning on feeding the resulting parse tree to the existing Python bytecode compiler, you don't stand a chance. The compiler is absolutely dependent on getting a particular parse tree structure, and that structure is derived directly from the grammar. The best you could hope for this way would be to get something which is really Python with a few cosmetic alterations to make it look very vaguely Java-like. There's no way it's going to be able to handle arbitrary real-life Java code. To handle anything like real Java, you'll have to extensively rework the bytecode compiler to match the new grammar. Not to mention deciding what to do about all the semantic differences between Python and Java. If you really want to tackle this, go ahead, it sounds like an interesting project -- but be aware that it will be a LOT of work. Unless you've got an enormous amount of Java to translate, it's going to be faster and easier to just rewrite it by hand! Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4