Re: [Haskell-cafe] parsec: how to get end location

2010-06-14 Thread Martijn van Steenbergen
On 6/14/10 0:10, Roman Cheplyaka wrote: Of course most parsers don't consume trailing newlines. But I was writing general function to use in many places in the code which would recover the end location. In most cases it just subtracts 1 from the column number, but what if it just happened so that

Re: [Haskell-cafe] parsec: how to get end location

2010-06-14 Thread Stephen Tetley
Hi Roman You would need different behaviour for the /lexeme/ parser in Parsec.Token at least - this is the combinator that promotes a parser to also consume trailing whitespace. I suspect you would have to recode most of Parsec.Token module - the TokenParser is a parameterized module (in the sens

Re: [Haskell-cafe] parsec: how to get end location

2010-06-13 Thread David Virebayre
On Mon, Jun 14, 2010 at 12:10 AM, Roman Cheplyaka wrote: > Of course most parsers don't consume trailing newlines. But I was > writing general function to use in many places in the code which would > recover the end location. In most cases it just subtracts 1 from the > column number, but what if

Re: [Haskell-cafe] parsec: how to get end location

2010-06-13 Thread Roman Cheplyaka
* Antoine Latter [2010-06-13 16:47:28-0500] > On Sun, Jun 13, 2010 at 4:17 PM, Roman Cheplyaka wrote: > > Suppose I have some parser 'p'. I want to parse it as well as get its > > span in the text. So I could write > > > > \begin{code] > > pWithLocation = do > >  loc_start <- getPosition > >  pva

Re: [Haskell-cafe] parsec: how to get end location

2010-06-13 Thread Antoine Latter
On Sun, Jun 13, 2010 at 4:17 PM, Roman Cheplyaka wrote: > Suppose I have some parser 'p'. I want to parse it as well as get its > span in the text. So I could write > > \begin{code] > pWithLocation = do >  loc_start <- getPosition >  pval <- p >  loc_end <- getPosition >  return (pval,loc_start,lo

[Haskell-cafe] parsec: how to get end location

2010-06-13 Thread Roman Cheplyaka
Suppose I have some parser 'p'. I want to parse it as well as get its span in the text. So I could write \begin{code] pWithLocation = do loc_start <- getPosition pval <- p loc_end <- getPosition return (pval,loc_start,loc_end) \end{code} except that loc_end gives me the location _after_ '