Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Klausur 15 Task 7
// S -> b {T.A = S.A -1} T {U.A = T.B} U {S.B = U.B}
// T -> {S.A = T.A } S {U.A = S.B} U {T.B = U.B}
// T -> e {T.B = T.A}
// U -> a {S.A = U.A +2} S {U.A = S.B} U {U.B = U.B}
int X;
main() {
SCANNER(X);
S(S_A);
}
// S -> b {T.A = S.A -1} T {U.A = T.B} U {S.B = U.B}
int S (int S_A) {
if (X != "b") return;
SCANNER(X);
T_B = T(S_A - 1);
SCANNER(X);
U_B = U(T_B);
S_B = U_B;
return S_B;
}
// T -> {S.A = T.A } S {U.A = S.B} U {T.B = U.B}
// T -> e {T.B = T.A}
int T (int T_A) {
if ( X == "e" ) {
T_B = T_A;
return T_B;
} else {
S_A = T_A;
S_B = S(S_A);
U_A = S_B;
SCANNER(X);
U_B = U(U_A);
T_B = U_B;
return T_B;
}
}
// U -> a {S.A = U.A +2} S {U.A = S.B} U {U.B = U.B}
// U -> e {U.B = U.A}
int U (int U_A) {
if (X == "a") {
S_A = U_A + 2;
SCANNER(X);
S_B = S ( S_A );
U_A = S_B;
SCANNER(X);
U_B = U(U_A);
U_B = U_B;
return U_B;
} else if (X == "e") {
U_B = U_A;
return U_B;
} else return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.