[Haskell-cafe] Happy parsing wierdness

Mike Menzel mdmenzel at ucalgary.ca
Sun Dec 2 03:19:29 EST 2007


Hi,

I'm using the Happy parser, and I've threaded a Success/Failure 
monad-like thing through it so that if the parse succeeds, Success AST 
(AST is the datatype I want to turn my tokens into) is returned and if 
it fails, Fail String is returned (in a similar manner to how such 
threading is described in the Happy Documentation).  That is, data SorF 
a = Succeed a | Fail String.  Now, if the input is valid, I get the 
correct result (namely Success AST).  If invalid input is given (ie the 
wrong token is encountered), happyError is triggered correctly, and and 
a Fail String is returned.  However, if incomplete info is given (let's 
say a rule is expecting two tokens, and only one is read before the end 
of input), the parser generated by happy throws error("Reading EOF").  I 
have defined happyError on both the empty list of tokens, and the 
non-empty list as returning a Fail String.  I'm stumped as to why I get 
this error.

Any advice?

Best,

Mike.


More information about the Haskell-Cafe mailing list