-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asking for help #2
Comments
Hi @SuperJMN, TLDRYou might find studying the source of these compilers useful. Their code bases are really small and comprehensible.
ParsingWas in a similar spot re parsing. Parsing theory is a really interesting field of computer science, but it gets really complex really fast, just as you say. But in my opinion what's more important to us, hobbyist compiler writers, is having a working example that we can look at and fully understand. And all such example compilers I managed to find have hand-crafted recursive descent parsers. So that's what I would suggest you go with. Once you get into the groove, you'll realize it isn't all that hard to write after all. What's interesting, production-grade compilers like The example compilers I'm talking about are: The last two are much bigger than Roadmap
I would surely write a compiler :)
C is considered to be a small language, but that's a bit deceptive. Writing a C compiler isn't a small project. You might want to keep that in mind depending on how much time you can dedicate to it.
If I was writing a C compiler I would definitely target an existing machine, most likely x86/x64. You'll want the compiler to compile programs that invoke libc functions like Good luck! |
Hi Mykola. I smell goodness wherever it is, and I feel you are the kind of person that I'd call a mentor. I hardly fail when it comes to this perception. Thanks for the time to think and write this helpful piece of gold. This is such a great advice! I'll study every link, project and book you recommended. I've already got a glance at 8cc and look really promising. The fact that he even wrote a log with a short description of the goals and challenges he found is fantastic. I felt somewhat identified with some of his thoughts when I attempted to create a C compiler (https://github.com/SuperJMN/Plotty). It became a failed attempt at some point, but it was useful to make me realize I needed to "level up", if I may use this expression. I thank you once again, and if you ever feel the need to create a C compiler, please, let me know. I will always be interested and will follow your work. You're already an authority for me. Best wishes from Spain, |
Hello!
My dream is to create a ANSI C compiler (using C#), but I'm a bit lost
Regarding the parser part, I've played with a very nice parser combinator library (https://github.com/datalust/superpower), and I really love how simple it is. But in fact, they're so simple that they aren't able to deal with left-recursion.
That's why I got interested in GLL parsers, because they said it was a way to fix the problems with parser combinators... until I find out that the literature is really complex and there isn't entry-level stuff around the Internet.
So here I am. I will investigate a bit more, but just in case you want to answer me, I would like to ask you a question:
What would you do if you were me?
I mean, would you attempt to create an ANSI C compiler back then? or maybe today you would totally reject doing that because of reasons?
What steps would you follow if you decided to go ahead?
Would you target an existing machine, like x86/x64, or invent a (invented) virtual architecture (to simplify things).
Thanks a lot!
The text was updated successfully, but these errors were encountered: