[project @ 2002-06-05 14:08:23 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)
commit2145e55a4fbd60c3bd134496d82ddc545bd698ba
tree316c1dce0df22aecbc88d079bb71fc193e3583d5
parent84e376bc7bc01799d444cdb2d915d69f36fe77d5
[project @ 2002-06-05 14:08:23 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/compiler/prelude/PrelNames.lhs
ghc/compiler/typecheck/TcGenDeriv.lhs