Compiler Design power point presentations, Exams of Compiler Design

lexical analysis,intermidate code generation,code optimization,code generation

Typology: Exams

2020/2021

Uploaded on 03/16/2021

unknown user
unknown user 🇮🇳

3.5

(2)

1 document

1 / 122

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TULSIRAMJI GAIKWAD-PATIL
College of Engineering & Technology
Department of Computer Science and
Engineering
Session 2016-2017
Subjects Undertaken
1. Language processor (LP) -----7th sem
(CSE)
Prof.Rajesh Babu.G
Asst. Professor
Dept. of Computer Science & Engineering 1Prof.G.Rajesh BabuLP
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Compiler Design power point presentations and more Exams Compiler Design in PDF only on Docsity!

TULSIRAMJI GAIKWAD-PATIL

College of Engineering & Technology

Department of Computer Science and Engineering Session 2016- Subjects Undertaken

1. Language processor (LP) -----

th

sem (CSE)

Prof.Rajesh Babu.G

Asst. Professor

LP^ Dept. of Computer Science & Engineering Prof.G.Rajesh Babu^ 1

Language Processors (LP)

 (^) UNIT I ------------ Introduction of compilers  (^) UNIT II ------------ Syntax analysis  (^) UNIT III ------------ syntax directed translation  (^) UNIT IV------------ Table Management & Error detection and recovery  (^) UNIT V------------- code optimization  (^) UNIT VI------------ code generation

UNIT Topics No. of Questions covered in University Exam Marks covered in University Exam III Syntax directed definitions, implementation of SDTS, Intermediate code representations (postfix, syntax tree, TAC), Intermediate code generation using syntax directed translation schemes for translation of controls structures, declarations, procedure calls, and Array reference.

IV

Table Management: Storage allocation and run time storage administration, symbol table management. Error detection and recovery: Error recovery in LR parsing, Error recovery in LL parsing, automatic error recovery in YACC.

V

Code optimization: Sources of optimization, loop optimization, control flow analysis, data flow analysis, setting up data flow equations to compute reaching definitions, available expressions, Live variables, Induction Variable, Common sub expression elimination.

VI

Code generation: Problems in code generation, Simple code generator, Register allocation and assignment, Code generation from DAG, Peephole optimization.

List of Books available in Library:

Sr. No. Title Author Publisher Edition

Compilers: principles techniques and tools Ullman , Setgi , A.V.Aho Pearson education 2 rd^ ,3rd

  1. Principles of compiler design Alfred V.Aho & Jeffery D.Ullman Narosa pub House 3 rd
  2. Principles of compiler design A. M. Tenenbaum PHI Publications 4 th,^5 th
  3. Compiler Design O. G. Kakde Laxmi Publications 2009
  • (^) What is a compiler?
    • (^) A program that reads a program written in one language (source language) and translates it into an equivalent program in another language (target language). - (^) Two components - (^) Understand the program (make sure it is correct) - (^) Rewrite the program in the target language.
    • (^) Traditionally, the source language is a high level language and the target language is a low level language (machine code).
    • (^) Example: C, C++, C#, Java compiler Source program Target program Error message

Features of Compiler

• After executing program, the first task of

compiler is to create .obj file and then .exe

file.

• Compiler manages the storage of code and

variable.

• Compiler is responsible for correctness of

code and highlights the errors.

• Compiler is more intelligent

Assembler The Assembler is used to translate the program written in Assembly language into machine code. The source program is a input of assembler that contains assembly language instructions. The output generated by assembler is the object code or machine code understandable by the computer. Interpreter The translation of single statement of source program into machine code is done by language processor and executes it immediately before moving on to the next line is called an interpreter.

  • (^) If there is an error in the statement, the interpreter terminates its translating process at that statement and displays an error message.
  • (^) The interpreter moves on to the next line for execution only after removal of the error.
  • (^) An Interpreter directly executes instructions written in a programming or scripting language without previously converting them to an object code or machine code. Example: Perl, Python and Matlab.

Scanner: Lexical Analysis

  • (^) Lexical analysis breaks up a program into tokens
    • (^) Grouping characters into non-separatable units (tokens)
    • (^) Changing a stream to characters to a stream of tokens program gcd (input, output); var i, j : integer ; begin read (i, j); while i <> j do if i > j then i := i - j else j := j - i; writeln (i) end. program gcd ( input , output ) ; var i , j : integer ; begin read ( i , j ) ; while i <> j do if i > j then i := i - j else j := i - i ; writeln ( i ) end.
  • (^) What kind of errors can be reported by lexical analyzer? A = b + @3; Syntax Analysis
  • (^) Checks whether the token stream meets the grammatical specification of the language and generates the syntax tree. - A syntax error is produced by the compiler when the program does not meet the grammatical specification. - For grammatically correct program, this phase generates an internal representation that is easy to manipulate in later phases - (^) Typically a syntax tree (also called a parse tree).
  • (^) A grammar of a programming language is typically described by a context free grammer, which also defines the structure of the parse tree is

Code Generation and Intermediate

Code Forms

  • (^) A typical intermediate form of code produced by the semantic analyzer is an abstract syntax tree (AST)
  • (^) The AST is annotated with useful information such as pointers to the symbol table entry of identifiers Example AST for the gcd program in Pascal

Code Generation and Intermediate

Code Forms

  • (^) Other intermediate code forms
    • (^) intermediate code is something that is both close to the final machine code and easy to manipulate (for optimization). One example is the three-address code: dst = op1 op op
    • (^) The three-address code for the assignment statement: temp1 = 60 temp2 = id3 + temp temp3 = id2 + temp id1 = temp
  • (^) Machine-independent Intermediate code improvement temp1 = id3 * 60. id1 = id2 + temp

Summary

• Compiler front-end: lexical analysis, syntax

analysis, semantic analysis

– Tasks: understanding the source code, making

sure the source code is written correctly

• Compiler back-end: Intermediate code

generation/improvement, and Machine code

generation/improvement

– Tasks: translating the program to a semantically

the same program (in a different language).

UNIT II Syntax analysis