Programming Languages and Compilers



Similar documents
Compiler and Language Processing Tools

CSCI 3136 Principles of Programming Languages

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

Outline. Compiler and Language Processing Tools. Language processing tools (2) Language processing tools. Language processing tools (3)

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

Fundamentals of Programming Languages

Semester Review. CSC 301, Fall 2015

Assembly Language: Function Calls" Jennifer Rexford!

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

CSE 307: Principles of Programming Languages

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

Image credits:

1/20/2016 INTRODUCTION

Programming Languages CIS 443

Programming Languages

Compiler Construction

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Object-Oriented Software Specification in Programming Language Design and Implementation

CA Compiler Construction

Chapter 7D The Java Virtual Machine

University of Twente. A simulation of the Java Virtual Machine using graph grammars

Compiler Construction

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Language Processing Systems

Textual Modeling Languages

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

02 B The Java Virtual Machine

Briki: a Flexible Java Compiler

Semantic Analysis: Types and Type Checking

Machine-Level Programming II: Arithmetic & Control

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Special Topics in Computer Science

Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006

CSE 130 Programming Language Principles & Paradigms

Habanero Extreme Scale Software Research Project

Chapter 1 Java Program Design and Development

picojava TM : A Hardware Implementation of the Java Virtual Machine

Machine Programming II: Instruc8ons

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

School of Computer Science

Chapter 15 Functional Programming Languages

Division of Mathematical Sciences

Introduction to programming

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

Lab Experience 17. Programming Language Translation

Data Structures Lecture 1

II. PREVIOUS RELATED WORK

The C Programming Language course syllabus associate level

Instruction Set Architecture

1.1 WHAT IS A PROGRAMMING LANGUAGE?

Intel Assembler. Project administration. Non-standard project. Project administration: Repository

Functions. MATH 160, Precalculus. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Functions

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Course Goal CMSC 330: Organization of Programming Languages. Studying Programming Languages. All Languages Are (Kind of) Equivalent.

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Chapter 5 Names, Bindings, Type Checking, and Scopes

COS 333: Advanced Programming Techniques

Programming Languages

Under the Hood: The Java Virtual Machine. Lecture 24 CS 2110 Fall 2011

Automated Termination Proofs for Java Programs with Cyclic Data

Programming Languages

Programmierpraktikum

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

COS 301 Programming Languages

Implementing Programming Languages. Aarne Ranta

Chapter 1 Programming Languages for Web Applications

What is a programming language?

Sources: On the Web: Slides will be available on:

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Programming the Android Platform. Logistics

Programming Language Pragmatics

The programming language C. sws1 1

Pretty-big-step semantics

Computer Science. 232 Computer Science. Degrees and Certificates Awarded. A.S. Degree Requirements. Program Student Outcomes. Department Offices

Lecture 27 C and Assembly

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

1 The Java Virtual Machine

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

McGraw-Hill The McGraw-Hill Companies, Inc.,

03 - Lexical Analysis

COURSE CODE: CSC 411 Organization of Programming Languages

Chapter 4 Processor Architecture

Java Crash Course Part I

CS61: Systems Programing and Machine Organization

Programming Languages & Tools

Built-in Concurrency Primitives in Java Programming Language. by Yourii Martiak and Mahir Atmis

HVM TP : A Time Predictable and Portable Java Virtual Machine for Hard Real-Time Embedded Systems JTRES 2014

CS 301 Course Information

Scanning and parsing. Topics. Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm

Introduction to Automata Theory. Reading: Chapter 1

Transcription:

PLaC-0.1 Programming Languages and Compilers Prof. Dr. Uwe Kastens WS 2013 / 2014 2013 bei Prof. Dr. Uwe Kastens

0. Introduction PLaC-0.2 The participants are taught to Objectives understand properties and notions of programming languages understand fundamental techniques of language implementation, and to use generating tools and standard solutions, apply compiler techniques for design and implementation of specification languages and domain specific languages Lectures Forms of teaching: 2008 bei Prof. Dr. Uwe Kastens Tutorials Homeworks Exercises Running project

