parsec
parsec copied to clipboard
SourcePos: Also track a character offset
The purpose of this parameter is to have character offset into the input stream.
Currently I use the following code to keep track of the offset:
handleNewline = do
p0 <- P.getPosition
_ <- P.char '\n'
P.setPosition (P.incSourceColumn p0 1)
The downside of this addition is that while setSourceColumn
and incSourceColumn
could in principle also update the offset parameter, setSourceLine
and setSourceLine
cannot.