I am learning about compilers for self-improvement. Best way I think is writing my own very basic and primitive compiler in Swift.
I read Crenshaw‘s tutorial a few years ago and now I am following along Nystrom’s website.
I am following the tokenizer-parser-interpreter (tokens - abstract syntax tree - visitor pattern) route. That’s the easiest route from what I read thus far.
I want to add static typing though which immediately lead to needing to store type information together with the value. That lead to typechecking in a comparison operator (double < string) and thus to types knowing to which protocols they adhere.
Now I think I “understand“ why a Double in Swift is a struct. A least it makes more sense than before.
So I went looking in the Swift repository for Double (and Integer). I found String, Dictionary, and also a bunch of howto’s, docs and guides some of which I read. Though to be honest that last part seems kind of a mess and outdated(?).
That’s pretty much all I know about compilers. Unfortunately my progress is limited by time constraints. Hopefully nobody will mind too much me asking basic questions once in a while. I promise to leave out a long introduction next time.
My question now is: where are the Double and Integer source files. Could somebody point them out or show me a way to efficiently find them.