Contents PLaC-0.3 Week Chapter 1 0. Introduction 2 1. Language Properties and Compiler tasks 3-4 2. Symbol Specification and Lexical Analysis 5-7 3. Context-free Grammars and Syntactic Analysis 8-10 4. Attribute Grammars and Semantic Analysis 11 5. Binding of Names 12 6. Type Specification and Analysis 13 7. Specification of Dynamic Semantics 13 8. Source-to-Source Translation 2013 bei Prof. Dr. Uwe Kastens 9. Domain Specific Languages Summary

Prerequisites PLaC-0.4 from Lecture Topic here needed for Foundations of Programming Languages: 4 levels of language properties Language specification, compiler tasks Context-free grammars Scope rules Data types Grammar design, syntactic analysis Name analysis Type specification and analysis Modeling: Finite automata Context-free grammars Lexical analysis Grammar design, syntactic analysis

References PLaC-0.5 Material for this course PLaC: http://ag-kastens.upb.de/lehre/material/plac for the Master course Compilation Methods: http://ag-kastens.upb.de/lehre/material/compii Modellierung: Grundlagen der Programmiersprachen: http://ag-kastens.upb.de/lehre/material/model http://ag-kastens.upb.de/lehre/material/gdp John C. Mitchell: Concepts in Programming Languages, Cambridge University Press, 2003 R. W. Sebesta: Concepts of Programming Languages, 4. Ed., Addison-Wesley, 1999 U. Kastens: Übersetzerbau, Handbuch der Informatik 3.3, Oldenbourg, 1990 (not available on the market anymore, available in the library of the University) A. W. Appel: Modern Compiler Implementation in Java, Cambridge University Press, 2nd Edition, 2002 (available for C and for ML, too) 2007 bei Prof. Dr. Uwe Kastens W. M. Waite, L. R. Carter: An Introduction to Compiler Construction, Harper Collins, New York, 1993 U. Kastens, A. M. Sloane, W. M. Waite: Generating Software from Specifications, Jones and Bartlett Publishers, 2007

References forreading PLaC-0.5a Week Chapter Kastens Waite Eli Carter Doc. 1 0. Introduction 2 1. Language Properties 1, 2 1.1-2.1 and Compiler tasks 3-4 2. Symbol Specification 3 2.4 + and Lexical Analysis 3.1-3.3 5-7 3. Context-free Grammars 4 4, 5, 6 + and Syntactic Analysis 8-10 4. Attribute Grammars 5 + and Semantic Analysis 11 5. Binding of Names 6.2 7 + 2013 bei Prof. Dr. Uwe Kastens 12 6. Type Specification and Analysis (6.1) + 13 7. Specification of Dynamic Semantics 13 8. Source-to-Source Translation 9. Domain Specific Languages

Course material in the Web PLaC-0.6 2013 bei Prof. Dr. Uwe Kastens

Commented slide in the course material PLaC-0.7 2013 bei Prof. Dr. Uwe Kastens

Organization of the course PLaC-0.8 2013 bei Prof. Dr. Uwe Kastens

What does a compiler compile? PLaC-0.9 A compiler transforms correct sentences of its source language into sentences of its target language such that their meaning is unchanged. Examples: Source language: Programming language C++ Programming language Java Programming language C++ Domain specific language LaTeX Data base language (SQL) Target language: Machine language Sparc code Abstract machine Java Bytecode Programming language (source-to-source) C Application language HTML Data base system calls 2003 bei Prof. Dr. Uwe Kastens Application generator: Domain specific language SIM Toolkit language Programming language Java Some languages are interpreted rather than compiled: Lisp, Prolog, Script languages like PHP, JavaScript, Perl

