haskell-token-utils-0.0.0.6: Utilities to tie up tokens to an AST

Safe HaskellNone

Language.Haskell.TokenUtils.API

Contents

Synopsis

Creating a LayoutTree

This should only be required by impementors of token utils backends

class Allocatable b a whereSource

Methods

allocTokens :: IsToken a => b -> [a] -> LayoutTree aSource

Construct a LayoutTree from a Haskell AST and a stream of tokens.

Instances

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

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]`

Methods

tokenLen :: a -> IntSource

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

isComment :: a -> BoolSource

isEmpty :: a -> BoolSource

Zero-length tokens, as appear in GHC as markers

mkZeroToken :: aSource

isDo :: a -> BoolSource

isElse :: a -> BoolSource

isIn :: a -> BoolSource

isLet :: a -> BoolSource

isOf :: a -> BoolSource

isThen :: a -> BoolSource

isWhere :: a -> BoolSource

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

markToken :: a -> aSource

Mark a token so that it can be use to trigger layout checking later when the toks are retrieved

isMarked :: a -> BoolSource

Instances

IsToken (Loc TuToken) 
IsToken (Located Token, String) 

class HasLoc a whereSource

Instances

HasLoc SrcSpan 
HasLoc ForestSpan 
HasLoc SrcSpan 
HasLoc (Loc a) 
HasLoc (Entry a) 
HasLoc (Located a) 
HasLoc (Located Token, String)