Re: Error reporting in LR parsers

djones@megatest.com (Dave Jones)
10 Aug 89 20:06:08 GMT

          From comp.compilers

Related articles
Error reporting in LR parsers worley@compass.com (1989-08-02)
Re: Error reporting in LR parsers djones@megatest.uucp (1989-08-04)
Re: Error reporting in LR parsers lai@mips.com (1989-08-07)
Re: Error reporting in LR parsers heirich@cs.ucsd.edu (1989-08-08)
Re: Error reporting in LR parsers heirich@cs.ucsd.edu (1989-08-08)
Re: Error reporting in LR parsers rusty@garnet.Berkeley.EDU (1989-08-10)
Re: Error reporting in LR parsers djones@megatest.com (1989-08-10)
Re: Error reporting in LR parsers djones@megatest.com (1989-08-10)
Re: Error reporting in LR parsers djones@megatest.com (1989-08-10)
Re: Error reporting in LR parsers markg@well.sf.ca.us (1989-08-15)
Re: Error reporting in LR parsers eachus@mbunix.mitre.org (1989-08-14)
| List of all articles for this month |
From: djones@megatest.com (Dave Jones)
Newsgroups: comp.compilers
Date: 10 Aug 89 20:06:08 GMT
References: <1989Aug8.130702.957@esegue.uucp)
Organization: Megatest Corporation, San Jose, Ca

>From article <1989Aug8.130702.957@esegue.uucp), by lai@mips.com (David Lai):
) In <1989Aug6.024931.10014@esegue.uucp), Dave Jones gives a rebuttal stating
) how a default reduction in yacc has eliminated acceptable tokens from the
) token list when an error occurs. The problem can be solved by generating
) the list of acceptable tokens *before* returning the error token. This
) method requires that you test the tokens before returning them to yacc (in
) the scanner).
)
) In the case given 'i = j k', the scanner upon reading 'k' checks the parser
) state to see whether an identifier is acceptable in this state. This will
) be the state prior to the default reduction, where + and * are still
) acceptable. The list of acceptable tokens is remembered and the erroneous
) token is returned. The 'yyerror' function then prints out the (perhaps
) decoded) list of acceptable tokens.


As I (and one or two other people) pointed out the last time this
subject came up, it is not necessary for the parser to keep a set of
acceptable tokens. It can keep a set of states which are discarded
by default reductions, (which should be much quicker to calculate),
then calculate the tokens only if they are needed when an error is
detected. Didn't I point this out recently also?


Dave Jones
[From djones@megatest.com (Dave Jones)]





Post a followup to this message

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