[Haskell-cafe] Parsing problem

Eric eeoam at ukfsn.org
Thu Jun 26 06:40:41 EDT 2008


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.



More information about the Haskell-Cafe mailing list