commit 1fcef6aae92b4d3a4214473648709aea33ae56ac Author: quirinecker Date: Thu Oct 9 22:20:14 2025 +0200 initial commit, finished 1a 1b diff --git a/index.pdf b/index.pdf new file mode 100644 index 0000000..7b5bb66 Binary files /dev/null and b/index.pdf differ diff --git a/index.typ b/index.typ new file mode 100644 index 0000000..2135895 --- /dev/null +++ b/index.typ @@ -0,0 +1,106 @@ +#import "@preview/codly:1.3.0": * +#import "@preview/codly-languages:0.1.1": * +#import "@preview/catppuccin:1.0.1": catppuccin, flavors + +#show: codly-init.with() +#show: catppuccin.with(flavors.latte) + +#codly(languages: codly-languages) + += Exercise 01 + +#let question(body) = block( + fill: luma(240), + inset: 8pt, + radius: 4pt +)[ + #body +] + +== 01 Grundbegriffe + +=== Task a + +#question[ + Wie lang (in Terminalsymbolen) ist der kürzeste Satz in MicroJava, der mindestens ein Tilde (“∼”) + enthält? Geben Sie ein Beispiel für einen Satz dieser Länge an. Der Satz muss nur syntaktisch korrekt + (entspricht der Grammatik) sein, nicht semantisch (hält alle Kontextbedingungen der Sprache ein). Bei- + spielsweise ist x = x + 1, ohne x zuvor zu definieren, eine syntaktisch korrekte Zuweisung, semantisch + korrekt ist sie aber nicht. +] + +```java +x[~1]++; +``` + +The statement above contains the following tokens: + +- x (iden, terminal) +- "\[" (literal, terminal) +- "~" (literall, terminal) +- 1 (number, terminal) +- "\]" (literal, terminal) +- "++" (literal, terminal) +- ";" (literal, terminal) + +To sum it up the statement has a `~` and has a terminal symbol count of 7. + +=== Task b + +#question[ +Sind die Nonterminalsymbole Statement und ActPars rekursiv? Wenn ja, geben Sie alle Rekursionen- +arten an (Transitivität: direkt, indirekt; Orientierung: links, rechts, zentral). Beispiele für Rekursionsarten +sind direkt zentralrekursiv, indirekt linksrekursiv, . . . Pro NT kann es mehrere Rekursionsarten geben. +Geben Sie bei indirekten Rekursionen einen möglichen Pfad an (Beispiel: Factor ist indirekt zentralre- +kursiv über Factor -> Expr -> Term -> Factor). +] + +==== Statement + +The relevant Productions for the Statement Symbol are: + +``` +Statement = Designator ( Assignop Expr | ActPars | "++" | "--" ) ";" +| "if" "(" Condition ")" Statement [ "else" Statement ] +| "while" "(" Condition ")" Statement +| "break" ";" +| "return" [ Expr ] ";" +| "read" "(" Designator ")" ";" +| "print" "(" Expr [ "," number ] ")" ";" +| Block +| ";". + +Block = "{" { Statement } "}". +``` + +We have the following Recursions: + +- line 2: Statement is directly central recursive +- line 3: Statement is directly right recursive +- line 8: Block is indirectly central recursive + + +==== ActPars + +The relevant Productions for the ActPars Symbol are: + +``` +ActPars = "(" [ Expr { "," Expr } ] ")". + +Expr = [ "–" ] Term { Addop Term }. + +Term = Factor { Mulop Factor }. + +Factor = Designator [ ActPars ] +| number +| charConst +| "new" ident [ "[" Expr "]" ] +| "(" Expr ")". +``` + +We have the following Recursion: + +- line 1: Factor is indirectly central recursive + +=== Task c +