Index Home About Blog
From: henry@spsystems.net (Henry Spencer)
Newsgroups: comp.compilers
Subject: Re: Compiler Compiler Compiler
Date: 10 Apr 2001 01:48:25 -0400
Keywords: tools

Joachim Durchholz <joachim.durchholz@gmx.de> wrote:
>There are other differences that might be more relevant.
>For example, LL parsers have been consistently reported to produce
>better error reporting. Does anybody know whether that's a historic
>accident, or is there something in LL parsing that makes it inherently
>easier to add useful error actions to LL parsers?

In a general sense, LL parsing inherently has an easier time with
error handling, because a top-down parse intrinsically knows much more
about the *context* of an error.  The parser knows exactly what it
thought it was parsing, and how that was supposed to fit into the
surroundings, whereas a bottom-up parser is more or less discovering
this as it goes.

(This doesn't mean that any particular LL parsing tool makes error
handling easy, mind you.)

This knowledge of context is also why semantics are often easier to fit
into LL.  The flip side, of course, is more limited parsing power, because
LL can handle only grammars where it *can* sort out the exact context in
advance.  LR, which discovers what's going on along the way, can deal with
constructs whose overall plan has to be figured out gradually.
--
When failure is not an option, success  |  Henry Spencer   henry@spsystems.net
can get expensive.   -- Peter Stibrany  |      (aka henry@zoo.toronto.edu)

Index Home About Blog