Prof Fateman CS 164 Lecture 371 Review: Programming Languages and Compilers CS164 9-10AM MWF 10 Evans.

Slides:



Advertisements
Similar presentations
1 CIS 461 Compiler Design and Construction Fall 2014 Instructor: Hugh McGuire slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon Lecture-Module.
Advertisements

Copyright © 2005 Elsevier Imperative languages Group languages as –imperative von Neumann(Fortran, Pascal, Basic, C) object-oriented(Smalltalk, Eiffel,
Compiler Construction by Muhammad Bilal Zafar (AP)
By Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
6/12/2015Prof. Hilfinger CS164 Lecture 111 Bottom-Up Parsing Lecture (From slides by G. Necula & R. Bodik)
Prof Fateman CS 164 Lecture 11 Introduction to Programming Languages and Compilers Prof. Richard Fateman CS164 Fall :30-11AM Room 22 Warren Hall.
January 12, Compiler Design Hongwei Xi Comp. Sci. Dept. Boston University.
January 19, Compiler Design Hongwei Xi Comp. Sci. Dept. Boston University.
Prof. Fateman CS 164 Lecture 91 Bottom-Up Parsing Lecture 9.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 10: Compiler I: Syntax Analysis slide 1www.idc.ac.il/tecs.
1 How are Languages Implemented? Two major strategies: –Interpreters (older, less studied) –Compilers (newer, more extensively studied) Interpreters run.
CS 2104 Prog. Lang. Concepts Dr. Abhik Roychoudhury School of Computing Introduction.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
COP4020 Programming Languages
CS 153: Concepts of Compiler Design August 24 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
CS453 LectureIntroduction1 CS453 Compiler Construction Instructor:Wim Bohm Computer Science Building 470 TA: tba
Compilation in More Detail Asst. Prof. Dr. Ahmet Sayar Spring-2012 Kocaeli University Computer Engineering Department Principles of Programming Languages.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Prof. Fateman CS 164 Lecture 111 Syntax  Simple Semantics Lecture 11.
Lexical Analysis: Finite Automata CS 471 September 5, 2007.
Introduction to Parsing
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Compilation With an emphasis on getting the job done quickly Copyright © – Curt Hill.
Introduction to Compiling
Compiler Construction (CS-636)
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Compiler Construction By: Muhammad Nadeem Edited By: M. Bilal Qureshi.
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.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
CS510 Compiler Lecture 1. Sources Lecture Notes Book 1 : “Compiler construction principles and practice”, Kenneth C. Louden. Book 2 : “Compilers Principles,
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Functional Programming
Advanced Computer Systems
Chapter 1 Introduction.
Introduction to Compiler Construction
CS 3304 Comparative Languages
CS 326 Programming Languages, Concepts and Implementation
PROGRAMMING LANGUAGES
Programming Language Hierarchy, Phases of a Java Program
Syntax Simple Semantics
Chapter 1 Introduction.
PROGRAMMING LANGUAGES
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
CS416 Compiler Design lec00-outline September 19, 2018
Introduction CI612 Compiler Design CI612 Compiler Design.
Compiler Construction
CPSC 388 – Compiler Design and Construction
CMP 131 Introduction to Computer Programming
CS416 Compiler Design lec00-outline February 23, 2019
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Presentation transcript:

Prof Fateman CS 164 Lecture 371 Review: Programming Languages and Compilers CS AM MWF 10 Evans

Prof Fateman CS 164 Lecture 372 Aministrivia Sample final questions will be posted Projects (rather than exams) will probably be weighted more for grades. Final Exam is Dec 18, morning We agreed that it should be closed book, but 3 pages, (6 sides) of your handwritten notes can be taken to the exam.

Prof Fateman CS 164 Lecture 373 Review: Why Should you Study Compilers/ Programming Languages? Increased capacity to express ideas Improved background for choosing appropriate tools / languages Increased ability to learn “new” languages or design new ones Better understanding of the interchange between implementation and design Appreciation of the beauty of relevant material from CS 61a/b/c CS170, Math 55

Prof Fateman CS 164 Lecture 374 What can you do with your new skills? Understand/ be a TA/ for CS61a/b/c Or a reader for CS164 Appreciate CS188 (since you know Lisp better!) Take graduate courses CS 264, 263 Take graduate course CS282 (W,F, 9:30) taught by Prof. Fateman: Algebraic Algorithms: need some math, CS164, Lisp helps Get a high-paying job

Prof Fateman CS 164 Lecture 375 Recall: The Course Project A big project. Written in Common Lisp. … in several easy parts Why Lisp? –Typical JAVA/C++ project code size: 5,000 lines –Typical Lisp code size: 2000 lines. –You are given 1000 lines in “skeletons” either way, so the ratio is about 4:1 in favor of Lisp –You all know Scheme; CL is a superset.

Prof Fateman CS 164 Lecture 376 Important: how did the pieces fit together? You must know the form of the input for each module You must know the form of the output for each module We didn’t ask you to write an interpreter, but we could have… What was the point of the interpreter? –Defined the language –Allowed us to TEST TIGER PROGRAMS –Could be used to resolve disputes, ambiguities

Prof Fateman CS 164 Lecture 377 Recall: How are Languages Implemented? Two major strategies: –Interpreters (simple, general, faster setup) –Compilers (complex, popular, faster runtime) Interpreters run programs with only modest processing; often easily portable to many hosts. Compilers do extensive preprocessing, some of it to target specific machine architectures.

Prof Fateman CS 164 Lecture 378 Interpreters and Compilers Both: Read in “source code” Construct some model of the program Provide error messages Adhere to some “execution model” of the programming language.

Prof Fateman CS 164 Lecture 379 Language Implementations Batch compilation systems dominate many production environments; Optimizes for fast runtime. Some languages are primarily interpreted –Java bytecode Lisp provides both –Interpreter for fast development/debugging –Typechecking compiler for faster running

Prof Fateman CS 164 Lecture 3710 The Structure of a Typical Compiler 1.Lexical Analysis 2.Parsing 3.Semantic Analysis 4.Optimization 5.Code Generation

Prof Fateman CS 164 Lecture 3711 Lexical Analysis (The “lexer” or “scanner”) First step: recognize words. –Smallest unit above letters –Some relation to finite state machines and regular expressions. (We could still ask questions about these on the final) let type tt={foo:int,bar:int} var xx:tt:=nil in 3 end (let let (1. 3)) (type type (1. 8)) (id tt (1. 11)) (= = (1. 12)) ({ { (1. 13)) (id foo (1. 16)) (|:| |:| (1. 17)) (id int (1. 20)) (|,| |,| (1. 21)) (id bar (1. 24)) (|:| |:| (1. 25)) (id int (1. 28)) (} } (1. 29)) …

Prof Fateman CS 164 Lecture 3712 Parsing Once words are understood, the next step is to understand sentence structure as we saw in CS61a Parsing = producing AST. –3 ways Recursive descent, seat of the pants programming LL (also top down parsing), more systematic LR (bottom up) especially LALR

Prof Fateman CS 164 Lecture 3713 Typechecking = Static Semantic Analysis Scramble over the tree –Build up a symbol table Structured in lexical levels Observe all the details Maybe make some changes. E.g. X.foo  x[1]

Prof Fateman CS 164 Lecture 3714 Interpretation = Dynamic (Runtime) Analysis Scramble over the tree –Execute it

Prof Fateman CS 164 Lecture 3715 OR…Compiling = code generation Scramble over the tree –Expand pieces of the AST into straight line sequences of Assembly code

Prof Fateman CS 164 Lecture 3716 then… Assemble the generated code Run the “binary” code on a computer –Simulated computer –Actual computer (think of it as a hardware simulation of the “architecture” which is, after all, a formal system.)

Prof Fateman CS 164 Lecture 3717 then… Celebrate if your code worked.

Prof Fateman CS 164 Lecture 3718 What else? Other ways of thinking about Programming Languages (We did not do…) prolog The Lambda calculus Macro expansion Object-orientation

Prof Fateman CS 164 Lecture 3719 Is there more to this subject? –Lots more. And its not just about programming, but about user interfaces, theorem proving, mathematics, (also politics, standards, economics). –At least 3 graduate courses here (more like 5 or 6 if you count “closely related”) –Many books (not counting “Java for dummies” etc.) –Magazines and Journals –Just a few web pages

Prof Fateman CS 164 Lecture 3720

Prof Fateman CS 164 Lecture 3721 Time for questions?

Prof Fateman CS 164 Lecture 3722 I hope you found this course challenging & fun. –Good luck on all your finals –Have a good vacation

Prof Fateman CS 164 Lecture 3723

Prof Fateman CS 164 Lecture 3724