Programming Language Descriptions. What drives PL Development? Computers are “in charge” of extremely important issues Execute a program literally. Exercise.

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

Semantics Static semantics Dynamic semantics attribute grammars
ANTLR in SSP Xingzhong Xu Hong Man Aug Outline ANTLR Abstract Syntax Tree Code Equivalence (Code Re-hosting) Future Work.
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
Names and Bindings.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
ISBN Chapter 3 Describing Syntax and Semantics.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CS 355 – Programming Languages
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics Fall 2005.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Operational Semantics.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Chapter 3 Describing Syntax and Semantics Sections 1-3.
C SC 520 Principles of Programming Languages 1 C SC 520: Principles of Programming Languages Peter J. Downey Department of Computer Science Spring 2006.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Denotational Semantics ICS.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Language Evaluation Criteria
Syntax & Semantic Introduction Organization of Language Description Abstract Syntax Formal Syntax The Way of Writing Grammars Formal Semantic.
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.
CSC 338: Compiler design and implementation
CS 331, Principles of Programming Languages Chapter 2.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
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.
CPS 506 Comparative Programming Languages Syntax Specification.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
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,
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
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.
CS 331, Principles of Programming Languages Chapter 2.
Semantics (1).
Cs7100 (Prasad)L2SpecIntro1 Motivation for Language Specification.
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Denotational Semantics.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Programming Languages Meeting 3 September 9/10, 2014.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Dr. M. Al-Mulhem Denotational Semantics 1 Chapter 4 Fundamentals (Denotational Semantics)
Semantics(1). 2 Symantec(1)  To provide an authoritative definition of the meaning of all language constructs for: 1.Programmers 2.Compiler writers 3.Standards.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
Describing Syntax and Semantics
Advanced Computer Systems
Chapter 1 Introduction.
Chapter 1 Introduction.
Compiler Lecture 1 CS510.
CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics
Generic Language Technology (2IS15) Dynamic Semantics
Semantics In Text: Chapter 3.
Motivation for Language Specification
Motivation for Language Specification
Presentation transcript:

Programming Language Descriptions

What drives PL Development? Computers are “in charge” of extremely important issues Execute a program literally. Exercise no “judgment”. Program development “works” : not too hard “works correctly”: beyond the state of the art Errors are due to inadequate command over the programming domain programming language A PL design should Make programs efficient Make programmers more productive Help catch typical errors High level operations PL easy to understand cs7842PL-Descriptions

Division of PL Descriptions Syntax –Context Free Grammars –Context Sensitive Details Semantics –PL designer typically uses prose. –Others would have developed Operational Semantics Axiomatic Semantics Denotational Pragmatics –Various practical details –Prose cs7843PL-Descriptions

Description of Syntax: BNF Backus-Naur-Form –Context-Free only –LHS ::= seq of Terminals/Non-Terminals –::= separates LHS from RHS –Repetition/Kleene Star { … }* Many variations of BNF cs7844PL-Descriptions

Description of Semantics What does a program “mean”? Mostly via carefully written prose. Semantics of a language is (ought to be) independent of its machine implementation. Subtleties abound cs7845PL-Descriptions

Side Effects If function f has side-effect on variable x then it is possible to have x + f(x) =/= f(x) + x f(x) + f(x) =/= 2 * f(x) f(x) / f(x) =/= 1, even assuming f(x) != 0 Loss of Referential Transparency cs7846PL-Descriptions

Subtle variations in semantics Are the following equivalent? (Ignore PL specific syntactic details.) while B do S S stands for a statement sequence 25: if B then begin S; goto 25 end Equivalent in Pascal, Ada, etc., but not in C/C++/Java. cs7847PL-Descriptions

Scope of break statement #include main() { int i, j, k1 = 2, k2 = 2; do { i = 2; while ( i > 0 ) { printf("\t i = %d \n", i--); } } while (k1--); printf("\n"); do { j = 2; TAG: if ( j > 0 ) { printf("\t j = %d \n", j--); goto TAG; } } while (k2--); } cs7848PL-Descriptions

Type Equivalence type T = array [1..10] of integer; var A,B : array [1..10] of integer; C: array [1..10] of integer; D, E: T; Structural Equivalence: {A,B,C,D,E} Name Chain Equivalence: {A,B},{C},{D,E} Name Equivalence: {A},{B},{C},{D,E} cs7849PL-Descriptions

Interpreter vs Compiler Interpreter evaluates the representation of a program. Compiler transforms a program representation in one language into an “equivalent” program in another language. cs78410PL-Descriptions

cs784 (Prasad)L2SpecIntro11 Why is formal semantics not widely used? Real PLs are too complex. Not (yet) cost effective for everyday (and everybody’s) use. Semantics is general. In particular, it must consider all possible situations (including the boundary cases). But steady progress is being made... cs78411PL-Descriptions

Approaches to Formal Semantics Operational : How a program executes? Specifies abstract interpreter to carry-out the meaning of the programs. Denotational : What a program computes? Maps a program to a mathematical function from its inputs to its outputs. Axiomatic : For reasoning about programs Specifies properties of language constructs through pre-post conditions. Abstraction level: OS < DS < AS cs78412PL-Descriptions

cs784 (Prasad)L2SpecIntro13 Who needs semantics? Those who write (meta-)programs that must work for all programs. Designers of –program transformation tools. –compilers and interpreters. –program analyzers. –software engineering tools. –critical software. cs78413PL-Descriptions

Language Syntax(BNF) Semantics Pragmatics Data Control Abstract Data Types Denotational Axiomatic Operational (interpreter-based) Attribute Grammar Framework CS784 Agenda cs78414PL-Descriptions