From: "David G. Andersen" Date: 2004-11-14T12:22:02+09:00 Subject: Re: smarter parser errors? On Sun, Nov 14, 2004 at 08:08:17AM +0900, Ferenc Engard scribed: > Hi all, > > I have a large ruby project (>40 files, >10k rows), and whenever I make > a syntax error somewhere (e.g. swap an 'end' and a '}' token), I always > get the same error, dozens of files away, in an END block, that a given > constant is not defined. > > Isn't it possible to detect such errors by the parser/lexer, and give a > helpful error message? I share your pain. The error messages are often pretty hard to trace. Part of my problem is that emacs is better at matching braces than it is at matching "do" "end" statements -- actually, does anyone know of a cute way to get emacs to do something intelligent with these as far as automatically figuring out which statement a particular "end" matches? The best answer I've come up with so far is the "lots of small unit tests" one that other people will probably suggest. Just having a test that ensures the sanity of each file, or small chunks of each file, is often pretty helpful, even if they're not super-in-depth-xp-like-tests (tm). I got pretty lazy with the test cases for my database interface code, since I didn't want to bother with a surrogate - the test file has exactly four assertions, but it's still remarkably useful to just make sure that the file "compiles" (er, whatever) properly. -Dave -- work: dga@lcs.mit.edu me: dga@pobox.com MIT Laboratory for Computer Science http://www.angio.net/