cws/cw03.tex
changeset 801 7aab258bf72a
parent 752 c0bdd4ad69ca
child 860 6f80e6df34f7
equal deleted inserted replaced
800:9eea6a801e10 801:7aab258bf72a
    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}