Click here to Skip to main content
15,748,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm good at programming(C,C++,Java) and still pursuing my degree. In a practical session 4-5 times I pointed out cons of a compiler and my teachers are like u must build ur own compiler to sort it out. So I winded up on the question HOW TO BUILD MY OWN COMPILER?. I am very well aware that doing that kind of stuff is not easy and is very much time consuming but I want to learn those things that challenge me.

Teachers are not always right. What are your complaints about existing compilers (or are you talking about programming languages)?
Are you going to write a compiler for an existing language or are you going to design your own language (and then write the compiler for it)?
If you are going to design your own language then could be useful read a book like "Masterminds of programming"[^].
Moreover you could use some tools for generating the compiler (at least for quick prototyping it, at early stages) like the oldie-goldie bison and flex, or ANTLR.
Share this answer
Sergey Alexandrovich Kryukov 27-Feb-14 14:13pm    
Best response so far, a 5.
See my article: POLAR - Creating a Virtual Machine in .NET[^]

In it I explain how to create a virtual machine in .NET and how to create a compiler for such virtual machine. The POLAR language is actually pretty similar to C#, but if you understand the idea you could create a compiler for anything.
Share this answer
If in doubt, start with Google: write your own compiler[^]

It will lead you here:[^], among other places - lots of other places. The info is a little dated, but it starts to give you the idea of the processes and stages involved.
As ever, the hard work isn't necessarily the compiler: it's the libraries which allow the coder to use the compiler...CSC.EXE is a relatively small file - 1.7Mb for .NET 4 - compared with a the rest of the framework at around 35Mb (depending on your system)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900