H EBERHARD-KARLS-UNIVERSIT "AT T "UBINGEN WILHELM-SCHICKARD-INSTITUT F "UR INFORMATIK Arbeitsbereich Programmierung -- Prof. Dr. H. Klaeren "Ubersetzung einer einfachen Programmiersprache Herbert Klaeren 7. Februar 1995 1 INHALTSVERZEICHNIS INHALTSVERZEICHNIS Inhaltsverzeichnis 1 PLE--Programmiersprache mit Ausdr "ucken 7 1.1 Abstrakte Syntax : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 7 1.2 Semantische Bereiche : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 1.3 Semantik von Deklarationen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 1.4 Statische Semantik : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 1.5 Semantische Funktionen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9 1.6 Zwischencode ZE f "ur Ausdr "ucke : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9 1.7 "Ubersetzung von PLE nach ZE : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 10 1.8 Korrektheit der "Ubersetzung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 12 1.9 Konstantenfaltung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 13 2 PLA--Programmiersprache mit Anweisungen 14 2.1 Abstrakte Syntax : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 2.2 Semantische Bereiche : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 2.3 Semantik von Deklarationen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 2.4 Statische Semantik : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 2.5 Semantische Funktionen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 15 2.6 Zwischencode ZA f "ur Anweisungen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 16 2.7 "Ubersetzung von PLA nach ZA : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 16 2.8 Korrektheit der "Ubersetzung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 18 2.9 Kurzschlussauswertung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 18 3 PL0--Programmiersprache mit Blockschachtelung 20 3.1 Abstrakte Syntax : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 20 3.2 Semantische Bereiche : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 20 3.3 Semantik von Deklarationen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 20 3.4 Statische Semantik : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 21 3.5 Semantische Funktionen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 21 3.6 Zwischencode Z0 f "ur Bl"ocke : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 22 3.7 "Ubersetzung von PL0 nach Z0 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 23 3.8 Korrektheit der "Ubersetzung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 26 3.9 Beispiel : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 26 4 PLP--Programmiersprache mit Prozedurparametern 32 4.1 Abstrakte Syntax : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 32 4.2 Semantische Bereiche : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 32 4.3 Semantik von Deklarationen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 32 2 Herbert Klaeren, T "ubingen, 7. Februar 1995 http://www-pu.informatik.uni-tuebingen.de/~klaeren/pl.ps.gz INHALTSVERZEICHNIS INHALTSVERZEICHNIS 4.4 Statische Semantik : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 33 4.5 Semantische Funktionen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 34 4.6 Zwischencode ZP f "ur Bl"ocke : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 34 4.7 "Ubersetzung von PLP nach ZP : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 34 4.8 Korrektheit der "Ubersetzung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 36 4.9 Beispiel : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 36 5 PLD--Programmiersprache mit Datentypen 40 5.1 Abstrakte Syntax : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 40 5.2 Semantische Bereiche : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 41 5.3 Deklarationssemantik : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 41 5.4 Statische Semantik : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 42 5.5 Semantische Funktionen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 44 5.6 Zwischencode ZD f "ur Datenstrukturen : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 44 5.7 "Ubersetzung von PLD nach ZD : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 44 5.8 Korrektheit der "Ubersetzung : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 47