tics - university of calgary in albertadenzinge/courses/... · cpsc 449 principles of programming...
TRANSCRIPT
![Page 1: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/1.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
1. IntroductionLanguage
Semantics
Parsing
Gramm
ar
Syn
tax
Co
mpiler
Interpreter
?
l-Ca
lcu
lus
SLD-Resolution
abstract data types
loo
ps
Error handling
![Page 2: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/2.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Hum
an LanguagesBabel, m
anyyears ago
Good
Day!G
utenT
ag!
Bon
Jour!
![Page 3: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/3.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Language: definition
Language:1 a: the w
ords, their pronunciation, and the methods
of combining them
used and understood by a largegroup of peopleb (1): audible, articulate, and m
eaningful sound asproduced by the action of the vocal organs(2): a system
atic means of com
municating ideas by
signs or marks w
ith understood meanings (sign
language)
![Page 4: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/4.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Language: definition (cont.)
2 a: form or m
anner of verbal expression; esp. STYLE(forceful language)b: the w
ords and expressions of a particular group orfield (the language of m
edicine)3: the study of language especially as a school subject(O
ld French, from langue "tongue, language:, from
Latin lingua)
Webster's N
ew Encyclopedic D
ictionary, 1996 Edition
![Page 5: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/5.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is language supposed to work?
Chair?
![Page 6: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/6.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is language supposed to work?
Chair?
![Page 7: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/7.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is language supposed to work?
Chair?
![Page 8: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/8.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is language supposed to work?
Chair
![Page 9: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/9.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
But:
![Page 10: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/10.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
So:Chair SyntaxSem
antics
![Page 11: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/11.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
What do w
e want to com
municate
using a language?
nThingsl
visible/invisiblel
real/imaginary
nConcepts
nA
ctionsn
Relationshipsl
Causall
Temporal
n…
![Page 12: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/12.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Language is more than w
ords!
nLetters are used to form
words
nW
ords are used to form phrases
nPhrases form
sentencesn
Sentences form paragraphs
nParagraphs form
sectionsn
Sections together form chapters
nChapters form
books
![Page 13: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/13.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
But:
nN
ot every sequence of letters is an "allowed" w
ordn
Not every com
bination of words is a phrase
nN
ot every collection of phrases is a sentence
F Syntax defines w
hat is allowed and w
hat not!But: syntax m
ust be comm
unicated between hum
ans!F
Gram
mars
are used to describe syntax (using rules, laws, etc.)
![Page 14: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/14.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
do we go from
syntax tosem
antics?
nH
umans learn about the m
eaning of words from
other humans and develop their ow
n relationsbetw
een syntactical constructs and semantical
conceptsn
There are then groups of human beings that have
rather similar sem
antical concepts for the same
syntactical constructF
A language is born
![Page 15: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/15.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Problems w
ith human languages (I)
nSeveral different syntactical constructs can expressthe sam
e semantical concepts:
lChair vs. object you sit on
lThis allow
s poets to exist!n
One syntactical construct can be associated w
ithseveral sem
antical concepts
lA
mbiguity: source for m
any jokes
Chair
![Page 16: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/16.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Problems w
ith human languages (II)
nH
uman languages change
CHA
TILLON
Philip of France, in right and true behalfO
f thy deceased brother Geffrey's son,
Arthur Plantagenet, lays m
ost lawful claim
To this fair island and the territories,To Ireland, Poictiers, A
njou, Touraine, Maine,
Desiring thee to lay aside the sw
ordW
hich sways usurpingly these several titles,
And put these sam
e into young Arthur's hand,
Thy nephew and right royal sovereign.
The Life and D
eath of King John
William
Shakespeare
![Page 17: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/17.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
What about com
puter programm
inglanguages?
nFortran
nProlog
nLisp
nC / C++
nJava
nSm
alltalkn
…
![Page 18: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/18.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Why do w
e have the Babel syndrome
here?n
People want to com
bine certain features of otherlanguages into one language
nPeople w
ant to work on a higher abstraction level
and therefore produce a language with such higher
conceptsn
People want to have a language that supports certain
types of tasks:l
Self modifying program
sl
Real-time applications
lVerification of program
sl
etc.n
There is a new idea of com
putability
![Page 19: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/19.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is a programm
ing languagesupposed to w
ork?
?
![Page 20: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/20.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is a programm
ing languagesupposed to w
ork?
?Sourcecodefile
Compiler
Inter-preter
mem
ory
prozessor
Compiler
Exe-cutable
![Page 21: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/21.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is a programm
ing languagesupposed to w
ork?
?Sourcecodefile
Compiler
Inter-preter
mem
ory
prozessorInter-preter
![Page 22: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/22.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
is a programm
ing languagesupposed to w
ork?
!Sourcecodefile
Compiler
Inter-preter
mem
ory
prozessorInter-preter
![Page 23: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/23.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
But still:
![Page 24: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/24.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
So, what defines sem
antics?
nLanguage report in natural language
nO
perating system of underlying com
putern
Understanding of designer &
programm
er ofcom
piler/interpreter of language report and machine
specifications
![Page 25: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/25.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
What do w
e want to com
municate
using a programm
ing language?
nD
ata and the structure of datan
Many different m
anipulations of datan
Sequences and more com
plex combinations of data
manipulations
nA
ccess to external devices, like sensors, files, printers
![Page 26: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/26.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
do we define a program
ming
language? (I)
Syntax:n
Formal gram
mars like
lContext-free gram
mars
lBackus-N
aur forml
Attribute gram
mars
nSyntax diagram
s
![Page 27: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/27.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
How
do we define a program
ming
language? (II)
Semantics:
nTheoretically using:l
Operational sem
anticsl
Axiom
atic semantics
lD
enotational (or fixpoint) semantics
nPractically:l
(in theory) by a language reportl
(in practice) by a compiler/interpreter
![Page 28: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/28.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Problems w
ith programm
inglanguages (I)
nSeveral different syntactical constructs can result inthe sam
e computation result:
j:= 0
j:= 0
for i:=1 to 5 do
i:= 1
j := j+
1;w
hile i<>
6 dobeginj:=
j+1;
i:=i+
1end
![Page 29: tics - University of Calgary in Albertadenzinge/courses/... · CPSC 449 Principles of Programming Languages Jörg Den zin g er L an g u ag e: d efin itio n (co n t.) 2 a: form or](https://reader033.vdocuments.us/reader033/viewer/2022060515/5f8a50df0720b55af1422769/html5/thumbnails/29.jpg)
CPSC 449 Principles of Programm
ing Languages Jörg D
enzinger
Problems w
ith programm
inglanguages (II)
nProgram
ming languages can change!
Remem
ber the Java 1.1 to Java 1.2 fiasco
But: the same syntactical construct should never have
different meanings
(now, w
e just have to tell the compiler guys this J
)