equal
deleted
inserted
replaced
11 \begin{document} |
11 \begin{document} |
12 |
12 |
13 \section*{Homework 8} |
13 \section*{Homework 8} |
14 |
14 |
15 \begin{enumerate} |
15 \begin{enumerate} |
16 \item Suppose the following grammar for the WHILE-language: |
|
17 |
|
18 \begin{center} |
|
19 \begin{tabular}{lcl} |
|
20 $Stmt$ & $\rightarrow$ & $\text{skip}$\\ |
|
21 & $|$ & $Id := AExp$\\ |
|
22 & $|$ & $\text{if}\; B\!Exp \;\text{then}\; Block \;\text{else}\; Block$\\ |
|
23 & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\medskip\\ |
|
24 $Stmts$ & $\rightarrow$ & $Stmt \;\text{;}\; Stmts$\\ |
|
25 & $|$ & $Stmt$\medskip\\ |
|
26 $Block$ & $\rightarrow$ & $\{ Stmts \}$\\ |
|
27 & $|$ & $Stmt$\medskip\\ |
|
28 $AExp$ & $\rightarrow$ & $AExp + AExp$\\ |
|
29 & $|$ & $AExp * AExp$\\ |
|
30 & $|$ & $( AExp )$\\ |
|
31 & $|$ & $Num$\\ |
|
32 & $|$ & $Id$\medskip\\ |
|
33 $BExp$ & $\rightarrow$ & $AExp = AExp$\\ |
|
34 & $|$ & $AExp \not= AExp$\\ |
|
35 & $|$ & $\text{false}$\\ |
|
36 & $|$ & $\text{true}$\\ |
|
37 |
|
38 \end{tabular} |
|
39 \end{center} |
|
40 |
|
41 Transform this grammar into Chomsky normalform. |
|
42 |
|
43 \item Write a program in the WHILE-language that calculates the factorial function. |
16 \item Write a program in the WHILE-language that calculates the factorial function. |
44 |
17 |
|
18 \item What optimisations could a compiler perform when compiling a WHILE-program? |
|
19 |
|
20 \item What is the main difference between the Java assembler (as processed by Jasmin) and |
|
21 Java Byte Code? |
|
22 |
|
23 \item Parser combinators can directly be given a string as input, without the need of a lexer. What are |
|
24 the advantages to first lex a string and then feed a sequence of tokens as input to the parser? |
45 \end{enumerate} |
25 \end{enumerate} |
46 |
26 |
47 \end{document} |
27 \end{document} |
48 |
28 |
49 %%% Local Variables: |
29 %%% Local Variables: |