some bugs in Language.Haskell.Parser

The program:
x = v where v = 2 where
main = putStrLn "hello world"
parses as:
x = v where v = 2 main = putStrLn "hello world"
which is incorrect. (in general, the parser can't deal with empty where clauses) as in:
x = 'a' where class A a where
this gives a parse error because it's waiting for a real declaration inside of the first where clause. it also can't deal with empty statements:
v = do {return 'a';;}
should be accepted but results in a parser error. in Parser.ly, this essentially boils down to the fact that 'decllist' must be nonempty, but in certain circumstances (all?), it really *can* be empty. the last error (with statements), can be fixed by replacing line 637-639:
stmtlist :: { [HsStmt] } : '{' stmts '}' { $2 } | open stmts close { $2 }
with:
stmtlist :: { [HsStmt] } : '{' stmts optsemis '}' { $2 } | open stmts optsemis close { $2 }
i believe. - Hal -- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume

On Sat, Jul 12, 2003 at 03:08:42PM -0700, Hal Daume wrote:
The program:
x = v where v = 2 where
main = putStrLn "hello world"
parses as:
x = v where v = 2 main = putStrLn "hello world"
which is incorrect.
(in general, the parser can't deal with empty where clauses) as in:
x = 'a' where class A a where
this gives a parse error because it's waiting for a real declaration inside of the first where clause.
Thanks for the report. All these are due to the implementation of layout omitting the rule about inserting empty braces (now fixed in CVS).
it also can't deal with empty statements:
v = do {return 'a';;}
should be accepted but results in a parser error.
This isn't Haskell.
participants (2)
-
Hal Daume
-
Ross Paterson