summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Fischer <daniel.is.fischer@googlemail.com>2011-09-19 12:41:38 +0200
committerDaniel Fischer <daniel.is.fischer@googlemail.com>2011-09-19 12:41:38 +0200
commit8266f5fd2857344289eadd38a5826a8e8d4061c1 (patch)
tree4199eb11f578a443a63fc0e68c532e38d918dc9d
parentc9b4d059ee4f931b89742208742385a9d0063dcd (diff)
downloadhaskell-8266f5fd2857344289eadd38a5826a8e8d4061c1.tar.gz
Whitespace only in Text.Read.Lex
-rw-r--r--libraries/base/Text/Read/Lex.hs52
1 files changed, 26 insertions, 26 deletions
diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs
index 88c9c07212..a3e48e40c2 100644
--- a/libraries/base/Text/Read/Lex.hs
+++ b/libraries/base/Text/Read/Lex.hs
@@ -6,7 +6,7 @@
-- Module : Text.Read.Lex
-- Copyright : (c) The University of Glasgow 2002
-- License : BSD-style (see the file libraries/base/LICENSE)
---
+--
-- Maintainer : libraries@haskell.org
-- Stability : provisional
-- Portability : non-portable (uses Text.ParserCombinators.ReadP)
@@ -19,13 +19,13 @@ module Text.Read.Lex
-- lexing types
( Lexeme(..) -- :: *; Show, Eq
- -- lexer
+ -- lexer
, lex -- :: ReadP Lexeme Skips leading spaces
, hsLex -- :: ReadP String
, lexChar -- :: ReadP Char Reads just one char, with H98 escapes
, readIntP -- :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadP a
- , readOctP -- :: Num a => ReadP a
+ , readOctP -- :: Num a => ReadP a
, readDecP -- :: Num a => ReadP a
, readHexP -- :: Num a => ReadP a
)
@@ -40,7 +40,7 @@ import GHC.Show( Show(..) )
#ifndef __HADDOCK__
import {-# SOURCE #-} GHC.Unicode ( isSpace, isAlpha, isAlphaNum )
#endif
-import GHC.Real( Ratio(..), Integral, Rational, (%), fromIntegral,
+import GHC.Real( Ratio(..), Integral, Rational, (%), fromIntegral,
toInteger, (^), (^^), infinity, notANumber )
import GHC.List
import GHC.Enum( maxBound )
@@ -78,17 +78,17 @@ lex = skipSpaces >> lexToken
hsLex :: ReadP String
-- ^ Haskell lexer: returns the lexed string, rather than the lexeme
-hsLex = do skipSpaces
+hsLex = do skipSpaces
(s,_) <- gather lexToken
return s
lexToken :: ReadP Lexeme
lexToken = lexEOF +++
- lexLitChar +++
- lexString +++
- lexPunc +++
- lexSymbol +++
- lexId +++
+ lexLitChar +++
+ lexString +++
+ lexPunc +++
+ lexSymbol +++
+ lexId +++
lexNumber
@@ -115,7 +115,7 @@ lexPunc =
lexSymbol :: ReadP Lexeme
lexSymbol =
do s <- munch1 isSymbolChar
- if s `elem` reserved_ops then
+ if s `elem` reserved_ops then
return (Punc s) -- Reserved-ops count as punctuation
else
return (Symbol s)
@@ -130,10 +130,10 @@ lexId :: ReadP Lexeme
lexId = lex_nan <++ lex_id
where
-- NaN and Infinity look like identifiers, so
- -- we parse them first.
+ -- we parse them first.
lex_nan = (string "NaN" >> return (Rat notANumber)) +++
(string "Infinity" >> return (Rat infinity))
-
+
lex_id = do c <- satisfy isIdsChar
s <- munch isIdfChar
return (Ident (c:s))
@@ -168,13 +168,13 @@ lexCharE =
if c1 == '\\'
then do c2 <- lexEsc; return (c2, True)
else do return (c1, False)
- where
+ where
lexEsc =
lexEscChar
+++ lexNumeric
+++ lexCntrlChar
+++ lexAscii
-
+
lexEscChar =
do c <- get
case c of
@@ -189,7 +189,7 @@ lexCharE =
'\"' -> return '\"'
'\'' -> return '\''
_ -> pfail
-
+
lexNumeric =
do base <- lexBaseChar <++ return 10
n <- lexInteger base
@@ -237,7 +237,7 @@ lexCharE =
lexAscii =
do choice
[ (string "SOH" >> return '\SOH') <++
- (string "SO" >> return '\SO')
+ (string "SO" >> return '\SO')
-- \SO and \SOH need maximal-munch treatment
-- See the Haskell report Sect 2.6
@@ -293,7 +293,7 @@ lexString =
lexStrItem = (lexEmpty >> lexStrItem)
+++ lexCharE
-
+
lexEmpty =
do _ <- char '\\'
c <- get
@@ -309,11 +309,11 @@ type Base = Int
type Digits = [Int]
lexNumber :: ReadP Lexeme
-lexNumber
+lexNumber
= lexHexOct <++ -- First try for hex or octal 0x, 0o etc
-- If that fails, try for a decimal number
lexDecNumber -- Start with ordinary digits
-
+
lexHexOct :: ReadP Lexeme
lexHexOct
= do _ <- char '0'
@@ -329,7 +329,7 @@ lexBaseChar = do { c <- get;
'O' -> return 8
'x' -> return 16
'X' -> return 16
- _ -> pfail }
+ _ -> pfail }
lexDecNumber :: ReadP Lexeme
lexDecNumber =
@@ -339,15 +339,15 @@ lexDecNumber =
return (value xs mFrac mExp)
where
value xs mFrac mExp = valueFracExp (val 10 0 xs) mFrac mExp
-
- valueFracExp :: Integer -> Maybe Digits -> Maybe Integer
+
+ valueFracExp :: Integer -> Maybe Digits -> Maybe Integer
-> Lexeme
- valueFracExp a Nothing Nothing
+ valueFracExp a Nothing Nothing
= Int a -- 43
valueFracExp a Nothing (Just exp)
| exp >= 0 = Int (a * (10 ^ exp)) -- 43e7
| otherwise = Rat (valExp (fromInteger a) exp) -- 43e-7
- valueFracExp a (Just fs) mExp
+ valueFracExp a (Just fs) mExp
= case mExp of
Nothing -> Rat rat -- 4.3
Just exp -> Rat (valExp rat exp) -- 4.3e-4
@@ -370,7 +370,7 @@ lexExp = do _ <- char 'e' +++ char 'E'
exp <- signedExp +++ lexInteger 10
return (Just exp)
where
- signedExp
+ signedExp
= do c <- char '-' +++ char '+'
n <- lexInteger 10
return (if c == '-' then -n else n)