yi-0.6.2.4: The Haskell-Scriptable Editor

Yi.Lexer.Alex

Contents

Description

Utilities to turn a lexer generated by Alex into a scanner that can be used by Yi.

Synopsis

Names expected by Alex code

type AlexInput = (Char, IndexedStr)Source

Other things closely associated with the lexer

data AlexState lexerState Source

Lexer state

Constructors

AlexState 

Fields

stLexer :: lexerState
 
lookedOffset :: !Point
 
stPosn :: !Posn
 

Instances

Show lexerState => Show (AlexState lexerState) 

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)

lexScannerSource

Arguments

:: 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.

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

data Tok t Source

Constructors

Tok 

Fields

tokT :: t
 
tokLen :: Size
 
tokPosn :: Posn
 

Instances

tokBegin :: forall t. Tok t -> PointSource

tokEnd :: forall t. Tok t -> PointSource

tokFromT :: forall t. t -> Tok tSource

data Posn Source

Constructors

Posn 

Fields

posnOfs :: !Point
 
posnLine :: !Int
 
posnCol :: !Int
 

Instances

moveStr :: Posn -> IndexedStr -> PosnSource

(+~) :: SemiNum absolute relative => absolute -> relative -> absoluteSource

(~-) :: SemiNum absolute relative => absolute -> absolute -> relativeSource

newtype Size Source

Size of a buffer region

Constructors

Size 

Fields

fromSize :: Int