chair chair cpsc 449 principles of programming languages
play

? ? Chair Chair CPSC 449 Principles of Programming Languages Jrg - PDF document

1. Introduction Human Languages Good abstract data types Babel, many Day! Semantics years ago Grammar loops Bon SLD-Resolution Jour! l -Calculus Language Guten Tag! ? Compiler Syntax Interpreter Parsing Error handling CPSC 449


  1. 1. Introduction Human Languages Good abstract data types Babel, many Day! Semantics years ago Grammar loops Bon SLD-Resolution Jour! l -Calculus Language Guten Tag! ? Compiler Syntax Interpreter Parsing Error handling CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger Language: definition Language: definition (cont.) Language: 2 a : form or manner of verbal expression; esp. STYLE 1 a : the words, their pronunciation, and the methods (forceful language ) of combining them used and understood by a large b : the words and expressions of a particular group or group of people field (the language of medicine) b (1): audible, articulate, and meaningful sound as 3: the study of language especially as a school subject produced by the action of the vocal organs (Old French, from langue "tongue, language:, from (2): a systematic means of communicating ideas by Latin lingua ) signs or marks with understood meanings (sign language ) Webster's New Encyclopedic Dictionary, 1996 Edition CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger How is language supposed to work? How is language supposed to work? ? ? Chair Chair CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger 1

  2. How is language supposed to work? How is language supposed to work? ? Chair Chair CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger But: So: Syntax Semantics Chair CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger What do we want to communicate using a language? Language is more than words! n Things n Letters are used to form words n Words are used to form phrases l visible/invisible n Phrases form sentences l real/imaginary n Concepts n Sentences form paragraphs n Actions n Paragraphs form sections n Relationships n Sections together form chapters l Causal n Chapters form books l Temporal n … CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger 2

  3. How do we go from syntax to But: semantics? n Not every sequence of letters is an "allowed" word n Humans learn about the meaning of words from other humans and develop their own relations n Not every combination of words is a phrase between syntactical constructs and semantical n Not every collection of phrases is a sentence concepts n There are then groups of human beings that have F Syntax defines what is allowed and what not! rather similar semantical concepts for the same But: syntax must be communicated between humans! syntactical construct F Grammars F A language is born are used to describe syntax (using rules, laws, etc.) CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger Problems with human languages (II) Problems with human languages (I) n Human languages change CHATILLON n Several different syntactical constructs can express Philip of France, in right and true behalf the same semantical concepts: Of thy deceased brother Geffrey's son, l Chair vs. object you sit on Arthur Plantagenet, lays most lawful claim l This allows poets to exist! To this fair island and the territories, n One syntactical construct can be associated with To Ireland, Poictiers, Anjou, Touraine, Maine, several semantical concepts Desiring thee to lay aside the sword Which sways usurpingly these several titles, Chair And put these same into young Arthur's hand, Thy nephew and right royal sovereign. l Ambiguity: source for many jokes The Life and Death of King John William Shakespeare CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger Why do we have the Babel syndrome What about computer programming here? languages? n People want to combine certain features of other languages into one language n Fortran n People want to work on a higher abstraction level n Prolog and therefore produce a language with such higher n Lisp concepts n C / C++ n People want to have a language that supports certain n Java types of tasks: n Smalltalk l Self modifying programs n … l Real-time applications l Verification of programs l etc. n There is a new idea of computability CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger 3

  4. How is a programming language How is a programming language supposed to work? supposed to work? pr Compiler Compiler Exe- oz Source cutable es code ? ? so file Inter- preter memory r CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger How is a programming language How is a programming language supposed to work? supposed to work? pr pr Compiler Compiler oz oz Source Source es es code code ? ! so so Inter- Inter- Inter- Inter- file file preter preter preter preter memory memory r r CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger But still: So, what defines semantics? n Language report in natural language n Operating system of underlying computer n Understanding of designer & programmer of compiler/interpreter of language report and machine specifications CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger 4

  5. What do we want to communicate How do we define a programming using a programming language? language? (I) n Data and the structure of data Syntax: n Many different manipulations of data n Formal grammars like n Sequences and more complex combinations of data l Context-free grammars manipulations l Backus-Naur form n Access to external devices, like sensors, files, printers l Attribute grammars n Syntax diagrams CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger How do we define a programming Problems with programming language? (II) languages (I) n Several different syntactical constructs can result in Semantics: the same computation result: n Theoretically using: j:= 0 j:= 0 l Operational semantics for i:=1 to 5 do i:= 1 l Axiomatic semantics j := j+1; while i<> 6 do begin l Denotational (or fixpoint) semantics j:= j+1; n Practically: i:=i+1 l (in theory) by a language report end l (in practice) by a compiler/interpreter CPSC 449 Principles of Programming Languages Jörg Denzinger CPSC 449 Principles of Programming Languages Jörg Denzinger Problems with programming languages (II) n Programming languages can change! Remember the Java 1.1 to Java 1.2 fiasco But: the same syntactical construct should never have different meanings (now, we just have to tell the compiler guys this J ) CPSC 449 Principles of Programming Languages Jörg Denzinger 5

Recommend


More recommend