thanks for your answer, exactly what I was looking for. Now I have parsers like this :ifStmt :: Parser StmtifStmt =do reserved "if"pos <- getPositioncond <- expressionreserved "then"stmt1 <- statementreserved "else"stmt2 <- statementreturn $ If cond stmt1 stmt2 posMy AST is not fully "positioned" though as I don't get how to add position in expression (more precisely on operators).I am using the buildExpressionParser to build expression parsers so I haveoperators = [ [Prefix (reservedOp "-" >> return (Neg )) ], [Infix (reservedOp "*" >> return (Binary Multiply)) AssocLeft, .....And I dont known how to tell parsec to add a SourcePos to my operators.Any suggestion please ?
Le dimanche 17 juillet 2016 19:09:32 UTC+2, Francesco Ariis a écrit :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 forhttp://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
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.