Werk College 11

FP
The easiest way to make these exercises is to add your definitions to the Prolog Interperter. If you make mistakes you can easily see where your parser and the input do have a mismatch

  • Define a parser for a (possibly negative) integer number, which consists of an optional minus sign followed by a natural number.
  • Let the parser for floating point numbers recognize an optional exponent.
  • As another variation on the theme `repetition', define a =pSequence=combinator that transforms alist of parsers for some type into a parser yielding a list of elements of that type.
  • Consider application of the parser Many (pSym 'a') to the string "aaa". In what order do the four possible parsings appear in the list of successes?
  • When defining the priority of the <|>=operator, using the =infixr keyword we also specified that the operator associates to the right. Why is this a better choice than association to the left?
  • Can you write the function pToken in terms of pSym?

-- DoaitseSwierstra - 19 Oct 2010