
Hi, Is there a way to get source position[1] information from parsec while defining a parser? It surely knows about source positions, as they are used while reporting a parsing error. data Identifier = Identifier String SourcePos pIdentifier :: Parser Identifier pIdentifier = do pos <- ?? s <- pString return (Identifier s pos) [1] http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parse... Thanks in advance, Ozgur

On 7 April 2011 17:22, Ozgur Akgun
Is there a way to get source position[1] information from parsec while defining a parser? It surely knows about source positions, as they are used while reporting a parsing error.
http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parse... http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parse...

Thanks!
On 7 April 2011 16:27, Christopher Done
On 7 April 2011 17:22, Ozgur Akgun
wrote: Is there a way to get source position[1] information from parsec while defining a parser? It surely knows about source positions, as they are used while reporting a parsing error.
http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parse... http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parse...
-- Ozgur Akgun

On Thursday 07 April 2011 17:22:56, Ozgur Akgun wrote:
Hi,
Is there a way to get source position[1] information from parsec while defining a parser? It surely knows about source positions, as they are used while reporting a parsing error.
data Identifier = Identifier String SourcePos
pIdentifier :: Parser Identifier pIdentifier = do pos <- ??
pos <- getPosition
s <- pString return (Identifier s pos)
[1] http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-P arsec.html#t:SourcePos
Thanks in advance,
Ozgur
participants (3)
-
Christopher Done
-
Daniel Fischer
-
Ozgur Akgun