From: | Hans Aberg <haberg_20080406@math.su.se> |
Newsgroups: | comp.compilers |
Date: | Tue, 16 Feb 2010 18:37:39 +0100 |
Organization: | A noiseless patient Spider |
References: | 10-02-024 10-02-029 10-02-047 10-02-055 10-02-062 10-02-064 |
Keywords: | errors, LALR |
Posted-Date: | 16 Feb 2010 19:14:23 EST |
Stephen Horne wrote:
> In LR(1), it is *easy* to give a message of the form "expected one of
> <token list>, but <token> was found." - the set of possible next
> tokens is part of the description of each state, and this can easily
> be traced back to a set of productions (or else the parser could never
> know when/what to reduce).
>
> Yacc and Bison don't support reporting errors in this form AFAIK, but
> the tool isn't the same as the algorithm the tool uses.
Those use LALR(1), though LR(1) support may be in the works for Bison,
which compacts the states in such a way that when an error token
appears, some extra reductions may take place before issuing the error.
It means that one must implement some search technique to get it right
if sticking to an algorithm doing such kind of compaction.
Unfortunately, what is actually implemented as LR(1) may in reality not
be pure, but applying a similar state compaction technique, with the
focus on covering the larger language class, having the same error
reporting problem. It is unclear though what this means in practice.
Hans
Return to the
comp.compilers page.
Search the
comp.compilers archives again.