IIm18-Kreativaufgabe8

Aus ProgrammingWiki

Wiki-Quelltext dieser Seite.

=LOOP - WHILE - GOTO =
Entwickeln Sie einen Compiler, der als Eingabesprache LWHILE ∪ LGOTO ∪ LLOOP verwendet und ein zur Eingabe ̈aquivalentes Programm aus LWHILE(Zielsprache) erzeugt. Die Interpretation des jeweils entstandenen WHILE-Programms ist nicht gefordert.

== Testprogramme ==
=== WHILE ===
 x0 := x0+1;
 WHILE x0 != 0 DO x0 := x0 - 1 END

=== LOOP ===
 x1 := x1 + 1;
 LOOP x0 DO x1 := x1 + 0 END;
 LOOP x1 DO x1 := x1 + 1 END

=== GOTO ===
 M1: IF x1 == 0 THEN GOTO M2;
 M3: x0 := x0 + 0;
 M2: GOTO M1;
 M4: x0 := x0 + 1;