Compiler Design

of 12
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
1st chapter
  Compiler Design. Why to learn about compilers ? Few people will ever be required to write a compiler for a general- purpose language like C, Pascal. So why do most computer science institutions offer compiler courses and often make these mandatory? Some typical reasons are : a) It is considered a topic that you should know in order to be “ well- cultured” in computer science.  b) A good craftsman should know his tools, and compilers are important tools for programmers and computer scientists. c) The techniques used for constructing a compiler are useful for other purposes as well. d) There is a good chance that a programmer or computer scientist will need to write a compiler or interpreter for a domain-specific language. Understanding how a compiler is built will allow programmers to get an intuition about what their high-level programs will look like when compiled and use this intuition to tune programs for better efficiency. Furthermore, the error reports that compilers provide are often easier to understand.  What is a compiler? ã In order to reduce the complexity of designing and building computers, nearly all of these are made to execute relatively simple commands (but do so very quickly). ã A program for a computer must be built by combining these very simple commands into a  program in what is called machine language. Since this is a tedious and errorprone ã  process most programming is, instead, done using a high-level programming language. This language can be very different from the machine language that the computer can execute, so some means of bridging the gap is required. This is where the compiler comes in. ã A compiler translates (or compiles) a program written in a high-level programming language that is suitable for human programmers into the low-level machine language that is required  by computers. During this process, the compiler will also attempt to spot and report obvious  programmer mistakes. ã Using a high-level language for programming has a large impact on how fast programs can be developed. The main reasons for this are: ã  Compared to machine language, the notation used by programming languages is closer to the way humans think about problems. ã  The compiler can spot some obvious programming mistakes. ã  Programs written in a high-level language tend to be shorter than equivalent programs written in machine language. ã Another advantage of using a high-level level language is that the same program can be compiled to many different machine languages and, hence, be brought to run on many different machines.  Analysis of the Source Program ã It consist of 3 types ã Linear Analysis ã Hierarchal Analysis ã Semantic Analysis  Linear Analysis ã In which the stream of characters making up the source program is read from left-to-right and grouped into tokens that are sequences of characters having collective meaning.
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks