| Copyright | (C) 2016-2025 David M. Johnson (@dmjio) |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Util.Lexer
Contents
Description
Synopsis
- newtype Lexer token = Lexer {
- runLexer :: Stream -> Either LexerError (token, Stream)
- data Stream = Stream {}
- data Located token = Located {}
- data Location = Location {}
- data LexerError
- getStartColumn :: Location -> Int
- zeroLocation :: Location
- initialLocation :: Location
- mkStream :: MisoString -> Stream
- oops :: Lexer token
- streamError :: Stream -> LexerError
- string :: MisoString -> Lexer MisoString
- string' :: String -> Lexer String
- char :: Char -> Lexer Char
- satisfy :: (Char -> Bool) -> Lexer Char
- peek :: Lexer (Maybe Char)
- getInput :: Lexer Stream
- putInput :: Stream -> Lexer ()
- getLocation :: Lexer Location
- setLocation :: Location -> Lexer ()
- modifyInput :: (Stream -> Stream) -> Lexer ()
- withLocation :: ToMisoString token => Lexer token -> Lexer (Located token)
Types
A Lexer is a state monad with optional failure the abides by the
maximal munch rule in its Alternative instance.
A Stream of text used as input to lexing
Constructors
| Stream | |
Fields
| |
Type to hold the location (line and column) of a Token
data LexerError Source #
Potential errors during lexing
Constructors
| LexerError MisoString Location | |
| UnexpectedEOF Location |
Instances
| Show LexerError Source # | |
Defined in Miso.Util.Lexer Methods showsPrec :: Int -> LexerError -> ShowS # show :: LexerError -> String # showList :: [LexerError] -> ShowS # | |
| Eq LexerError Source # | |
Defined in Miso.Util.Lexer | |
Combinators
zeroLocation :: Location Source #
Empty Location
initialLocation :: Location Source #
Initial Location
streamError :: Stream -> LexerError Source #
Smart constructor for LexerError
string :: MisoString -> Lexer MisoString Source #
Lexer combinator for matching a MisoString
peek :: Lexer (Maybe Char) Source #
Fetches the first character in the Stream, does not consume input
withLocation :: ToMisoString token => Lexer token -> Lexer (Located token) Source #