BuK/IIm11/BuK-KA-WHILE-COMPILER
Aus ProgrammingWiki
Wiki-Quelltext dieser Seite.
== Aufgabenstellung ==
Entwickeln Sie einen Compiler, der als Eingabesprache $L_{WHILE}\cup L_{GOTO}\cup L_{LOOP}$ verwendet und ein zur Eingabe äquivalentes Programm aus $L_{WHILE}$ (Zielsprache) erzeugt. Die Interpretation des jeweils entstandenen $WHILE$-Programms ist nicht gefordert.
Verwenden Sie AtoCC
== Grammatik ==
G = (N, T, P, s)
N={}
T={}
P={
S -> P_GOTO ; HALT | P_LOOP | P_WHILE
P_GOTO -> Marke : Anweisung | Anweisung | P_GOTO ; P_GOTO
Anweisung -> Wertezuweisung | GOTO Marke
| IF Variable == Konstante THEN GOTO Marke
P_LOOP -> Wertezuweisung | P_LOOP ; P_LOOP | LOOP Variable DO P_LOOP END
P_WHILE -> Wertezuweisung | P_WHILE ; P_WHILE
| WHILE Variable != 0 DO P_WHILE END
Wertezuweisung -> Variable ':=' Variable Operation Konstante
Variable -> x Konstante
Marke -> M Konstante
Konstante -> Digit Konstante | Digit
Digit -> 0|1|...|9
Operation -> + | -
}