[Haskell-cafe] parsec get line number of lexems

Francesco Ariis fa-ml at ariis.it
Sun Jul 17 17:04:26 UTC 2016


On Sun, Jul 17, 2016 at 09:50:27AM -0700, Olivier Duhart wrote:
> is ther a way to get the line numbers at parsers level?

Hi Olivier,
    maybe you are looking for

    http://hackage.haskell.org/package/parsec-3.1.11/docs/Text-Parsec.html#v:getPosition

(which is very simple and used mainly for error reporting) or you could
just keep track of `currLine` into a State of your choice (the 's' in
ParsecT s ...).
Does that help?
-F


More information about the Haskell-Cafe mailing list