<<

CSC 302: CONSTRUCTION 1 LECTURE 1 DEPARTMENT OF SCIENCE

ON MONDAY @ 11- 1PM; TUESDAY @ 10AM

INSTRUCTOR: OBIENU, A. . ([email protected]) CSC 302 SECOND SEMESTER

© 2018 Obienu, A. C. All rights reserved. Students enrolled in Csc 302 at MCIU and other educational institutions have explicit permission to make copies of these materials for their personal use, provided this copyright notice is preserved. GOALS OF THE CLASS

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. What is a Compiler

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Language Processors

compiler

nterpreter

much faster than interpreters. better at error diagnostics.

C , C++ Haskel Python, Javascript and LISP

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Compilation Process

❑ source programs

❑ target programs

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Abstract View

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Some Historical Highlights

➢ John W. Backus

➢ Frances E. Allen,

➢ Alfred V. Aho and Jeffrey D. Ullman

➢ Donald Knuth

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Organization of a Compiler

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Structure of a Compiler

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Example

position = initial + rate * 60

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Lexemes

position, =, initial, +, rate, *, and 60.

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Lexical Analysis

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Syntax Analysis

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Semantic Analysis

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Semantic Analysis

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Intermediate Code

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Code Optimization

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Code Generation

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Roles of a Compiler

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Qualities of a good compiler

❑ Correct ❑ Robust:

❑ Efficient:

❑ Usable:

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. The essence of Optimization

Compilers Optimize Code For:

❑ Performance/Speed

❑ Code Size

❑ Power Consumption

❑ Fast/Efficient Compilation

❑ Security/Reliability

❑ Debugging

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Assignment

ASSIGNMENT

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Assignment

1) Compiler is faster than an , Discuss?

2) Is JAVA compiled or Interpreted, Discuss?

3) Name other language processors other than

compiler and interpreter?

4) Given the following program code:

Profile = Rate * Time + Interest * 5,

Explain the various phases of a compiler

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. Next Class

For the next week, we will look at:

Lexical Analyzer and Grammars

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved. The End

QUESTIONS ?

E-mail: [email protected] Office hours: Mon, Wed & Fri, 1.30pm to 3.30pm Office: Power of Faith Building Floor 2 Rm 59

CSC 302, Second Semester. © 2018 Obienu, A. C. All rights reserved.