.\" $Header$
.\" Run this paper off with
.\" refer [options] -p LLgen.refs LLgen.doc | [n]eqn | tbl | (nt)roff -ms
+.if '\*(>.'' \{\
+. if '\*(.>'' \{\
+. if n .ds >. .
+. if n .ds >, ,
+. if t .ds .> .
+. if t .ds ,> ,\
+\}\
+\}
.cs 5 22u
.RP
.ND
.ft 5
grammar : rule +
;
-.ft P
+.ft R
.DE
This grammar rule states that a grammar consists of one or more
rules.
.ft 5
rule : nonterminal ':' productionrule ';'
;
-.ft P
+.ft R
.DE
A rule consists of a left hand side, the nonterminal,
followed by ":",
.ft 5
productionrule : production [ '|' production ]*
;
-.ft P
+.ft R
.DE
A production rule consists of one or
more alternative productions separated by "|". This symbol is called the
.ft 5
production : term *
;
-.ft P
+.ft R
.DE
A production consists of a possibly empty list of terms.
So, empty productions are allowed.
.ft 5
term : element repeats
;
-.ft P
+.ft R
.DE
A term is an element, possibly with a repeat specification.
.DS
| IDENTIFIER
| '[' productionrule ']'
;
-.ft P
+.ft R
.DE
An element can be a LITERAL, which basically is a single character
between apostrophes, it can be an IDENTIFIER, which is either a
| [ '*' | '+' ] NUMBER ?
| NUMBER ?
;
-.ft P
+.ft R
.DE
These are the repeat specifications discussed above. Notice that
this specification may be empty.
.ft 5
.sp 1
%token name1, name2, . . . ;
-.ft P
+.ft R
.fi
.PP
\fILLparse\fR is designed to recognize special nonterminal
.ft 5
.sp 1
%start LLparse, specification ;
-.ft P
+.ft R
.fi
.sp 1
declares "specification" as a start symbol and associates the
*/
;
.sp 1
-.ft P
+.ft R
.fi
is a rule to recognize a number of factors, separated by "+", and
to compute their sum.
The error recovery technique used by \fILLgen\fR is a
modification of the one presented in .
.[
-Rohrich
+automatic construction error correcting
.]
It is based on \fBdefault choices\fR, which just are
what the word says, default choices at
.nf
term+
.fi
-.ft P
+.ft R
.sp 1
is treated as
.sp 1
.nf
.ft 5
term term* .
-.ft P
+.ft R
.fi
.PP
It is also clear, that it can never be the default choice to do
.nf
commandlist : command* ;
.fi
-.ft P
+.ft R
.sp 1
could be changed to
.sp 1
.nf
commandlist : [ %persistent command ]* ;
.fi
-.ft P
+.ft R
.sp 1
The effects of this in case of a syntax error are twofold:
The set @T@ mentioned above will be extended as if "command" were
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 .
.[
milton
.]
.nf
.ft 5
%first fmac, nonterm ;
-.ft P
+.ft R
.sp 1
.fi
declares "fmac" as a macro with one parameter, whose value
.nf
.ft 5
%lexical scanner ;
-.ft P
+.ft R
.fi
.sp 1
declares "scanner" as the name of the lexical analyzer.
;
.fi
-.ft P
+.ft R
.bp
.SH
Appendix B : An example
{
#include <stdio.h>
#include <ctype.h>
-#define MAXPRIO 5
-#define prio(op) (ptab[op])
+#define MAXPRIO 5
+#define prio(op) (ptab[op])
struct token {
int t_tokno; /* token number */
return parse();
} }
.fi
-.ft P
+.ft R
.bp
.SH
Appendix C. How to use \fILLgen\fR.
expr.o: Lpars.h
.fi
-.ft P
+.ft R