Hi Gerd,
despite SourcePos being abstract, it can be fully manipulated using newPos.
import Text.ParserCombinators.Parsec.Pos
If you can compute the positions from your Tok-stream then you may
consider using "tokenPrim" and work with "GenParser Tok () a"
HTH Christian
Gerd M wrote:
I'm trying to use parsec for parsing a custom input stream. As far as I
understood the manual correctly I need to define the primitive parser:
type MyParser a = GenParser (SourcePos,Tok) () a
mytoken :: (Tok -> Maybe a) -> MyParser a
mytoken test
= token showToken posToken testToken
where
showToken (pos,tok) = show tok
posToken (pos,tok) = pos
testToken (pos,tok) = test tok
The problem is, since SourcePos is an abstract datatype, how can I
actually run this parser without explicitly using values of type
SourcePos in the input stream?
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe