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) |
Newsgroups: | comp.compilers |
From: | hage@netcom.com (Carl Hage) |
Keywords: | Lisp, parse, yacc, question |
Organization: | Various Places |
References: | 93-12-091 |
Date: | Tue, 18 Jan 1994 08:19:49 GMT |
bdarr@atr-2s.hac.com (Byron Darrah) writes:
: Darryl Friesen writes:
:
: >I need a little help with error detection/recovery/repair in either or
: >both of LEX and YACC (a little snippet of code, even just a few
: >productions, would be tremendously appreciated! :).
:
: Here is a yacc production that uses the special error symbol to trap
: parsing errors in a semicolon-terminated statement (as in C):
:
: Statement : Stmt semicolon_tok
: | error semicolon_tok
: ;
Is there a good way to handle error recovery in lex/yacc for a LISP like
language of the form (keyword (keyword token) ... ) where recovery is
triggered at the balanced parenthesis?
If the lexical analysis returns KEYWD for "(keyword", would you need
to add an error token on each production? E.g.
name: KEYWD1 ... ')'
| KEYWD2 ... ')'
...
| error ')'
;
Is there are easier way to do this like
name: KEYWD1 ... endp
| KEYWD2 ... endp
;
endp: ')'
| error ')'
;
Would the best way to skip tokens during error recovery with balanced
parenthesis be to add code in lex to count parenthesis nesting, then
set an error state skipping tokens until the matching ')' is found?
If lex skips tokens until a matching ')' during the error state, does
that eliminate the need to add error tokens to each production?
Would it be useful to add action code to save the nesting level for
use in error recovery?
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.