Added doc on %onerror, and some other minor mods
This commit is contained in:
parent
3f6a8abe1b
commit
a08f3c3e9c
1 changed files with 35 additions and 18 deletions
|
@ -2,11 +2,11 @@
|
||||||
.\" Run this paper off with
|
.\" Run this paper off with
|
||||||
.\" refer [options] -p LLgen.refs LLgen.doc | [n]eqn | tbl | (nt)roff -ms
|
.\" refer [options] -p LLgen.refs LLgen.doc | [n]eqn | tbl | (nt)roff -ms
|
||||||
.if '\*(>.'' \{\
|
.if '\*(>.'' \{\
|
||||||
. if '\*(.>'' \{\
|
. if '\*(<.'' \{\
|
||||||
. if n .ds >. .
|
. if n .ds >. .
|
||||||
. if n .ds >, ,
|
. if n .ds >, ,
|
||||||
. if t .ds .> .
|
. if t .ds <. .
|
||||||
. if t .ds ,> ,\
|
. if t .ds <, ,\
|
||||||
\}\
|
\}\
|
||||||
\}
|
\}
|
||||||
.cs 5 22u
|
.cs 5 22u
|
||||||
|
@ -75,10 +75,10 @@ will be called
|
||||||
for the rest of this document.
|
for the rest of this document.
|
||||||
It is assumed that the reader has some knowledge of LL(1) grammars and
|
It is assumed that the reader has some knowledge of LL(1) grammars and
|
||||||
recursive descent parsers.
|
recursive descent parsers.
|
||||||
For a survey on the subject, see .
|
For a survey on the subject, see reference
|
||||||
.[
|
.[ (
|
||||||
griffiths
|
griffiths
|
||||||
.]
|
.]).
|
||||||
.PP
|
.PP
|
||||||
Extended LL(1) parsers are an extension of LL(1) parsers. They are
|
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
|
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
|
\fILLgen\fR
|
||||||
user can associate
|
user can associate
|
||||||
actions with the syntax. These actions must be written in the programming
|
actions with the syntax. These actions must be written in the programming
|
||||||
language C ,
|
language C,
|
||||||
.[
|
.[
|
||||||
kernighan ritchie
|
kernighan ritchie
|
||||||
.]
|
.]
|
||||||
|
@ -117,15 +117,15 @@ Appendix A gives a summary of the
|
||||||
input syntax.
|
input syntax.
|
||||||
Appendix B gives an example.
|
Appendix B gives an example.
|
||||||
It is very instructive to compare this example with the one
|
It is very instructive to compare this example with the one
|
||||||
given in .
|
given in reference
|
||||||
.[
|
.[ (
|
||||||
yacc
|
yacc
|
||||||
.]
|
.]).
|
||||||
It demonstrates the struggle \fILLparse\fR and other LL(1)
|
It demonstrates the struggle \fILLparse\fR and other LL(1)
|
||||||
parsers have with expressions.
|
parsers have with expressions.
|
||||||
Appendix C gives an example of the \fILLgen\fR features
|
Appendix C gives an example of the \fILLgen\fR features
|
||||||
allowing the user to recompile only those output files that
|
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
|
make
|
||||||
.]
|
.]
|
||||||
|
@ -396,10 +396,10 @@ To avoid name-conflicts with identifiers generated by
|
||||||
Error Recovery
|
Error Recovery
|
||||||
.PP
|
.PP
|
||||||
The error recovery technique used by \fILLgen\fR is a
|
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
|
automatic construction error correcting
|
||||||
.]
|
.]).
|
||||||
It is based on \fBdefault choices\fR, which just are
|
It is based on \fBdefault choices\fR, which just are
|
||||||
what the word says, default choices at
|
what the word says, default choices at
|
||||||
every point in the grammar where there is a
|
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
|
The conflicts can be resolved by rewriting the grammar
|
||||||
or by using \fBconflict resolvers\fR.
|
or by using \fBconflict resolvers\fR.
|
||||||
The mechanism described here is based on the attributed parsing
|
The mechanism described here is based on the attributed parsing
|
||||||
of .
|
of reference
|
||||||
.[
|
.[ (
|
||||||
milton
|
milton
|
||||||
.]
|
.]).
|
||||||
.PP
|
.PP
|
||||||
An alternation conflict can be resolved by putting an \fBif condition\fR
|
An alternation conflict can be resolved by putting an \fBif condition\fR
|
||||||
in front of the first conflicting production.
|
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
|
So, the lexical analyzer must have a facility to push back one
|
||||||
token.
|
token.
|
||||||
.PP
|
.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
|
The user must supply a lexical analyzer to read the input stream and
|
||||||
break it up into tokens, which are passed to
|
break it up into tokens, which are passed to
|
||||||
.I LLparse.
|
.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
|
The reason for this funny name is that a useful tool for constructing
|
||||||
lexical analyzers is the
|
lexical analyzers is the
|
||||||
.I Lex
|
.I Lex
|
||||||
program ,
|
program,
|
||||||
.[
|
.[
|
||||||
lex
|
lex
|
||||||
.]
|
.]
|
||||||
|
@ -689,6 +700,8 @@ The lexical analyzer must signal the end
|
||||||
of input to \fILLparse\fR
|
of input to \fILLparse\fR
|
||||||
by returning a number less than or equal to zero.
|
by returning a number less than or equal to zero.
|
||||||
.bp
|
.bp
|
||||||
|
.SH
|
||||||
|
References
|
||||||
.[
|
.[
|
||||||
$LIST$
|
$LIST$
|
||||||
.]
|
.]
|
||||||
|
@ -724,6 +737,7 @@ version of \fILLgen\fR is written with \fILLgen\fR.
|
||||||
%token PREFER; /* %prefer */
|
%token PREFER; /* %prefer */
|
||||||
%token DEFAULT; /* %default */
|
%token DEFAULT; /* %default */
|
||||||
%token LEXICAL; /* %lexical */
|
%token LEXICAL; /* %lexical */
|
||||||
|
%token ONERROR; /* %onerror */
|
||||||
%token FIRST; /* %first */
|
%token FIRST; /* %first */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -753,6 +767,9 @@ declaration
|
||||||
| LEXICAL
|
| LEXICAL
|
||||||
IDENTIFIER
|
IDENTIFIER
|
||||||
';'
|
';'
|
||||||
|
| ONERROR
|
||||||
|
IDENTIFIER
|
||||||
|
';'
|
||||||
| rule
|
| rule
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue