Click here to Skip to main content
15,885,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am confuse that how to start for designing compiler ...
plz give me some idea how to start
Posted
Comments
joshrduncan2012 18-Mar-13 11:47am    
What have you attempted so far?

You could read The Dragon Book[^] and then set out to write your own compiler from scratch if you have a year or five to spare or you could join a project like LLVM/Clang and learn by contributing to a compiler in development.
Assuming you're compiling C++ the minimal basic components you'll need are:-

A File System interface to read and write source, intermediate and executable files. The Binutils Linux package contains the Binary File Descriptor library for this purpose, It's very good.

A C preprocessor like Boost::Wave

A Lexer and Parser for C++ ( This is considered a hard part and what you'd need to read and understand the Dragon book and several more in order to write )

A Code generator to take an Abstract Sytax Tree and generate IL or some form of assembly
language for the target processor.

An assembler to turn that IL or ASM into executable code.

A Linker to link together the ouputs of compilation units to form executable modules.

Writing any one of these would be a major achievement. Good Luck.
 
Share this answer
 
Comments
nv3 18-Mar-13 11:56am    
Nice compilation of things; though, I doubt that it will be appreciated by OP.
Matthew Faithfull 18-Mar-13 12:02pm    
The OP may not be too plzd but others may hit the question in a search I suppose.
As with all such things, Google is a good start: Designing Compiler[^]
That simple search gives you over 4 million hits.
Have a look at some of the links - they will almost certainly contain what you need.
 
Share this answer
 
Two programs that are popular for compiler design and construction are "Lex" and "YACC". There should be plenty of info on the web about them.

[These are popular in the linux world, which I see you flagged.]
 
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