





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Q1) What is complier construction?
The compiler is a system program used to translate source code into machine codes. The compiler is called language translator. Every programming language has its own compilers or interpreters. The designing of interpreter is not more difficult like as compiler. The compiler construction work is enough though and logical.
Every year several software’s are lunched in market, but compiler is lunched very rarely per year. The computer engineers can design it, so, it is not like as designing of small application software using Visual Basic or Delphi. It is a time consuming process. There are many types of compilers available in market. Pascal, FORTRAN, COBOL, C, C++, C#, Java and many other high level programming and their compilers are popular among software professionals.
The source program is fed into compiler. Generally compiler converts the source code into machine codes, but some compiler converts source codes into assembly language and assembler converts them into machine language.
Q2) Phases of compilers?
The compilation process of any compilers has some special types of procedures. These
procedures are completed in pre-defined phases. When one phase is completed next phase is started. As the time of compiler designing, each phase is designed very
carefully. The compiler is a system in which source program has to pass from different phases and at last converted into machine codes.
These phases are:
The lexical analysis or scanning is a process to take source program and procedure lexical tokens or tokens. The lexical analysis is efficiently handled by lexer or lexical analyzer.
Example:
amount := salary + rent;
Tokens are:
(a) Amount: Identifier
(b):=: Assignment symbol
(c) Salary: Identifier
(d) +: Operator
(e) rent : Identifier
The token is a lowest level sequence of sub-string which contains numerical constants, literal strings, operator symbols, punctuation symbols and control structures such as assignment, conditions and looping.
2. Syntax Analysis
The grouping of tokens into grammatical phrases is called syntax analysis or parsing. The context-free grammar is usually used for describing the structure of language. The BNF (Backus- Naur Form) notation is popular in computer science, used to represent and define grammar of programming language.
A syntax analyzer takes tokens as input and output error message if program syntax is wrong. There are many algorithms for parsing. The most popular types of parsing are top-down parsing and bottom-up parsing.
Parse tree:
The semantic analysis is a process of semantic error detection in source program. Sometimes, grammatically correct statements are not semantically correct. So, compiler is equipped with semantic error checking facilities.
Q3) Define Code Generator?
Q4) Error recovery method in Compiler constriction?
Q7) What is shift reduce parsing?
Q8) Diff b/w Intermediate and code generator?
Intermediate Representation Intermediate codes can be represented in a variety of ways and they have their own benefits.
Intermediate code can be either language specific (e.g., Byte Code for Java) or language independent (three-address code).
Three-Address Code Intermediate code generator receives input from its predecessor phase, semantic analyzer, in the form of an annotated syntax tree. That syntax tree then can be converted into a linear representation, e.g., postfix notation. Intermediate code tends to be machine independent code. Therefore, code generator assumes to have unlimited number of memory storage (register) to generate code.
Q9) Diff b/w push and pop?
PUSH and POP are commands used on a stack. In computer science, a stack is an area of memory that holds all local variables and parameters used by any function. This is essential as a stack remembers the order in which functions are called so that function returns occur correctly.
A stack is a restricted data structure, because only a small number of operations are performed on it. A stack is named due to its ability to place individual data entries in a stack, like a stack of books. The first entry goes in the bottom, and corresponding entries are placed on top of the first entry. However, if something from the middle or bottom of the stack needs to be accessed, then everything on top of that entry must be removed first, before gaining access to the entry. This type of arrangement is called LIFO (Last In, First Out).