Starting from this article, we are going to present a free guide and introduction to the principles of Compiling a program. Beginners can read it as a brief guide to get started on Compilers.Going forward we will be looking into GNU's GCC. I am avoiding too much details and providing information enough for Freshers/ Engineers and Undergrads to understand compilers.
A compiler is a program that reads another program, called the source code ( written in a particular high level programming language) and converts it into, a low level language.
By low level I mean either Assembly or machine code.
Also, as a part of the compilation process, the compiler will report the errors present in the source code.
It is but obvious, that this compilation process can not happen in a single step. That is to say, the compilation process in itself is broken up into a series of processes. In most cases, compilation process can be grouped into two parts: Analysis and Synthesis.
While Analyzing, the source code is converted to an intermediate representation.
Lets us briefly look at how this happens:
- Lexical Analysis :
- Stream of characters from Source program are scanned from left to right.
- Meaningful Tokens are identified based on programming language rules.
- spaces are eliminated
- Parsing : grouping of tokens to generate PARSE TREE
- Syntax Analysis
- Check syntax as per programming language specs (type casting etc.)
- convert parse tree into SYNTAX TREE
- Semantic Analysis
- check for semantic errors
Although an error can occur at any stage, the syntax and semantic analyzing phases generally detect most of the errors in the program.
Based on the above we arrive at some building blocks of a compiler.
This is early part of the compiler as shown above is commonly called the FRONT END.
Do you have Questions? Arguments? doubts?... we'll try our best to resolve
Provide us with valuable Suggestions / Ideas / or clues...
Please leave us a commentProvide us with valuable Suggestions / Ideas / or clues...
No comments:
Post a Comment
Have a suggestion or feedback... Please take a minute to tell me your opinion