Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to write a very simple compiler.

How can I find a simple open source compiler so that I can learn about writing a compiler?

Thanks
Posted
Updated 7-Jan-11 4:26am
v2

 
Share this answer
 
Comments
fjdiewornncalwe 7-Jan-11 10:17am    
+5. Great Links.
Nuri Ismail 7-Jan-11 10:39am    
Good call! +5
Please take also this tool into consideration:

ANTLR[^]

There is a C# version available on the download site:

ANTLR download[^]

Caution commercial product: This one is pretty easy to handle even for beginners. My sister could do it and she isn't even a programmer/developer:
ProGrammar[^]


This tool is great for small DSLs or also for bigger languages. It does however take a bit of studying the documentation and the samples. Having seen a grammar specification before would also come in handy.

Best regards,
Manfred
 
Share this answer
 
v2
Comments
Espen Harlinn 7-Jan-11 6:43am    
5+ Seems we are on the same track :)
fjdiewornncalwe 7-Jan-11 10:16am    
+5... Great links.
Nuri Ismail 7-Jan-11 10:39am    
Good call! +5
thatraja 7-Jan-11 21:23pm    
Yep, good tool.
You can start by looking at http://www.antlr.org/[^]

and

http://boost-spirit.com/home/[^]

Antlr is a parser generator, with lots of extra goodies. Generates code for java, c#, c, and other programming laguages.

boost spirit allows you to define your parser directly in C++, using constructs that closely resembles Extended Backus–Naur Form.

compilation involves parsing as the first step towards code generation.

parse programming language, possibly optimize, generate machine code - or possibly other stuff ...

Regards
Espen Harlinn
 
Share this answer
 
Comments
Manfred Rudolf Bihy 7-Jan-11 7:50am    
Good call! 5+
Gotta look into that boost-spirit stuff. I forgot a commerical one: "Programmar". Even my not so IT sister got a DSL compiler running with that.
Espen Harlinn 7-Jan-11 7:52am    
Thanks - Yes, boost spirit is interesting
fjdiewornncalwe 7-Jan-11 10:17am    
+5... Great links.
Nuri Ismail 7-Jan-11 10:40am    
Good answer! +5
Espen Harlinn 7-Jan-11 12:17pm    
Thanks Nuri!
If you want to learn how to build a simple compiler (without using tools) then "Let's build a compiler, by Jack Crenshaw"[^] may be a worthy reading.
:)
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 7-Jan-11 8:35am    
Thanks for the link! 5+
fjdiewornncalwe 7-Jan-11 10:17am    
That one is good for me too... +5.
Nuri Ismail 7-Jan-11 10:38am    
Very useful link! +5
thatraja 7-Jan-11 21:22pm    
Good resource CP!

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