
26 Jun
2008
26 Jun
'08
9:54 a.m.
Am Donnerstag, 26. Juni 2008 12:40 schrieb Eric:
Hi all,
I'm using the Parsec library to parse the following grammar
expr = atom+ atom = integer | var | (expr)
The input to the parser is a list of (Token, SourcePos). I have the following code for atom:
atom = try variable <|> try integerr <|> do{sat(== Reserved "("); (e,pos) <- expression; sat(==Reserved ")"); return (e,pos)}
sat p = do (t,pos) <- item if p t then return(t,pos) else pzero
When I run the code on the input "(_ineg_ 0)" the parser fails, but removing
sat(==Reserved ")")
and it succeeds. Can any one see why?
E.
What does the tokeniser return? I would have to see more of the code to diagnose it. Cheers, Daniel