1
I ntro – Lecture 9
1 Chair of Softw are Engineering
Introduction to Programming
Michela Pedroni
16 Novem ber 2003
I ntro – Lecture 9
2 Chair of Softw are Engineering
Lecture 9: Describing the Syntax
I ntro – Lecture 9
3 Chair of Softw are Engineering
Why describe the syntax formally?
We know syntax descriptions for human languages: e.g. gramm ar for German, French, … Expressed in natural language Good enough for human use Ambiguous, like human languages themselves
I ntro – Lecture 9
4 Chair of Softw are Engineering
Syntax: Conditional
A conditional instruction consists, in order, of: An “If part”, of the form if condition. A “Then part” of the form then compound. Zero or m ore “Else if parts”, each of the form elseif condition then com pound. Zero or one “Else part” of the form else compound The keyword end. Here each condition is a boolean expression, and each com pound is a compound instruction.
I ntro – Lecture 9
5 Chair of Softw are Engineering
Why describe the syntax formally?
Programm ing languages need better descriptions: More precise: must tell us unambiguously whether given program text is legal or not Use formalism sim ilar to mathematics Can be fed into com pilers for automatic processing of programs
I ntro – Lecture 9
6 Chair of Softw are Engineering