Copyright | (c) Sergey Vinokurov 2019 |
---|---|
Safe Haskell | None |
Language | Haskell98 |
All the types and functions needed to make lexer run:
- AlexInput
- primary workhorse, an optimized representation of input
stream as a pointer to utf8 bytes and our position within it.
- Lexer monad AlexM
- a monad (self-explanatory) with state that describes
current lexing context.
- AlexState
- state of the lexing monad, maintains current Alex code,
comment depth, quasiquoter depth, indentation size, whether we're in
a literate mode (and in which one) or vanilla mode and whether there
are any TH quasiquotes present till the end of file.
All the functions are to do with
Synopsis
- data AlexState = AlexState {
- asInput :: !AlexInput
- asIntStore :: !Word64
- asContextStack :: [Context]
- mkAlexState :: LitMode Void -> AlexCode -> AlexInput -> AlexState
- alexEnterBirdLiterateEnv :: MonadState AlexState m => m ()
- alexEnterLiterateLatexEnv :: MonadState AlexState m => m ()
- alexExitLiterateEnv :: MonadState AlexState m => m ()
- pushContext :: MonadState AlexState m => Context -> m ()
- modifyCommentDepth :: MonadState AlexState m => (Int16 -> Int16) -> m Int16
- modifyQuasiquoterDepth :: MonadState AlexState m => (Int16 -> Int16) -> m Int16
- modifyPreprocessorDepth :: MonadState AlexState m => (Int16 -> Int16) -> m Int16
- addIndentationSize :: MonadState AlexState m => Int16 -> m ()
- checkQuasiQuoteEndPresent :: Ptr Word8 -> Bool
- type AlexM = WriterT [(AlexInput, TokenVal)] (State AlexState)
- runAlexM :: FilePath -> Bool -> LitMode Void -> AlexCode -> ByteString -> AlexM a -> (a, [Token])
- alexSetInput :: MonadState AlexState m => AlexInput -> m ()
- alexSetNextCode :: MonadState AlexState m => AlexCode -> m ()
- data AlexInput = AlexInput {
- aiPtr :: !(Ptr Word8)
- aiIntStore :: !Word64
- aiLineL :: Lens' AlexInput Line
- takeText :: AlexInput -> Int -> Text
- countInputSpace :: AlexInput -> Int -> Int
- extractDefineOrLetName :: AlexInput -> Int -> Text
- dropUntilNL :: AlexInput -> AlexInput
- dropUntilUnescapedNL :: AlexInput -> AlexInput
- dropUntilNLOr :: Word8 -> AlexInput -> AlexInput
- dropUntilNLOrEither :: Word8 -> Word8 -> AlexInput -> AlexInput
- unsafeTextHeadAscii :: Ptr Word8 -> Word8
- unsafeTextHeadOfTailAscii :: Ptr Word8 -> Word8
- unsafeTextHead :: Ptr Word8 -> Char
- utf8BS :: Int -> Ptr Word8 -> ByteString
- asCodeL :: Lens' AlexState AlexCode
- asCommentDepthL :: Lens' AlexState Int16
- asQuasiquoterDepthL :: Lens' AlexState Int16
- asIndentationSizeL :: Lens' AlexState Int16
- asPreprocessorDepthL :: Lens' AlexState Int16
- asLiterateLocL :: Lens' AlexState (LitMode LitStyle)
- asHaveQQEndL :: Lens' AlexState (Maybe Bool)
- alexInputPrevChar :: AlexInput -> Char
- alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
Documentation
AlexState | |
|
alexEnterBirdLiterateEnv :: MonadState AlexState m => m () Source #
alexEnterLiterateLatexEnv :: MonadState AlexState m => m () Source #
alexExitLiterateEnv :: MonadState AlexState m => m () Source #
pushContext :: MonadState AlexState m => Context -> m () Source #
modifyCommentDepth :: MonadState AlexState m => (Int16 -> Int16) -> m Int16 Source #
modifyQuasiquoterDepth :: MonadState AlexState m => (Int16 -> Int16) -> m Int16 Source #
modifyPreprocessorDepth :: MonadState AlexState m => (Int16 -> Int16) -> m Int16 Source #
addIndentationSize :: MonadState AlexState m => Int16 -> m () Source #
runAlexM :: FilePath -> Bool -> LitMode Void -> AlexCode -> ByteString -> AlexM a -> (a, [Token]) Source #
alexSetInput :: MonadState AlexState m => AlexInput -> m () Source #
alexSetNextCode :: MonadState AlexState m => AlexCode -> m () Source #
AlexInput | |
|
dropUntilNL :: AlexInput -> AlexInput Source #
dropUntilNLOrEither :: Word8 -> Word8 -> AlexInput -> AlexInput Source #
Drop until either of two bytes.
asCodeL :: Lens' AlexState AlexCode Source #
Current Alex state the lexer is in. E.g. comments, string, TH quasiquoter or vanilla toplevel mode.
asLiterateLocL :: Lens' AlexState (LitMode LitStyle) Source #
Whether we're in bird-style or latex-style literate environment
Alex interface
alexInputPrevChar :: AlexInput -> Char Source #