parsec icon indicating copy to clipboard operation
parsec copied to clipboard

SourcePos: Also track a character offset

Open sjakobi opened this issue 6 years ago • 0 comments

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.

sjakobi avatar May 16 '18 11:05 sjakobi