base-4.5.1.0: Basic libraries

Portability | non-portable (uses Text.ParserCombinators.ReadP)
Stability | provisional
Maintainer | libraries@haskell.org
Safe Haskell | Trustworthy

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
  - | Int Integer
  - | Rat Rational
  - | EOF
- data Lexeme'
  - = Ident' String
  - | Punc' String
  - | Symbol' String
  - | Number Number
- numberToInteger :: Number -> Maybe Integer
- numberToRangedRational :: (Int, Int) -> Number -> Maybe Rational
- lex :: ReadP Lexeme
- lex' :: ReadP Lexeme'
- 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

# Documentation

data Lexeme

Haskell lexemes.

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. `>>`, `:%`
Int Integer | Integer literal
Rat Rational | Floating point literal
EOF |

Instances

Eq Lexeme |
Read Lexeme |
Show Lexeme |

data Lexeme'

Constructors

Ident' String |
Punc' String |
Symbol' String |
Number Number |

Instances

Eq Lexeme' |
Show Lexeme' |

numberToInteger :: Number -> Maybe Integer

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

lex :: ReadP Lexeme

lex' :: ReadP Lexeme'

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