Programming Languages and Compilers (CS 421)

Slides:



Advertisements
Similar presentations
Semantics Static semantics Dynamic semantics attribute grammars
Advertisements

ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CS 330 Programming Languages 09 / 19 / 2006 Instructor: Michael Eckmann.
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
Chair of Software Engineering Fundamentals of Program Analysis Dr. Manuel Oriol.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
Environments and Evaluation
Slide 1 Chapter 3 Attribute Grammars. Slide 2 Attribute Grammars Certain language structures cannot be described using EBNF. Attribute grammars are extensions.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Programming Languages and Compilers (CS 421)
CS 540 Spring CS 540 Spring 2013 GMU2 The Course covers: Lexical Analysis Syntax Analysis Semantic Analysis Runtime environments Code Generation.
Data Flow Analysis Compiler Baojian Hua
9/18/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
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.
10/7/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
10/14/20151 Programming Languages and Compilers (CS 421) Grigore Rosu 2110 SC, UIUC Slides by Elsa Gunter, based.
10/25/20151 Programming Languages and Compilers (CS 421) Grigore Rosu 2110 SC, UIUC Slides by Elsa Gunter, based.
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
Parse & Syntax Trees Syntax & Semantic Errors Mini-Lecture.
1 Chapter 1 Introduction. 2 Outlines 1.1 Overview and History 1.2 What Do Compilers Do? 1.3 The Structure of a Compiler 1.4 The Syntax and Semantics of.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Semantics In Text: Chapter 3.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
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.
The Model of Compilation Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
10/16/081 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
2/1/20161 Programming Languages and Compilers (CS 421) Grigore Rosu 2110 SC, UIUC Slides by Elsa Gunter, based in.
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
CMSC 330: Organization of Programming Languages Operational Semantics.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
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.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Software Engineering Algorithms, Compilers, & Lifecycle.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
Compiler Design (40-414) Main Text Book:
Basic Program Analysis
Programming Languages and Compilers (CS 421)
Data Flow Analysis Suman Jana
Chapter 1 Introduction.
Overview of Compilation The Compiler Front End
Overview of Compilation The Compiler Front End
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Overview of Compilation The Compiler BACK End
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Programming Languages and Compilers (CS 421)
Compiler Lecture 1 CS510.
Intermediate Representations Hal Perkins Autumn 2011
University Of Virginia
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Overview of Compilation The Compiler BACK End
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Madhusudan Parthasarathy
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Presentation transcript:

Programming Languages and Compilers (CS 421) William Mansky http://courses.engr.illinois.edu/cs421/ Based in part on slides by Mattox Beckman, as updated by Vikram Adve, Gul Agha, Elsa Gunter, and Dennis Griffith 5/11/2018

The Big Picture OCaml/Functional Programming Continuation Passing Style Type checking/inference Unification Lexing Parsing Operational Semantics Lambda Calculus Hoare Logic 5/11/2018

Anatomy of an Interpreter Program Text Lexing regular expressions/lex Token Buffer Parsing BNF grammar/yacc AST Static Semantics type checking/inference, unification possibly Hoare Logic! Correct AST Dynamic Semantics operational semantics Program Output 5/11/2018

regular expressions/lex Anatomy of a Compiler Program Text Lexing regular expressions/lex Token Buffer Parsing BNF grammar/yacc AST Static Semantics type checking/inference, unification possibly Hoare Logic! Correct AST Translation denotational semantics possibly CPS! } IR Optimization CS 426 Optimized IR Code Generation (denotational semantics again) 5/11/2018 Assembly/Machine Code (or lambda calculus!)

What can we do now? Write functional programs (which parallelize well and compute math quickly) Build compilers and interpreters Specify and implement programming languages Prove programs correct Compare various approaches to PL syntax and semantics 5/11/2018

Formal Methods The study of proving programs correct But what is a program? Anything we can model formally/mathematically Computer programs, machines, workflows Compilers, air traffic control protocols, security protocols, simulators, Java programs And how do we prove it correct? Syntax, semantics, formal logic, automatic/interactive provers 5/11/2018

Verifying a Compiler “do the same thing” Program Text Lexing Token Buffer Parsing AST “do the same thing” Static Semantics Correct AST Translation IR Optimization Optimized IR Code Generation 5/11/2018 Assembly/Machine Code

Verifying a Compiler have the same semantics? Program Text Lexing Token Buffer Parsing AST have the same semantics? Static Semantics Correct AST Translation IR Optimization Optimized IR Code Generation 5/11/2018 Assembly/Machine Code

Verifying a Compiler have the same semantics Program Text Lexing Token Buffer Parsing AST Static Semantics Correct AST have the same semantics Translation IR Optimization Optimized IR Code Generation 5/11/2018 Assembly/Machine Code

Verifying a Compiler prove this! Semantics Input AST Input Meaning Translation Semantics Output AST Output Meaning 5/11/2018

Verifying a Compiler – Example PicoML SOS PicoML AST PicoML Value prove this! Denotation LC SOS Lambda-term LC Value 5/11/2018

Verifying a Compiler – Example PicoML SOS PicoML AST PicoML Value prove this! Denotation LC SOS Lambda-term LC Value Can we prove this for every program? 5/11/2018

Verifying a Compiler – Example PicoML SOS PicoML AST PicoML Value prove this! Denotation LC SOS Lambda-term LC Value Can we prove this for every program? Yes. 5/11/2018

Verifying a Compiler – Harder Case Semantics Compiler IR Input Meaning prove this! Optimization Semantics Compiler IR Output Meaning Can we prove this for every program? 5/11/2018

Control Flow Graphs ASTs are good for complex expressions What if we care more about control flow than expression structure? Graphs with commands on nodes, edges showing control flow 5/11/2018

Control Flow Graphs 0: x := 1 Entry 1: if x > 0 goto 4 2: x := x + 1 3: goto 5 4: x := x - 1 5: y := x 6: return y Entry seq x := 1 seq if x > 0 seq branch x := x + 1 x := x - 1 seq goto seq branch y := x seq return y seq Exit

Semantics on Control Flow Graphs Configurations are (G, n, m), where G is a graph and n is the currently executing node Small-step for moving between nodes, big-step within a single node E.g. (Assignment Rule): label(G, n) = I := E (E, m) v out(n) = n' (G, n, m)  (G, n', m[x  v]) 5/11/2018

Verifying a Compiler – Harder Case CFG Semantics Input CFG Input Value prove this! Optimization CFG Semantics Output CFG Output Value 5/11/2018

Questions? 5/11/2018