Click here to Skip to main content
13,047,502 members (57,341 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am confuse that how to start for designing compiler ...
plz give me some idea how to start
Posted 18-Mar-13 5:22am
joshrduncan2012 18-Mar-13 11:47am
What have you attempted so far?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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.]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100