Added doc on %onerror, and some other minor mods

This commit is contained in:
ceriel 1987-02-16 21:42:18 +00:00
parent 3f6a8abe1b
commit a08f3c3e9c

View file

@ -2,11 +2,11 @@
.\" 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
@ -75,10 +75,10 @@ will be called
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
@ -92,7 +92,7 @@ Section 4 provides a description of the way the
\fILLgen\fR
user can associate
actions with the syntax. These actions must be written in the programming
language C ,
language C,
.[
kernighan ritchie
.]
@ -117,15 +117,15 @@ Appendix A gives a summary of the
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
.]
@ -396,10 +396,10 @@ To avoid name-conflicts with identifiers generated by
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
@ -551,10 +551,10 @@ The conflicts can be examined by inspecting the verbose
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.
@ -650,6 +650,17 @@ lexical analyzer, with the proper attributes.
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.
@ -670,7 +681,7 @@ The default name for the lexical analyzer is "yylex".
The reason for this funny name is that a useful tool for constructing
lexical analyzers is the
.I Lex
program ,
program,
.[
lex
.]
@ -689,6 +700,8 @@ The lexical analyzer must signal the end
of input to \fILLparse\fR
by returning a number less than or equal to zero.
.bp
.SH
References
.[
$LIST$
.]
@ -724,6 +737,7 @@ version of \fILLgen\fR is written with \fILLgen\fR.
%token PREFER; /* %prefer */
%token DEFAULT; /* %default */
%token LEXICAL; /* %lexical */
%token ONERROR; /* %onerror */
%token FIRST; /* %first */
/*
@ -753,6 +767,9 @@ declaration
| LEXICAL
IDENTIFIER
';'
| ONERROR
IDENTIFIER
';'
| rule
;