Safe Haskell | None |
---|
Utilities to turn a lexer generated by Alex into a scanner that can be used by Yi.
- type AlexInput = (Char, IndexedStr)
- alexGetChar :: AlexInput -> Maybe (Char, AlexInput)
- alexInputPrevChar :: AlexInput -> Char
- data AlexState lexerState = AlexState {
- stLexer :: lexerState
- lookedOffset :: !Point
- stPosn :: !Posn
- unfoldLexer :: ((AlexState lexState, input) -> Maybe (token, (AlexState lexState, input))) -> (AlexState lexState, input) -> [(AlexState lexState, token)]
- lexScanner :: forall lexerState token. ((AlexState lexerState, AlexInput) -> Maybe (token, (AlexState lexerState, AlexInput))) -> lexerState -> Scanner Point Char -> Scanner (AlexState lexerState) token
- alexCollectChar :: AlexInput -> [Char]
- actionConst :: token -> Action lexState token
- actionAndModify :: (lexState -> lexState) -> token -> Action lexState token
- actionStringAndModify :: (lexState -> lexState) -> (String -> token) -> Action lexState token
- actionStringConst :: (String -> token) -> Action lexState token
- data Tok t = Tok {}
- tokBegin :: forall t. Tok t -> Point
- tokEnd :: forall t. Tok t -> Point
- tokFromT :: forall t. t -> Tok t
- tokRegion :: Tok t -> Region
- data Posn = Posn {}
- startPosn :: Posn
- moveStr :: Posn -> IndexedStr -> Posn
- type ASI s = (AlexState s, AlexInput)
- (+~) :: SemiNum absolute relative => absolute -> relative -> absolute
- (~-) :: SemiNum absolute relative => absolute -> absolute -> relative
- newtype Size = Size {
- fromSize :: Int
- type Stroke = Span StyleName
- tokToSpan :: Tok t -> Span t
- alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
Names expected by Alex code
Other things closely associated with the lexer
unfoldLexer :: ((AlexState lexState, input) -> Maybe (token, (AlexState lexState, input))) -> (AlexState lexState, input) -> [(AlexState lexState, token)]Source
unfold lexer function into a function that returns a stream of (state x token)
:: forall lexerState token . | |
=> ((AlexState lexerState, AlexInput) -> Maybe (token, (AlexState lexerState, AlexInput))) | A lexer |
-> lexerState | Initial user state for the lexer |
-> Scanner Point Char | |
-> Scanner (AlexState lexerState) token |
Combine a character scanner with a lexer to produce a token scanner.
May be used together with mkHighlighter
to produce a Highlighter
,
or with linearSyntaxMode
to produce a Mode
.
alexCollectChar :: AlexInput -> [Char]Source
Lexer actions
actionConst :: token -> Action lexState tokenSource
Return a constant token
actionAndModify :: (lexState -> lexState) -> token -> Action lexState tokenSource
Return a constant token, and modify the lexer state
actionStringAndModify :: (lexState -> lexState) -> (String -> token) -> Action lexState tokenSource
Convert the parsed string into a token, and also modify the lexer state
actionStringConst :: (String -> token) -> Action lexState tokenSource
Convert the parsed string into a token
Data produced by the scanner
Functor Tok | |
Eq (Tok a) | |
Show t => Show (Tok t) | |
Strokable (Tok Token) | |
Strokable (KeyValue TT) | |
Strokable (Array TT) | |
Strokable (Expr TT) | |
Strokable (VarDecAss TT) | |
Strokable (Block TT) | |
Strokable (ForContent TT) | |
Strokable (ParExpr TT) | |
Strokable (Parameters TT) | |
Strokable (Statement TT) | TODO: This code is *screaming* for some generic programming. TODO: Somehow fix Failable and failStroker to be more generic. This will make these instances much nicer and we won't have to make ad-hoc stuff like this. |
Size of a buffer region
alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)Source