Re: Recursive-descent C parser WANTED

henry@zoo.toronto.edu (Henry Spencer)
Thu, 27 Feb 1992 22:57:40 GMT

          From comp.compilers

Related articles
Re: Recursive-descent C parser WANTED doug@netcom.com (1992-02-27)
Re: Recursive-descent C parser WANTED bliss@sp64.csrd.uiuc.edu (1992-02-27)
Re: Recursive-descent C parser WANTED henry@zoo.toronto.edu (1992-02-27)
Re: Recursive-descent C parser WANTED wjw@eb.ele.tue.nl (1992-03-04)
| List of all articles for this month |

Newsgroups: comp.compilers
From: henry@zoo.toronto.edu (Henry Spencer)
Keywords: errors, LL(1)
Organization: U of Toronto Zoology
References: <1776@wrdis01.af.mil> 92-02-126
Date: Thu, 27 Feb 1992 22:57:40 GMT

In article 92-02-126 doug@netcom.com (Doug Merritt) writes:
>The added bonus to parser generators is that it is possible to add
>variations on automated Graham-Rhodes error recovery to them...


Despite popular misconceptions, there is no great difficulty in adding
automated error recovery to recursive-descent parsers. If the parser
tells the scanner what sorts of tokens it's looking for, rather than
just saying "give me the next token", a fairly effective error-recovery
strategy can be implemented as a layer in between scanner and parser.
I did this in an experimental C parser.


(The basic strategy is to give the parser what it wants, and if that
wasn't what showed up in the input stream, complain. Some simple
heuristics work fairly well for resynchronization and avoiding infinite
loops. The code is simple and the cost is minimal.)
--
| Henry Spencer @ U of Toronto Zoology, henry@zoo.toronto.edu utzoo!henry
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.