[project @ 2002-06-05 14:08:24 by simonpj]
authorsimonpj <unknown>
Wed, 5 Jun 2002 14:08:25 +0000 (14:08 +0000)
committersimonpj <unknown>
Wed, 5 Jun 2002 14:08:25 +0000 (14:08 +0000)
commit4af6a1708d420733fc9110cbac58e8bfacdaf53d
tree9b49cad49660a262722d5a55617bc13b583a5c2f
parentdc3a9adce050b1db078c939473c7e293721f5c2c
[project @ 2002-06-05 14:08:24 by simonpj]
------------------------------------------------
Fix the (new) lexer, and make the derived read
and show code work according to the new H98 report
------------------------------------------------

The new lexer, based on Koen's cunning parser (Text.ParserCombinators.ReadP)
wasn't quite right.  It's all very cool now.

In particular:

* The H98 "lex" function should return the exact string parsed, and it
now does, aided by the new combinator ReadP.gather.

* As a result the Text.Read.Lex Lexeme type is much simpler than before
    data Lexeme
      = Char   Char -- Quotes removed,
      | String String --  escapes interpreted
      | Punc   String  -- Punctuation, eg "(", "::"
      | Ident  String -- Haskell identifiers, e.g. foo, baz
      | Symbol String -- Haskell symbols, e.g. >>, %
      | Int Integer
      | Rat Rational
      | EOF
     deriving (Eq,Show)

* Multi-character punctuation, like "::" was getting lexed as a Symbol,
but it should be a Punc.

* Parsing numbers wasn't quite right.  "1..n" got it confused because it
got committed to a decimal point and then found a second '.'.

* The new H98 spec for Show is there, which ignores associativity.
GHC/Read.lhs
Numeric.hs
Text/ParserCombinators/ReadP.hs
Text/Read/Lex.hs