This is an old revision of the document!


10. Writing a parser for a CF language

10.1.1. Write a grammar which accurately describes regular expressions. Consider the following definition: A regular expression is built in the normal way, using the symbols (,),*,| and any other alpha-numeric caracter. Free spaces may occur freely within the expression.

10.1.2. Starting from the solution to the previous exercise, write an unambiguous grammar for regexes:

  • Make sure to take precedence into account

10.2.1. Write a parser for the following language:

  • $ S \leftarrow M \mid M + S$
  • $ M \leftarrow A \mid A * M$
  • $ A \leftarrow 0 \mid 1 \mid (S)$