| Copyright | (c) Hangil Kim 2026 Kairon Johnson 2026 Leonidas Sallos 2026 Oscar Abelanet 2026 |
|---|---|
| License | MIT |
| Maintainer | kimhang@oregonstate.edu |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
LH.Text.Parser.Monad
Description
This module provides the parser monad for Layered Haskell. Consequently, it includes definitions for a custom Alex wrapper and a representation of errors and state.
Synopsis
- data AlexInput = AlexInput {}
- alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
- alexInputPrevChar :: AlexInput -> Char
- newtype LHsParser a = LHsParser (StateT LHsState (Either LHsTextError) a)
- runLHsParser :: LHsParser a -> Text -> Either LHsTextError a
- data LHsState = LHsState {}
- getInput :: LHsParser AlexInput
- setInput :: AlexInput -> LHsParser ()
- data LHsStcd = LHsStcd !Int !LHsPos
- getStcd :: LHsParser Int
- pushStcd :: Int -> LHsPos -> LHsParser ()
- popStcd :: LHsParser ()
- getInnermostLayout :: LHsParser (Maybe Int)
- pushLayout :: Int -> LHsParser ()
- popLayout :: LHsParser ()
- data LHsTextError
A wrapper for Alex
A representation of the current state of the input stream being tokenized.
alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) Source #
Fetches the next byte from the input and returns an updated input.
alexInputPrevChar :: AlexInput -> Char Source #
Returns the character previously read from the input.
The parser monad
A parser monad with state (LHsState) and errors (LHsTextError).
Constructors
| LHsParser (StateT LHsState (Either LHsTextError) a) |
Instances
| Applicative LHsParser Source # | |
| Functor LHsParser Source # | |
| Monad LHsParser Source # | |
| MonadError LHsTextError LHsParser Source # | |
Defined in LH.Text.Parser.Monad Methods throwError :: LHsTextError -> LHsParser a # catchError :: LHsParser a -> (LHsTextError -> LHsParser a) -> LHsParser a # | |
| MonadState LHsState LHsParser Source # | |
runLHsParser :: LHsParser a -> Text -> Either LHsTextError a Source #
State
The parser state, which keeps track of the current input and two stacks.
Constructors
| LHsState | |
Startcodes
A startcode paired with the position at which it was pushed onto the stack.
Layout
getInnermostLayout :: LHsParser (Maybe Int) Source #
Retrieves the column of the innermost open layout block, if present.
pushLayout :: Int -> LHsParser () Source #
Pushes a column of an open layout block onto the stack.
Errors
data LHsTextError Source #
A text-related error emitted by the lexer or parser.
Constructors
| LexicalError !LHsPos !Text | A lexical error emitted by Alex. |
| UnclosedComment !LHsPos | An unclosed multi-line comment error emitted by Alex. |
| ParseError !LHsSpan !LHsToken | A parse error emitted by Happy. The first argument indicates where an unexpected token starts and ends in the source. |
Instances
| LHsError LHsTextError Source # | |
Defined in LH.Text.Parser.Monad Methods renderError :: FilePath -> Text -> LHsTextError -> Text Source # buildError :: FilePath -> LHsTextError -> Errata Source # | |
| Show LHsTextError Source # | |
Defined in LH.Text.Parser.Monad Methods showsPrec :: Int -> LHsTextError -> ShowS # show :: LHsTextError -> String # showList :: [LHsTextError] -> ShowS # | |
| Eq LHsTextError Source # | |
Defined in LH.Text.Parser.Monad | |
| MonadError LHsTextError LHsParser Source # | |
Defined in LH.Text.Parser.Monad Methods throwError :: LHsTextError -> LHsParser a # catchError :: LHsParser a -> (LHsTextError -> LHsParser a) -> LHsParser a # | |