Add api to begin and end a span of source code

This commit is contained in:
Ng Zhi An 2018-06-12 21:56:53 -07:00
parent 8ff35fb4af
commit 1699c9e9ba
1 changed files with 21 additions and 0 deletions

View File

@ -188,6 +188,27 @@ getNextId = do
pos <- getPosition
getNextIdAt pos
data IncompleteInterval = IncompleteInterval SourcePos
startSpan = IncompleteInterval <$> getPosition
endSpan (IncompleteInterval start) = do
id <- getNextIdAt start
endPos <- getPosition
state <- getState
let setEndPos (start, _) = Just (start, Just endPos)
let newMap = Map.update setEndPos id (positionMap state)
putState $ state {
lastId = id,
positionMap = newMap
}
return id
zeroWidthSpan = do
start <- startSpan
id <- endSpan start
return id
endPosOfStartId s = do
endPos <- getPosition
state <- getState