Chapter 4: Language Semantics The need for language semantics: a. for the programmer - to know how to use language constructs b. for the implementor -

Slides:



Advertisements
Similar presentations
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.
Advertisements

CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
CS 330 Programming Languages 09 / 19 / 2006 Instructor: Michael Eckmann.
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.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Software Testing and Quality Assurance
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 12: Semantic Analysis COMP 144 Programming Language Concepts Spring 2002 Felix.
PZ03CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03CX - Language semantics Programming Language Design.
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.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
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.
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.
1 Lecture 11: Semantic Analysis (Section ) CSCI 431 Programming Languages Fall 2002 A modification of slides developed by Felix Hernandez-Campos.
©Ian Sommerville 2000Software Engineering, Chapter 10 Slide 1 Chapter 10 Formal Specification.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
CS 331, Principles of Programming Languages Chapter 2.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
TextBook Concepts of Programming Languages, Robert W. Sebesta, (10th edition), Addison-Wesley Publishing Company CSCI18 - Concepts of Programming languages.
CS 363 Comparative Programming Languages Semantics.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
Sullivan Algebra & Trigonometry: Section 3.1 Functions Objectives Determine Whether a Relation Represents a Function Find the Value of a Function Find.
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.
ISBN Chapter 3 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,
Logical and Functional Programming
ISBN Chapter 3 Describing Syntax and Semantics.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
CS 331, Principles of Programming Languages Chapter 2.
Describing Syntax and Semantics Session 2 Course : T Programming Language Concept Year : February 2011.
Chapter 1: Variables in Algebra
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
©Ian Sommerville 2000Software Engineering, Chapter 10 Slide 1 Chapter 10 Formal Specification.
CMSC 330: Organization of Programming Languages Operational Semantics.
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.
Dr. M. Al-Mulhem Denotational Semantics 1 Chapter 4 Fundamentals (Denotational Semantics)
PZ03CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03CX - Language semantics Programming Language Design.
Functional Programming
Describing Syntax and Semantics
Algebra 1 Section 1.7 Identify functions and their parts
Syntax Questions 6. Define a left recursive grammar rule.
Midterm Review In Text: Chapters 1, 2, 3, 5, 15.
Midterm Review In Text: Chapters 1, 2, 3, 11, 14, 15.
Midterm Review In Text: Chapters 1-3, 5, 15.
Midterm Review In Text: Chapters 1-3, 5-7, 15, 16.
Midterm Review In Text: Chapters 1, 2, 3, 5, 6, 15.
Midterm Review In Text: Chapters 1, 2, 3, 5, 15.
Midterm Review In Text: Chapters 1-3, 5-6, 15.
CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics
Denotational Semantics (Denotational Semantics)
Semantics In Text: Chapter 3.
All other materials should be on the floor or in a desk.
Chapter 3 Describing Syntax and Semantics.
Describing Syntax and Semantics
Language semantics Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE S. Tanimoto Lambda Calculus
Motivation for Language Specification
CH 4 - Language semantics
Presentation transcript:

Chapter 4: Language Semantics The need for language semantics: a. for the programmer - to know how to use language constructs b. for the implementor - to know how to implement the language

Semantics Semantics: the study or analysis of the relationships between linguistic symbols and their meanings

Semantic descriptions Informal descriptions of language semantics - provided in verbal form in the language manuals. May be ambiguous. Formal description: studied theoretically, no satisfactory models have been produced so far.

Formal semantic models Grammatical models Operational (imperative) models Axiomatic models Applicative (functional) models Specification models

Grammatical models  grammar rules are paired with semantic rules. Resulting grammars are called attribute grammars RuleAttribute E  E + Tvalue (E1) = value (E2) + value(T) E  Tvalue (E) = value (T) T  T * Pvalue (T1) = value (T2) * value (P) T  Pvalue (T) = value (P) P  Ivalue (P) = value of number I P  (E)value (P) = value (E)

Operational models Describe the meaning of the language constructs in terms of machine states, i.e. memory and register contents. Operational semantics – describes what has to be done.

Applicative models Treat programs as functions. Denotational semantics (functional semantics) Lambda calculus

Denotational semantics Specifies the meaning of expressions by their denotation The domain of interpretation defines the denotation of composite expressions in terms of the denotations of their components. -> Compositional semantics

Lambda calculus Formal mathematical system devised by Alonzo Church to investigate functions, function application and recursion

Example illustrating lambda calculus A function accepts input and produces an output. Suppose we have a "chocolate-covering" function that produces the following outputs for the corresponding inputs: INPUTOUTPUT peanuts->chocolate-covered peanuts raisins->chocolate-covered raisins ants->chocolate-covered ants

Lambda functions We can use Lambda-calculus to describe such a function: Lx. chocolate - covered x If we want to apply the function to an argument, we use the following syntax: (Lx.chocolate-covered x)peanuts -> chocolate-covered peanuts

Using Lambda expressions to get new functions Functions can also be the result of applying a lambda-expression Ly.Lx. y - covered x We can use this to create a caramel-covering function: (Ly.Lx.y-covered x) caramel -> Lx. caramel-covered x

Functions as inputs Functions can also be the inputs to other functions, as with this "apply-to-ants" function: Lf.(f) ants We can feed the chocolate-covering function to the "apply-to-ants" function: (Lf.(f)ants)Lx.chocolate-covered x -> (Lx.chocolate-covered x)ants -> chocolate-covered ants

Axiomatic models Describe the meaning as pre- conditions and post-conditions Used in program verifications

Specification models Describe the relationship among various functions that implement a program. Example of a specification model: Algebraic data types - describe the meaning in terms of algebraic operations, e.g. pop(push(S,x)) = S