hi everyone.....
how to create a c compiler using c language....
can anyone explain the steps involved.....
thnx in advance

hi everyone.....
how to create a c compiler using c language....
can anyone explain the steps involved.....
thnx in advance

Are you ready to study compiler generation ABCs (at least 0.5 year, ~1000 pages) then make a hard work for at least 2 years in 7/24 manner?

no this is given as an assignment .....
i ve asked to do compiler which supports basic functions such as looping,conditional,importing header......
i dont have years of time i have only 2 and a half months....
what is lex and yacc....

i came across a word bootstrapping which is creating a compiler for a language using the same language.....
how to bootstrap a c compiler using c??????
any ideas.....

how to bootstrap a c compiler using c??????
any ideas.....

(Someone's really joking with you when he/she said you to write a compiler in 2 months.In this time you cant even study the basics properly.And moreover you don't know whats LEX and YACC is which can be treated as foundation stones to compiler building.So please stay away from words like bootstrap etc for now.)

Well to deal with your problem in hand the max you can do is to write a C program which takes another file (containing some lines of code like looping etc) as input and splits and tabulates the contents and tries to find a particular pattern there.

so what r the steps to create compiler

0. Study the C language Standard.
1. Make the project plan.
2. Design the compiler architecture.
3. Make the scanner (a lexical analyzer).
4. Make the parser (a syntax analyzer).
5. Make the code generator.
6: (2..5). Make (or select) the test suite.
7: (0..6). Make the compiler documentation.

Don't worry: it's possible to write a good compiler without lex or yacc ;)...

There are tons of useful links for self-made compiler creators, for example:
http://www.cs.vu.nl/~dick/PTAPG.html

can u tell me some links which will be useful to me in creating a compiler......
i need compiler for only some basic functions like conditional statements,loops...

>can u tell me some links which will be useful to me in creating a compiler......
Maybe if you gave us the actual requirements for your assignment. You're confusing a lot of people here by saying you need to write a C compiler in two months, but it only needs so and so features.

can u tell me some links which will be useful to me in creating a compiler......
i need compiler for only some basic functions like conditional statements,loops...

Well, if you want silver bullet links then you may download the Tiny C Compiler sources (GNU LGPL) from
http://bellard.org/tcc/
It's a very very small C compiler ( ~1MB source codes ;) ).
Try to reduce its size for 2 month ;)
Send best regards to your teachers - what's a wonderful assignment!...

Write a short parser for what minimal things it must do, study up on the Windows PE format and machine code(a good disassembler helps), then just put out the minimal code to achieve that minimal list of features.

This article has been dead for over six months. Start a new discussion instead.