cws/cw04.tex
changeset 952 33b3e790e1d4
parent 951 9e7147f33219
child 959 64ec1884d860
equal deleted inserted replaced
951:9e7147f33219 952:33b3e790e1d4
    20 syntax). Please submit your answers to the questions
    20 syntax). Please submit your answers to the questions
    21 below as PDF. You can do the implementation in any programming
    21 below as PDF. You can do the implementation in any programming
    22 language you like, but you need to submit the source code with
    22 language you like, but you need to submit the source code with
    23 which you answered the questions, otherwise a mark of 0\% will
    23 which you answered the questions, otherwise a mark of 0\% will
    24 be awarded. You should use the lexer and parser from the
    24 be awarded. You should use the lexer and parser from the
    25 previous courseworks.
    25 previous courseworks. Implement your compiler in the file \texttt{cw04.sc}.
    26 
    26 
    27 %Please package \emph{everything}(!) in
    27 %Please package \emph{everything}(!) in
    28 %a zip-file that creates a directory with the name
    28 %a zip-file that creates a directory with the name
    29 %\texttt{YournameYourFamilyname} on my end.
    29 %\texttt{YournameYourFamilyname} on my end.
    30 
    30 
   247 
   247 
   248 \noindent 
   248 \noindent 
   249 Note that in this program the variable \pcode{i} is used
   249 Note that in this program the variable \pcode{i} is used
   250 twice. You need to make a decision how it should be compiled?
   250 twice. You need to make a decision how it should be compiled?
   251 Explain your decision and indicate what this program would
   251 Explain your decision and indicate what this program would
   252 print out.
   252 print out. Give your answer in the file \texttt{q3-answer.txt}.
   253 
   253 
   254 \subsection*{Question 4}
   254 \subsection*{Question 4}
   255 
   255 
   256 Extend the lexer and parser to add a \textcolor{codepurple}{\pcode{break}} keyword.  Modify
   256 Extend the lexer and parser to add a \textcolor{codepurple}{\pcode{break}} keyword.  Modify
   257 the compiler (including lexer and parser) such that when a \textcolor{codepurple}{\texttt{break}}-statement is encountered
   257 the compiler (including lexer and parser) such that when a \textcolor{codepurple}{\texttt{break}}-statement is encountered
   286 should print out 0 to 10 with the first for-loop, but only 0
   286 should print out 0 to 10 with the first for-loop, but only 0
   287 to 4 in the second. Similarly it should print out \code{"Should print"},
   287 to 4 in the second. Similarly it should print out \code{"Should print"},
   288 but not \code{"Should not print"}. For this you need to add
   288 but not \code{"Should not print"}. For this you need to add
   289 a label to the end of every for-loop and also to the end of the
   289 a label to the end of every for-loop and also to the end of the
   290 whole program just in case you need to jump to that label via a
   290 whole program just in case you need to jump to that label via a
   291 \code{break}.
   291 \code{break}. The file you need to be able to process for this question
       
   292 is called \texttt{break.while}.
   292 
   293 
   293 
   294 
   294 \subsection*{Further Information}
   295 \subsection*{Further Information}
   295 
   296 
   296 The Java infrastructure unfortunately does not contain an
   297 The Java infrastructure unfortunately does not contain an