Safe Haskell | None |
---|
- class Allocatable b a where
- allocTokens :: IsToken a => b -> [a] -> LayoutTree a
- renderLayoutTree :: IsToken a => LayoutTree a -> String
- class (Show a, HasLoc a) => IsToken a where
- tokenLen :: a -> Int
- isComment :: a -> Bool
- isEmpty :: a -> Bool
- mkZeroToken :: a
- isDo :: a -> Bool
- isElse :: a -> Bool
- isIn :: a -> Bool
- isLet :: a -> Bool
- isOf :: a -> Bool
- isThen :: a -> Bool
- isWhere :: a -> Bool
- tokenToString :: a -> String
- showTokenStream :: [a] -> String
- lexStringToTokens :: SimpSpan -> String -> [a]
- markToken :: a -> a
- isMarked :: a -> Bool
- class HasLoc a where
Creating a LayoutTree
This should only be required by impementors of token utils backends
class Allocatable b a whereSource
allocTokens :: IsToken a => b -> [a] -> LayoutTree aSource
Construct a LayoutTree
from a Haskell AST and a stream of tokens.
Allocatable ParsedSource GhcPosToken | |
Allocatable (Module SrcSpanInfo) (Loc TuToken) | This instance is the purpose of this module |
Eliminating a LayoutTree
This should only be required by impementors of token utils backends
renderLayoutTree :: IsToken a => LayoutTree a -> StringSource
Properties required for a LayoutTree
This should only be required by impementors of token utils backends
class (Show a, HasLoc a) => IsToken a whereSource
The IsToken class captures the different token type in use. For
GHC it represents the type returned by getRichTokenStream
,
namely [(GHC.Located GHC.Token, String)]
For haskell-src-exts this is the reult of lexTokenStream
, namely `[HSE.Loc HSE.Token]`
tokenLen returns the length of the string representation of the token, not just the difference in the location, as the string may have changed without the position being updated, e.g. in a renaming
Zero-length tokens, as appear in GHC as markers
mkZeroToken :: aSource
tokenToString :: a -> StringSource
showTokenStream :: [a] -> StringSource
lexStringToTokens :: SimpSpan -> String -> [a]Source
Create a stream of tokens from source, with first token start at given location
Mark a token so that it can be use to trigger layout checking later when the toks are retrieved