2003 bei Prof. Dr. Uwe Kastens class Average { private: int sum, count; public: Average (void) { sum = 0; count = 0; } void Enter (int val) { sum = sum + val; count++; } float GetAverage (void) { return sum / count; } }; -------------- _Enter 7Averagei: pushl %ebp movl %esp,%ebp movl 8(%ebp),%edx movl 12(%ebp),%eax addl %eax,(%edx) incl 4(%edx) L6: movl %ebp,%esp popl %ebp ret What is compiled here? PLaC-0.10 class Average { private int sum, count; public Average () { sum = 0; count = 0; } void Enter (int val) { sum = sum + val; count++; } float GetAverage () { return sum / count; } }; --------------- 1: Enter: (int) --> void Access: [] Attribute 'Code' (Length 49) Code: 21 Bytes Stackdepth: 3 Locals: 2 0: aload_0 1: aload_0 2: getfield cp4 5: iload_1 6: iadd 7: putfield cp4 10: aload_0 11: dup 12: getfield cp3 15: iconst_1 16: iadd

What is compiled here? PLaC-0.11 2003 bei Prof. Dr. Uwe Kastens program Average; var sum, count: integer; aver: integer; procedure Enter (val: integer); begin sum := sum + val; count := count + 1; end; begin sum := 0; count := 0; Enter (5); Enter (7); aver := sum div count; end. ----------- void ENTER_5 (char *slnk, int VAL_4) { {/* data definitions: */ /* executable code: */ { SUM_1 = (SUM_1)+(VAL_4); COUNT_2 = (COUNT_2)+(1); ; } }}/* ENTER_5 */ \documentstyle[12pt]{article} \begin{document} \section{introduction} This is a very short document. It just shows \begin{itemize} \item an item, and \item another item. \end{itemize} \end{document} ------------- %%Page: 1 1 1 0 bop 164 315 a Fc(1)81 b(in)n(tro)r(duction) 164 425 y Fb(This)16 b(is)g(a)h(v)o(ery)e(short) i(do)q(cumen)o(t.)j(it)c(just)g (sho)o(ws)237 527 y Fa(\017)24 b Fb(an)17 b(item,) c(and)237 628 y Fa(\017)24 b Fb(another)17 b(item.) 961 2607 y(1)p eop

Languages for specification and modeling PLaC-0.12 SDL (CCITT) Specification and Description Language: UML Unified Modeling Language: 2003 bei Prof. Dr. Uwe Kastens

Domain Specific Languages (DSL) PLaC-0.13 A language designed for a specific application domain. Application Generator: Implementation of a DSL by a program generator Examples: Simulation of mechatronic feedback systems Robot control Collecting data from instruments Testing car instruments Game description language: game BBall { size 640 480; background "pics/backgroundbb.png"; Ball einball; int ballsize; 2006 bei Prof. Dr. Uwe Kastens initial { ballsize=36; } events { pressed SPACE: { einball = new Ball(<100,540>, <100,380>);

PLaC-0.14 Programming languages as source or target languages Programming languages as source languages: Program analysis call graphs, control-flow graph, data dependencies, e. g. for the year 2000 problem Recognition of structures and patterns e. g. for Reengineering Programming languages as target languages: Specifications (SDL, OMT, UML) graphic modeling of structures DSL, Application generator 2005 bei Prof. Dr. Uwe Kastens => Compiler task: Source-to-source compilation

Semester project as running example PLaC-0.15 SetLan: A Language for Set Computation SetLan is a domain-specific language for programming with sets. Constructs of the the language are dedicated to describe sets and computations using sets. The language allows to define types for sets and variables and expressions of those types. Specific loop constructs allow to iterate through sets. These constructs are embedded in a simple imperative language. A source-to-source translator translates SetLan programs into Java programs. 2012 bei Prof. Dr. Uwe Kastens The SetLan translator is implemented using the methods and tools introduced in this course. The participants of this course get an implementation of a sub-language of SetLan as a starting point for their work towards their individual extension of the language and the implementation. { } set a, b; int i; i = 1; a = [i, 3, 5]; b = [3, 6, 8]; print a+b; println; print a*b <= b; println;