<div dir="ltr">thanks for your answer, exactly what I was looking for. Now I have parsers like this :<div><br></div><div><div>ifStmt :: Parser Stmt</div><div>ifStmt =</div><div>  do reserved "if"</div><div>     <b>pos <- getPosition</b></div><div>     cond  <- expression</div><div>     reserved "then"</div><div>     stmt1 <- statement</div><div>     reserved "else"</div><div>     stmt2 <- statement</div><div>     return $ If cond stmt1 stmt2 <b>pos</b></div><div><br></div><div>My AST is not fully "positioned" though as I don't get how to add position in expression (more precisely on operators).</div><div>I am using the buildExpressionParser to build expression parsers so I have</div><div><br></div><div><div>operators = [ [Prefix (reservedOp "-"   >> return (Neg ))          ]</div><div>             , [Infix  (reservedOp "*"   >> return (Binary Multiply)) AssocLeft, .....</div></div><div><br></div><div>And I dont known how to tell parsec to add a SourcePos to my operators.</div><div><br></div><div>Any suggestion please ?</div><div><br></div><div><br></div><div><br><br>Le dimanche 17 juillet 2016 19:09:32 UTC+2, Francesco Ariis a écrit :<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Sun, Jul 17, 2016 at 09:50:27AM -0700, Olivier Duhart wrote:<br>> is ther a way to get the line numbers at parsers level?<p>Hi Olivier,<br>    maybe you are looking for</p><p>    <a href="http://hackage.haskell.org/package/parsec-3.1.11/docs/Text-Parsec.html#v:getPosition" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fhackage.haskell.org%2Fpackage%2Fparsec-3.1.11%2Fdocs%2FText-Parsec.html%23v%3AgetPosition\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVzE_TS-lDNo_fVh8li_JaD6I8Kw';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fhackage.haskell.org%2Fpackage%2Fparsec-3.1.11%2Fdocs%2FText-Parsec.html%23v%3AgetPosition\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVzE_TS-lDNo_fVh8li_JaD6I8Kw';return true;">http://hackage.haskell.org/<wbr>package/parsec-3.1.11/docs/<wbr>Text-Parsec.html#v:getPosition</a></p><p>(which is very simple and used mainly for error reporting) or you could<br>just keep track of `currLine` into a State of your choice (the 's' in<br>ParsecT s ...).<br>Does that help?<br>-F<br>______________________________<wbr>_________________<br>Haskell-Cafe mailing list<br>To (un)subscribe, modify options or view archives go to:<br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fmail.haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fhaskell-cafe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH7sFgl7KfuDcDlaGGG3ip3kRaoIA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fmail.haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fhaskell-cafe\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH7sFgl7KfuDcDlaGGG3ip3kRaoIA';return true;">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>Only members subscribed via the mailman list are allowed to post.</p><p></p><p></p></blockquote></div></div></div>