Cs7100 (Prasad)L2SpecIntro1 Motivation for Language Specification.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

CS 150 lecture 2. Review Reasons for studying programming languages Language evaluation criteria –Readability Simplicity? Orthogonality? –Writability.
Semantics Static semantics Dynamic semantics attribute grammars
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.
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
ISBN Chapter 3 Describing Syntax and Semantics.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
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.
Object-Oriented Programming OOP John Gilligan School of Computing DIT Kevin St.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
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:
Reasons to study concepts of PL
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.
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
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
School of Computer ScienceG53FSP Formal Specification1 Dr. Rong Qu Introduction to Formal Specification
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Introduction (Chapter 1)
Presented by: Destry Diefenbach
PROGRAMMING LANGUAGES The Study of Programming Languages.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
Syntax & Semantic Introduction Organization of Language Description Abstract Syntax Formal Syntax The Way of Writing Grammars Formal Semantic.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
 The design of the imperative languages is based directly on the von Neumann architecture  Efficiency is the primary concern  Low-level specifications:
Principles of Programming Languages Asst. Prof. Dr. Ahmet Sayar Spring-2012 Kocaeli University Computer Engineering Department Introduction.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Semantics. Semantics is a precise definition of the meaning of a syntactically and type-wise correct program. Ideas of meaning: –Operational Semantics.
Ch. 5 Ch. 51 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (more notes) Dr. Carter Tiernan.
ProgrammingLanguages Programming Languages Language Definition, Translation and Design.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
ISBN Chapter 3 Describing Semantics.
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.
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.
Chapter 3 - Language Design Principles
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
Semantics (1).
Ch. 5 Ch. 51 jcmt Summer 2003Programming Languages CSE3302 Programming Languages (more notes) Summer 2003 Dr. Carter Tiernan.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
Programming Language Descriptions. What drives PL Development? Computers are “in charge” of extremely important issues Execute a program literally. Exercise.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
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.
Advanced programming language theory. week 2. Attribute grammars and semantics.
Describing Syntax and Semantics
Programming Languages 2nd edition Tucker and Noonan
Ada – 1983 History’s largest design effort
Generic Language Technology (2IS15) Dynamic Semantics
Semantics In Text: Chapter 3.
Chapter 3 Describing Syntax and Semantics.
Motivation for Language Specification
Midterm Review In Text: Chapters 1-3, 5-11, 15.
Motivation for Language Specification
Presentation transcript:

cs7100 (Prasad)L2SpecIntro1 Motivation for Language Specification

cs7100 (Prasad)L2SpecIntro2 Languages Natural LanguagesArtificial Languages Logic LanguagesProgramming Languages (descriptive) (prescriptive) Aspects SyntaxSemanticsPragmatics

cs7100 (Prasad)L2SpecIntro3 Motivation for Specifying Natural Languages A lexicographer's business is solely to collect, arrange, and define the words that usage presents to his hands. He has no right to proscribe words; he is to present them as they are. -Noah Webster, lexicographer ( )

cs7100 (Prasad)L2SpecIntro4 Motivation for Specifying Semantics of Programming Languages The language of mathematics is precise, well-understood, and standard. In contrast, the PL notations are diverse and similar looking syntax have been given different meaning. So it is important to specify unambiguously what a system of notation stands for.

cs7100 (Prasad)L2SpecIntro5 Semantics seeks profound definitions rather than difficult theorems. Software Design – Use Divide and Conquer. Team effort common. Language Design –Unify and study interactions among language features. Individual effort common. »Pascal, Modula-2, Oberon - Niklaus Wirth »C - Dennis Ritchie, C++ - Bjarne Stroustrup »Java - James Gosling, C# - Anders Hejlsberg »Scheme – Guy Steele, Python – Guido von Rossum »Scala – Martin Oderksy, Clojure– Rich Hickey

cs7100 (Prasad)L2SpecIntro6 Problems with Informal Specifications Some Historically Significant Examples of Ambiguity/Incompleteness

cs7100 (Prasad)L2SpecIntro7 Algol Example Algol-60 report is ambiguous since it does not specify a fixed-order of evaluation for sub-expressions, or rule out the possibility of side-effects in programs.  If function f has side-effect on variable x then it is possible to have x + f(x) =/= x + f(x) f(x) + f(x) =/= 2 * f(x) f(x) / f(x) =/= 1 Loss of Referential Transparency

cs7100 (Prasad)L2SpecIntro8 Pascal Example Type Equivalence type T = array [1..10] of integer; var A,B : array [1..10] of integer; C: array [1..10] of integer; D: T ; E : T; Structural Equivalence: {A,B,C,D,E} Name Chain Equivalence: {A,B},{C},{D,E} Name Equivalence: {A},{B},{C},{D,E}

cs7100 (Prasad)L2SpecIntro9 Semantic Equivalence Example Are the following statement templates equivalent? while do vs 25: if then begin ; goto 25 end;

cs7100 (Prasad)L2SpecIntro10 #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--); }

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

Cause of ‘The 1990 AT&T Long Distance Network Collapse’ The defect was a C program that featured a break statement located within an if-then- else statement, that was nested within a switch statement. Instead of the control breaking out of the else clause, it also broke out of the surrounding switch. cs7100 (Prasad)L2SpecIntro12

cs7100 (Prasad)L2SpecIntro13 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

cs7100 (Prasad)L2SpecIntro14 Interpreter vs Compiler Interpreter evaluates the meaning of a program. Compiler transforms a program in one language into an equivalent program in another language. That is, it preserves meaning. Semantics of a language is independent of its machine implementation.

cs7100 (Prasad)L2SpecIntro15 Why is formal semantics not widely used? It is relatively complex and 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). However, most programmers want to know: –What is the output for the particular inputs?

cs7100 (Prasad)L2SpecIntro16 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.

cs7100 (Prasad)L2SpecIntro17 Language Syntax(BNF) Semantics Pragmatics Data Control Abstract Data Types Denotational Axiomatic Operational (interpreter-based) Attribute Grammar Framework CS7100 Agenda