FW: Haskell 98 lexical syntax again

Simon Peyton-Jones simonpj@microsoft.com
Thu, 28 Feb 2002 07:18:42 -0800


Two small matters of lexical syntax for Haskell 98.  (As ever, I'm
posting this
to the whole list because I feel I shouldn't fiddle with the Report
telling you all.  Partly because many eyeballs is good for debugging,=20
partly because there might be an objection in principle that I don't
know of.)

1.  Ian Lynagh pointed out the following problem:

| The report says
| whitechar    -> newline | return | linefeed | vertab | formfeed
|              |  space | tab | uniWhite
| newline      -> a newline (system dependent)
| return       -> a carriage return
| linefeed     -> a line feed
| so, if your system defines a newline to be a line feed, an
| implementation is free to choose whether to lex a line feed=20
| as a whitechar or a newline, which makes quite a difference=20
| when you consider the layout rule!

I propose to solve this as follows:

  whitechar -> newline | vertab | space | tab | uniWhite
  newline   -> return linefeed | return | linefeed | formfeed
  return    -> a carriage return
  linefeed  -> a line feed

This means that CR, LF, or CRLF, are all valid 'newline' separators,
and the same sequence of characters should therefore work on any
Haskell implementation.

2. As a separate matter, I propose to replace the production for
ANY by
	ANY -> graphic | whitechar

This seems nicely dual to
	any -> graphic | space | tab

The existing production for ANY is:

ANY  ->  any | newline | vertab | formfeed | return | linefeed |

which simply repeats whitechar + space + tab.