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

Safe HaskellSafe-Inferred

Language.Haskell.TokenUtils.Utils

Contents

Synopsis

Documentation

splitToks :: IsToken a => (SimpPos, SimpPos) -> [a] -> ([a], [a], [a])Source

Split the token stream into three parts: the tokens before the startPos, the tokens between startPos and endPos, and the tokens after endPos. Note: The startPos and endPos refer to the startPos of a token only. So a single token will have the same startPos and endPos NO^^^^

ghead :: String -> [a] -> aSource

glast :: String -> [a] -> aSource

gtail :: String -> [a] -> [a]Source

gfromJust :: [Char] -> Maybe a -> aSource

splitToksIncComments :: IsToken a => (SimpPos, SimpPos) -> [a] -> ([a], [a], [a])Source

Split the given tokens to include the comments belonging to the span.

splitToksForList :: (IsToken a, HasLoc b) => [b] -> [a] -> ([a], [a], [a])Source

Split the given tokens into the ones that occur prior to the start of the list and ones that occur after

allocList :: (IsToken a, HasLoc b) => [b] -> [a] -> (b -> [a] -> [LayoutTree a]) -> [LayoutTree a]Source

startEndLocIncComments' :: IsToken a => [a] -> (SimpPos, SimpPos) -> (SimpPos, SimpPos)Source

Get the start&end location of t in the token stream, then extend the start and end location to cover the preceding and following comments.

ForestSpan conversions

forestSpanToSimpPos :: ForestSpan -> (SimpPos, SimpPos)Source

Strip out the version markers

ForestSpans

forestSpanVersions :: ForestSpan -> (Int, Int)Source

Gets the version numbers

forestSpanAstVersions :: ForestSpan -> (Int, Int)Source

Gets the AST tree numbers

forestSpanLenChangedFlags :: ForestSpan -> (Bool, Bool)Source

Gets the SpanLengthChanged flags

forestSpanVersionNotSet :: ForestSpan -> BoolSource

Checks if the version is zero in both positions

forestPosVersionSet :: ForestPos -> BoolSource

Checks if the version is non-zero

forestPosAstVersionSet :: ForestPos -> BoolSource

Checks if the AST version is non-zero

forestPosVersionNotSet :: ForestPos -> BoolSource

Checks if the version is zero

treeIdIntoForestSpan :: TreeId -> ForestSpan -> ForestSpanSource

Puts a TreeId into a forestSpan

spanContains :: ForestSpan -> ForestSpan -> BoolSource

Does the first span contain the second? Takes cognisance of the various flags a ForestSpan can have. NOTE: This function relies on the Eq instance for ForestLine

forestSpanVersionSet :: ForestSpan -> BoolSource

Checks if the version is non-zero in either position

treeStartEnd :: Tree (Entry a) -> ForestSpanSource

Get the start and end position of a Tree treeStartEnd :: Tree Entry -> (SimpPos,SimpPos) treeStartEnd (Node (Entry sspan _) _) = (getGhcLoc sspan,getGhcLocEnd sspan)

groupTokensByLine :: IsToken a => [a] -> [[a]]Source

increaseSrcSpan :: IsToken a => SimpPos -> a -> aSource

Shift the whole token by the given offset

addOffsetToToks :: IsToken a => SimpPos -> [a] -> [a]Source

Add a constant line and column offset to a span of tokens

Spans

combineSpans :: ForestSpan -> ForestSpan -> ForestSpanSource

ForestSpan version of GHC combineSrcSpans

nonCommentSpan :: IsToken a => [a] -> (SimpPos, SimpPos)Source

Extract the start and end position of a span, without any leading or trailing comments

drawing the various trees

drawTreeEntry :: Tree (Entry a) -> StringSource

Neat 2-dimensional drawing of a tree.

drawForestEntry :: Forest (Entry a) -> StringSource

Neat 2-dimensional drawing of a forest.

drawTokenCache :: IsToken a => TokenCache a -> StringSource

Call drawTreeEntry on the entire token cache

drawTokenCacheDetailed :: IsToken a => TokenCache a -> StringSource

Call drawTreeEntry on the entire token cache

divideComments :: IsToken a => Int -> Int -> [a] -> ([a], [a])Source

Split a set of comment tokens into the ones that belong with the startLine and those that belong with the endLine