yi-0.7.2: The Haskell-Scriptable Editor

Safe HaskellNone

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

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.

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

Eq Posn 
Ord Posn 
Show Posn 
Ix Posn 

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