Re: Q: Error detection/recovery in LEX/YACC (Help)

neitzel@ips.cs.tu-bs.de (Martin Neitzel)
Thu, 27 Jan 1994 18:03:50 GMT

          From comp.compilers

Related articles
Q: Error detection/recovery in LEX/YACC (Help) friesend@herald.usask.ca (1993-12-17)
Re: Q: Error detection/recovery in LEX/YACC (Help) collison@osf.org (1993-12-20)
Re: Q: Error detection/recovery in LEX/YACC (Help) neitzel@ips.cs.tu-bs.de (1993-12-20)
re: Q: Error detection/recovery in LEX/YACC (Help) bdarr@atr-2s.hac.com (1993-12-21)
Re: Q: Error detection/recovery in LEX/YACC (Help) neitzel@ips.cs.tu-bs.de (1993-12-23)
Re: Q: Error detection/recovery in LEX/YACC (Help) hage@netcom.com (1994-01-18)
Re: Q: Error detection/recovery in LEX/YACC (Help) neitzel@ips.cs.tu-bs.de (1994-01-27)
| List of all articles for this month |
Newsgroups: comp.compilers
From: neitzel@ips.cs.tu-bs.de (Martin Neitzel)
Keywords: Lisp, parse, yacc
Organization: Inst. f. Informatik, TU Braunschweig, FRG
References: 93-12-091 94-01-093
Date: Thu, 27 Jan 1994 18:03:50 GMT

>>>Carl Hage:
CH> Is there a good way to handle error recovery in lex/yacc
CH> for a LISP like language of the form (keyword (keyword token)
CH> ... ) where recovery is triggered at the balanced parenthesis?


I don't know how much more structure than '(keyword ... )' has your
language at hand has to offer, but:


"Lisp like language" essentially means your grammar is nothing more than
nested lists. Parsing nested lists itself is trivial, you need nothing
more than your {atom, '(', ')'}-lexer and a level counter.


Unbalanced parentheses are the _only_ kind of errors you can have at all.
Good recovery would mean properly re-balancing '(keyword's with ')'s at
the point of error, but you lack the neccessary syntactic sugar to do
this. That's what the Simplicity Of Lisp is about... ;-) (Now you see
what Algol68 funnyisms a la ".case ... .esac" were good for. rof.)


Your only option for doing better recovery would be to concentrate on
semantic issues. ("Hey, these symbols come from the outer environment.
Perhaps a ')' was missing." "(FOO wants an even number of args." "(BAR
takes only numerical args." ...)


These things are clearly beyond the scope of the lex/yacc parsing engines
themselves.
Martin Neitzel
--


Post a followup to this message

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