Presentation is loading. Please wait.

Presentation is loading. Please wait.

Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.

Similar presentations


Presentation on theme: "Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical."— Presentation transcript:

1 Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical Sciences Web Site: http://scom.hud.ac.uk/scomtlm/cas2545

2 Aims To give you a DEEP understanding of the meaning and structure of (programming) languages.. So that in the future when you encounter a new one you can analyse and classify it - and hence easily pick it up

3 Content This Module will concentrate on PROGRAM LANGUAGE SEMANTICS - specifically DENOTATIONAL SEMANTICS.

4 Last Term’s Work: - Functional PL: Haskell/Gofer - Lambda Calculus - Reductions, Normal forms, Fixed Points, Church - Rosser Theorem.. - Functional PL + Lambda Calculus relationship - Operational Semantics of Functional PL, type checking + type inference - Implementation of FPL’s

5 This Term’s Work: -- Denotational Semantics of basic Imperative PL Control Structures (using Lambda Calculus) -- Prototyping the Denotational Semantics using Haskell -- Algebraic Semantics of Data Types (Objects)

6 Kinds of (Programming) Languages GENERAL PLs e.g. C,Java,Haskell, Pascal, Ada, Prolog.. fall into 3 groups depending on their underlying model of computation: Procedural (state change) Functional (function evaluation) Logic (logical inference) SPECIALIST PLs e.g. Maths, Web, Multimedia, Database, Op Sys

7 SYNTAX..is all about the set of symbols allowed in a language and the order in which they may be written. This is usually specified in a structured, compositional manner, e.g.: sentence := noun verb noun “.” loop := “WHILE” exp “DO” stm This can be very subtle e.g. what is the role of a ‘;’ in Java vs. the role of ‘;’ in Pascal?

8 SEMANTICS..is all about the relationship between the symbols in a language and their meaning. The meaning of a language is often defined by ascribing meaning to the grammatical components of the language. E.g. semantics(“REPEAT” stm “UNTIL” exp) = execute stm, then check if exp is true; if it is then halt else execute REPEAT again

9 SEMANTICS- EXAMPLE WHAT CAN YOU SAY ABOUT THE FOLLOWING COMMANDS? X := X+1 (Pascal) X = X+1 ( C ) X++ ( C )

10 PRAGMATICS..is all about the use or utility of the components of a language. To write complex programs we use decomposition: procedures/methods solve sub-problems of the main problem abstraction: objects encapsulate the representation of a data type, procedures/methods encapsulate the particular algorithm used to solve the sub-problem. Reasoning: documentation, invariants, long variable names all help us to reason about the workings of a program None of these add to the computational power of a PL!

11 RELATED CONCEPTS Semiotics – the science of SIGNS and SYMBOLS – esp. their form and meaning Linguistics – as semiotics but specific to the SYMBOLS contained in a language Syntax can be broken up into: Morphology – make-up of words Grammar – legal orderings of words, the structure of the phrases and sentences language

12 SEMANTICS.. WHY?..There are many uses for semantic definitions: compiler specification documentation analysis / classification of a language checking properties of a language standardisation deriving proofs of correctness of programs

13 Semantics: Different Definitions Natural Language Semantics Axiomatic Semantics Operational Semantics Denotational Semantics

14 Natural Language Semantics Giving the meaning of (components of) a language in pure natural language form. The meaning may well suffer from ambiguities and inconsistencies typical in such definitions. It has been said that there have been no correct definitions of usable languages completed in natural language

15 Axiomatic Semantics Commands change states: each command in the language is given a meaning in terms of axioms / inference rules which defines how the command changes a program “state” Commands are defined in terms of pre- and post- conditions on states AS are good for proving the (partial) correctness of programs.

16 Operational Semantics Language components are defined in terms of a simple, well-defined abstract “machine”. Operational Semantics are good for proving the implementation of a PL correct.

17 Denotational Semantics Syntax Classes are mapped via “meaning functions” to a mathematical language - typically lambda calculus A denotational definition usually consists of - the (abstract) syntax of the language a set of meaning functions for each of the syntax classes

18 Denotational Semantics: Revision You will need to revise: sets and functions Functional Programming Syntax Definitions (BNF)

19 Exercises Look up the definition of some of the key concepts in this lecture on the internet eg Semiotics, linguistics, semantics, meaning, denotation, syntax, grammar, pragmatics, morphology, phrase structure Try to relate the concepts using a diagram. Write down a “one line” definition of each concept.


Download ppt "Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical."

Similar presentations


Ads by Google