.\" Run this paper off with
.\" refer [options] -p LLgen.refs LLgen.doc | [n]eqn | tbl | (nt)roff -ms
.if '\*(>.'' \{\
-. if '\*(.>'' \{\
+. if '\*(<.'' \{\
. if n .ds >. .
. if n .ds >, ,
-. if t .ds .> .
-. if t .ds ,> ,\
+. if t .ds <. .
+. if t .ds <, ,\
\}\
\}
.cs 5 22u
for the rest of this document.
It is assumed that the reader has some knowledge of LL(1) grammars and
recursive descent parsers.
-For a survey on the subject, see .
-.[
+For a survey on the subject, see reference
+.[ (
griffiths
-.]
+.]).
.PP
Extended LL(1) parsers are an extension of LL(1) parsers. They are
derived from an Extended Context-Free (ECF) syntax instead of a Context-Free
\fILLgen\fR
user can associate
actions with the syntax. These actions must be written in the programming
-language C ,
+language C,
.[
kernighan ritchie
.]
input syntax.
Appendix B gives an example.
It is very instructive to compare this example with the one
-given in .
-.[
+given in reference
+.[ (
yacc
-.]
+.]).
It demonstrates the struggle \fILLparse\fR and other LL(1)
parsers have with expressions.
Appendix C gives an example of the \fILLgen\fR features
allowing the user to recompile only those output files that
-have changed, using the \fImake\fR program .
+have changed, using the \fImake\fR program.
.[
make
.]
Error Recovery
.PP
The error recovery technique used by \fILLgen\fR is a
-modification of the one presented in .
-.[
+modification of the one presented in reference
+.[ (
automatic construction error correcting
-.]
+.]).
It is based on \fBdefault choices\fR, which just are
what the word says, default choices at
every point in the grammar where there is a
The conflicts can be resolved by rewriting the grammar
or by using \fBconflict resolvers\fR.
The mechanism described here is based on the attributed parsing
-of .
-.[
+of reference
+.[ (
milton
-.]
+.]).
.PP
An alternation conflict can be resolved by putting an \fBif condition\fR
in front of the first conflicting production.
So, the lexical analyzer must have a facility to push back one
token.
.PP
+The user may also supply his own error recovery routines, or handle
+errors differently. For this purpose, the name of a routine to be called
+when an error occurs may be declared using the keyword \fB%onerror\fR.
+This routine takes one parameter, which is either the token number of the
+token expected, or 0. In the last case, the error occurred at a choice.
+In both cases, the routine must ensure that the next call to the lexical
+analyser returns the token that replaces the current one. Of course,
+that could well be the current one, in which case
+.I LLparse
+recovers from the error.
+.PP
The user must supply a lexical analyzer to read the input stream and
break it up into tokens, which are passed to
.I LLparse.
The reason for this funny name is that a useful tool for constructing
lexical analyzers is the
.I Lex
-program ,
+program,
.[
lex
.]
of input to \fILLparse\fR
by returning a number less than or equal to zero.
.bp
+.SH
+References
.[
$LIST$
.]
%token PREFER; /* %prefer */
%token DEFAULT; /* %default */
%token LEXICAL; /* %lexical */
+%token ONERROR; /* %onerror */
%token FIRST; /* %first */
/*
| LEXICAL
IDENTIFIER
';'
+ | ONERROR
+ IDENTIFIER
+ ';'
| rule
;