Text.Read.Lex

base-4.11.1.0: Basic libraries

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)
Safe Haskell | Trustworthy
Language | Haskell2010

Text.Read.Lex

Description

The cut-down Haskell lexer, used by Text.Read

Synopsis

- data Lexeme
  - = Char Char
  - | String String
  - | Punc String
  - | Ident String
  - | Symbol String
  - | Number Number
  - | EOF
- data Number
- numberToInteger :: Number -> Maybe Integer
- numberToFixed :: Integer -> Number -> Maybe (Integer, Integer)
- numberToRational :: Number -> Rational
- numberToRangedRational :: (Int, Int) -> Number -> Maybe Rational
- lex :: ReadP Lexeme
- expect :: Lexeme -> ReadP ()
- hsLex :: ReadP String
- lexChar :: ReadP Char
- readIntP :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadP a
- readOctP :: (Eq a, Num a) => ReadP a
- readDecP :: (Eq a, Num a) => ReadP a
- readHexP :: (Eq a, Num a) => ReadP a
- isSymbolChar :: Char -> Bool

# Documentation

data Lexeme #

Constructors

Char Char | Character literal
String String | String literal, with escapes interpreted
Punc String | Punctuation or reserved symbol, e.g. `(`, `::`
Ident String | Haskell identifier, e.g. `foo`, `Baz`
Symbol String | Haskell symbol, e.g. `>>`, `:%`
Number Number | Since: base-4.6.0.0
EOF |

Instances

Eq Lexeme # |
Instance details Defined in Text.Read.Lex Methods (==) :: Lexeme -> Lexeme -> Bool Source # (/=) :: Lexeme -> Lexeme -> Bool Source #
Read Lexeme # | Since: base-2.1
Instance details Defined in GHC.Read Methods readsPrec :: Int -> ReadS Lexeme # readList :: ReadS [Lexeme] # readPrec :: ReadPrec Lexeme # readListPrec :: ReadPrec [Lexeme] #
Show Lexeme # |
Instance details Defined in Text.Read.Lex Methods showsPrec :: Int -> Lexeme -> ShowS # show :: Lexeme -> String # showList :: [Lexeme] -> ShowS #

data Number #

Since: base-4.7.0.0

Instances

Eq Number # |
Instance details Defined in Text.Read.Lex Methods (==) :: Number -> Number -> Bool Source # (/=) :: Number -> Number -> Bool Source #
Show Number # |
Instance details Defined in Text.Read.Lex Methods showsPrec :: Int -> Number -> ShowS # show :: Number -> String # showList :: [Number] -> ShowS #

numberToInteger :: Number -> Maybe Integer #

Since: base-4.5.1.0

numberToFixed :: Integer -> Number -> Maybe (Integer, Integer) #

Since: base-4.7.0.0

numberToRational :: Number -> Rational #

Since: base-4.6.0.0

numberToRangedRational :: (Int, Int) -> Number -> Maybe Rational #

Since: base-4.5.1.0

lex :: ReadP Lexeme #

expect :: Lexeme -> ReadP () #

Since: base-4.7.0.0

hsLex :: ReadP String #

Haskell lexer: returns the lexed string, rather than the lexeme

lexChar :: ReadP Char #

readIntP :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadP a #

readOctP :: (Eq a, Num a) => ReadP a #

readDecP :: (Eq a, Num a) => ReadP a #

readHexP :: (Eq a, Num a) => ReadP a #

isSymbolChar :: Char -> Bool #