hws/hw09.tex
changeset 941 66adcae6c762
parent 916 10f834eb0a9e
child 958 fddf099a82f8
equal deleted inserted replaced
940:46eee459a999 941:66adcae6c762
    93 }
    93 }
    94 \end{lstlisting}
    94 \end{lstlisting}
    95 
    95 
    96 \item As an optimisation technique, a compiler might want to detect `dead code' and
    96 \item As an optimisation technique, a compiler might want to detect `dead code' and
    97   not generate anything for this code. Why does this optimisation technique have the
    97   not generate anything for this code. Why does this optimisation technique have the
    98   potential of speeding up the run-time of a program? (Hint: On what CPUs are programs
    98   potential of speeding up the run-time of a program? (Hint: On what kind of CPUs are programs
    99   run nowadays?)
    99   run nowadays?)
   100 
   100 
   101 \item In an earlier question, we analysed the advantages of having a lexer-phase
   101 \item In an earlier question, we analysed the advantages of having a lexer-phase
   102   before running the parser (having a lexer is definitely a good thing to have). But you
   102   before running the parser (having a lexer is definitely a good thing to have). But you
   103   might wonder if a lexer can also be implemented by a parser and some simple
   103   might wonder if a lexer can also be implemented by a parser and some simple
   113   What is wrong with implementing a lexer in this way?
   113   What is wrong with implementing a lexer in this way?
   114 
   114 
   115 \item What is the difference between a parse tree and an abstract
   115 \item What is the difference between a parse tree and an abstract
   116   syntax tree? Give some simple examples for each of them.
   116   syntax tree? Give some simple examples for each of them.
   117 
   117 
   118 
   118 \item What are the two main features of code in
   119 \item Give a description of how the Brzozowski matcher works. 
   119   static single assignment form (SSA)?
   120   The description should be coherent and logical.
   120 
   121 
   121   \solution{
   122 \item Give a description of how a compiler for the While-language can
   122     Variables are only assigned once and all operations are
   123   be implemented. You should assume you are producing code for the JVM.
   123     primitive (in the sense of simple arithmetic operations,
   124   The description should be coherent and logical.
   124     function calls and so on).
       
   125   }
       
   126 
       
   127   
       
   128 %\item Give a description of how the Brzozowski matcher works. 
       
   129 %  The description should be coherent and logical.
       
   130 
       
   131 %\item Give a description of how a compiler for the While-language can
       
   132 %  be implemented. You should assume you are producing code for the JVM.
       
   133 %  The description should be coherent and logical.
   125 
   134 
   126   
   135   
   127 \item \POSTSCRIPT  
   136 \item \POSTSCRIPT  
   128 
   137 
   129 %  \item It is true (I confirmed it) that
   138 %  \item It is true (I confirmed it) that