schwalbe-sprach / schwalbe

"Transpiler" from the Schwalbe Programming Language to Swift
MIT License
27 stars 1 forks source link

Why not use the swift parser? (Warum wird der Schwalbe Syntaxanalysierer nicht benutzt?) #9

Closed JustusAdam closed 7 years ago

JustusAdam commented 7 years ago

(German version below!)

As far as I know the Swift language and compiler are open source. Why not use the original swift lexer + parser to read the input (you know, good old copy&past code) and just replace the keywords with the german ones?

That'd certainly be better.

Alternatively, if the swift compiler is as cool as GHC (😝 ) and the swift compiler can be used like a library then change the tokeniser and then directly hand the AST to the compiler library for compilation?

---------- german version ----------

So weit ich weiß ist die Schwalbe Sprache und der Übersetzer offene Quelle. Warum benutzt du nicht den originalen Schwalbe lexikalischen Scanner + Syntaxanalysierer um die Eingabe zu lesen (du weißt schon, guter alter Kopieren-und-Einfügen Kode) und ersetzt einfach die Schlüsselwörter mit den deutschen?

Das wäre sicherlich besser.

Alternativ, wenn der Schwalbe Übersetzer so toll sein sollte wir GHC (😝 ), und der Schwalbe Übersetzer wie eine Bibliothek verwendet werden kann, dann ändere doch einfach den Tokenisierer and dann gibt den Abstrakten Syntaxbaum direkt an die Übersetzerbibiliothek zum Übersetzen?

kiliankoe commented 7 years ago

My original intention was to fork the Swift compiler and edit it accordingly, keeping all the hard work the compiler team had poured into that. The issue with that was that it turned out not be as easy as I had thought 😅 I found some mentions of the syntax in the codebase, but after building it (which took somewhere from 1 to 4 hours for every build) the compiler still seemed to only want to work with the original syntax 😕 I spent some more time digging around, unfortunately to no avail. It also didn't help that I had to make a clean build every now and then (pushing the build times back up), since the build artifacts were occupying about 20-40GB of space on my drive. Also... it really didn't help that Swift unfortunately isn't self-hosted (yet), but is written in C++.

Unfortunately the last point is also the reason why it's not possible to reuse compiler code in this project 😞 It would definitely improve this quite a bit, since the current implementation here is terrible. But although it would definitely be pretty cool, this project is never going to find actual usage anywhere (at least I seriously hope that), so the added benefit of having a clean toolchain emitting correct Swift (or LLVM IR directly?) is more or less moot.

But... nobody's saying it wouldn't be a fun project for the future 😄 So there's technically already a tracking issue → #1 😊