cws/cw03.tex
changeset 801 b17a43f80ed0
parent 752 1f1a293549c1
child 860 abf63cd5e11b
equal deleted inserted replaced
800:bdd731e4edbf 801:b17a43f80ed0
    53 You should implement a parser for the WHILE language using parser
    53 You should implement a parser for the WHILE language using parser
    54 combinators. Be careful that the parser takes as input a stream, or
    54 combinators. Be careful that the parser takes as input a stream, or
    55 list, of \emph{tokens} generated by the tokenizer from the previous
    55 list, of \emph{tokens} generated by the tokenizer from the previous
    56 coursework. For this you might want to filter out whitespaces and
    56 coursework. For this you might want to filter out whitespaces and
    57 comments. Your parser should be able to handle the WHILE programs in
    57 comments. Your parser should be able to handle the WHILE programs in
    58 Figures~\ref{fib}, \ref{loop} and \ref{primes}.  In addition give the
    58 Figures~\ref{fib} -- \ref{collatz}.  In addition give the
    59 parse tree for the statement:
    59 parse tree for the statement:
    60 
    60 
    61 \begin{lstlisting}[language=While,numbers=none]
    61 \begin{lstlisting}[language=While,numbers=none]
    62 if (a < b) then skip else a := a * b + 1
    62 if (a < b) then skip else a := a * b + 1
    63 \end{lstlisting}
    63 \end{lstlisting}