1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="Manual.css">
<TITLE>
Quick start
</TITLE>
</HEAD>
<BODY >
<A HREF="Manual002.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="Manual004.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<H1 CLASS="chapter"><A NAME="htoc6">Chapter 2</A> Quick start</H1>
First install <FONT COLOR=purple>Frown</FONT> as described in Sec. <A HREF="Manual002.html#sec:install">1.1</A>. Then enter
the directory <TT>QuickStart</TT>.
<TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><TT> ralf/Frown> cd QuickStart
</TT></TD>
</TR></TABLE>
The file <TT>Tiger.lg</TT>, listed in Fig. <A HREF="#fig:tiger">2.1</A>, contains a
medium-sized grammar for an imperative language.
<BLOCKQUOTE CLASS="figure"><DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV>
<FONT SIZE=2>A grammar file consists of two parts: the specification of the
grammar, enclosed in special curly braces, and Haskell source code.
The source file typically starts with a Haskell module header.
<TABLE BORDER="2" BGCOLOR="#E0E0E0" WIDTH="100%"><TR><TD>
</FONT><TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> <B>module</B> <I>Tiger</I></TT></FONT><FONT SIZE=2><TT> <B>where</B></TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> <B>import</B> <I>Lexer</I></TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> <B>import</B> <I>Syntax</I></TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> <B>import</B> <I>Prelude</I></TT></FONT><FONT SIZE=2><TT> hiding (exp)</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> %{</TT></FONT></TD>
</TR></TABLE><FONT SIZE=2>
</TD></TR></TABLE><P>
The grammar part begins here. A context-free grammar consists of sets
of terminal and nonterminal symbols, a set of start symbols, and set
of productions or grammar rules. The declaration below introduces the
terminal symbols. Each terminal is given by a Haskell pattern of type
<TT><I>Terminal</I></TT></FONT><FONT SIZE=2>.
<TABLE BORDER="2" BGCOLOR="#E0E0E0" WIDTH="100%"><TR><TD>
</FONT><TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> <I>Terminal</I></TT></FONT><FONT SIZE=2><TT> = <I>DO</I></TT></FONT><FONT SIZE=2><TT> | <I>ELSE</I></TT></FONT><FONT SIZE=2><TT> | <I>END</I></TT></FONT><FONT SIZE=2><TT> | <I>FUNCTION</I></TT></FONT><FONT SIZE=2><TT> | <I>IF</I></TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> | <I>IN</I></TT></FONT><FONT SIZE=2><TT> | <I>LET</I></TT></FONT><FONT SIZE=2><TT> | <I>THEN</I></TT></FONT><FONT SIZE=2><TT> | <I>VAR</I></TT></FONT><FONT SIZE=2><TT> | <I>WHILE</I></TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> | <I>ASSIGN</I></TT></FONT><FONT SIZE=2><TT> as ":=" | <I>COLON</I></TT></FONT><FONT SIZE=2><TT> as ":" | <I>COMMA</I></TT></FONT><FONT SIZE=2><TT> as "," | <I>CPAREN</I></TT></FONT><FONT SIZE=2><TT> as ")"</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> | <I>DIV</I></TT></FONT><FONT SIZE=2><TT> as "/" | <I>EQU</I></TT></FONT><FONT SIZE=2><TT> as "=" | <I>LST</I></TT></FONT><FONT SIZE=2><TT> as "<=" | <I>MINUS</I></TT></FONT><FONT SIZE=2><TT> as "-"</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> | <I>NEG</I></TT></FONT><FONT SIZE=2><TT> as "~" | <I>OPAREN</I></TT></FONT><FONT SIZE=2><TT> as "(" | <I>PLUS</I></TT></FONT><FONT SIZE=2><TT> as "+" | <I>SEMI</I></TT></FONT><FONT SIZE=2><TT> as ";"</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> | <I>TIMES</I></TT></FONT><FONT SIZE=2><TT> as "*"</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> | <I>ID</I></TT></FONT><FONT SIZE=2><TT> {<I>String</I></TT></FONT><FONT SIZE=2><TT>} | <I>INT</I></TT></FONT><FONT SIZE=2><TT> {<I>String</I></TT></FONT><FONT SIZE=2><TT>};
</TT></FONT></TD>
</TR></TABLE><FONT SIZE=2>
</TD></TR></TABLE><P>
A terminal symbol may carry a semantic value or attribute. The Haskell
type of the semantic value is given in curly braces. As a rule,
Haskell source code is always enclosed in curly braces within the
grammar part. The as-clauses define shortcuts for terminals, which may
then be used in the productions.<BR>
<BR>
The declaration below introduces a nonterminal symbol called <TT>exp</TT>
followed by sixteen productions for that symbol. The asterix marks
<TT>exp</TT> as a start symbol; <TT>exp</TT> has a single attribute of type <TT><I>Expr</I></TT></FONT><FONT SIZE=2>.
<TABLE BORDER="2" BGCOLOR="#E0E0E0" WIDTH="100%"><TR><TD>
</FONT><TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> *exp {<I>Expr</I></TT></FONT><FONT SIZE=2><TT>};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> exp {<I>Var</I></TT></FONT><FONT SIZE=2><TT> v} : <I>ID</I></TT></FONT><FONT SIZE=2><TT> {v};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Block</I></TT></FONT><FONT SIZE=2><TT> es} | "(", sepBy exp ";" {es}, ")";</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Int</I></TT></FONT><FONT SIZE=2><TT> i } | <I>INT</I></TT></FONT><FONT SIZE=2><TT> {i};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Un</I></TT></FONT><FONT SIZE=2><TT> <I>Neg</I></TT></FONT><FONT SIZE=2><TT> e} | "-", exp {e}, prec "~";</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Call</I></TT></FONT><FONT SIZE=2><TT> f es} | <I>ID</I></TT></FONT><FONT SIZE=2><TT> {f}, "(", sepBy exp "," {es}, ")";</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Bin</I></TT></FONT><FONT SIZE=2><TT> e1 <I>Eq</I></TT></FONT><FONT SIZE=2><TT> e2} | exp {e1}, "=", exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Bin</I></TT></FONT><FONT SIZE=2><TT> e1 <I>Leq</I></TT></FONT><FONT SIZE=2><TT> e2} | exp {e1}, "<=", exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Bin</I></TT></FONT><FONT SIZE=2><TT> e1 <I>Add</I></TT></FONT><FONT SIZE=2><TT> e2} | exp {e1}, "+", exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Bin</I></TT></FONT><FONT SIZE=2><TT> e1 <I>Sub</I></TT></FONT><FONT SIZE=2><TT> e2} | exp {e1}, "-", exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Bin</I></TT></FONT><FONT SIZE=2><TT> e1 <I>Mul</I></TT></FONT><FONT SIZE=2><TT> e2} | exp {e1}, "*", exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Bin</I></TT></FONT><FONT SIZE=2><TT> e1 <I>Div</I></TT></FONT><FONT SIZE=2><TT> e2} | exp {e1}, "/", exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Assign</I></TT></FONT><FONT SIZE=2><TT> v e} | <I>ID</I></TT></FONT><FONT SIZE=2><TT> {v}, ":=", exp {e};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>IfThen</I></TT></FONT><FONT SIZE=2><TT> e e1} | <I>IF</I></TT></FONT><FONT SIZE=2><TT>, exp {e}, <I>THEN</I></TT></FONT><FONT SIZE=2><TT>, exp {e1};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>IfElse</I></TT></FONT><FONT SIZE=2><TT> e e1 e2} | <I>IF</I></TT></FONT><FONT SIZE=2><TT>, exp {e}, <I>THEN</I></TT></FONT><FONT SIZE=2><TT>, exp {e1}, <I>ELSE</I></TT></FONT><FONT SIZE=2><TT>, exp {e2};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>While</I></TT></FONT><FONT SIZE=2><TT> e e1} | <I>WHILE</I></TT></FONT><FONT SIZE=2><TT>, exp {e}, <I>DO</I></TT></FONT><FONT SIZE=2><TT>, exp {e1};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {<I>Let</I></TT></FONT><FONT SIZE=2><TT> ds es} | <I>LET</I></TT></FONT><FONT SIZE=2><TT>, many dec {ds}, <I>IN</I></TT></FONT><FONT SIZE=2><TT>, sepBy exp ";" {es}, <I>END</I></TT></FONT><FONT SIZE=2><TT>;
</TT></FONT></TD>
</TR></TABLE><FONT SIZE=2>
</TD></TR></TABLE><P>
Left-hand and right-hand side of a production are separated by a
colon; symbols on the right are separated by commas and terminated by
a semicolon. Alternative right-hand sides are separated by a vertical
bar. <BR>
<BR>
The pieces in curly braces constitute Haskell source code. Each rule
can be seen as a function from the right-hand to the left-hand
side. On the right-hand side, Haskell variables are used to name the
values of attributes. The values of the attributes on the left-hand
side are given by Haskell expressions, in which the variables of the
right-hand side occur free.<BR>
<BR>
The last production makes use of two (predefined) rule schemes: <TT>many x</TT>
implements the repetition of the symbol <TT>x</TT>, and <TT>sepBy x sep</TT>
denotes a repetition of <TT>x</TT> symbols separated by <TT>sep</TT> symbols.<BR>
<BR>
The above productions are ambiguous as, for instance, <TT>1 + 2 * 3</TT> has
two derivations. The ambiguity can be resolved by assigning
precedences to terminal symbols.
<TABLE BORDER="2" BGCOLOR="#E0E0E0" WIDTH="100%"><TR><TD>
</FONT><TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> left 7 "~"; left 6 "*"; left 6 "/"; left 5 "+"; left 5 "-";</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> right 0 <I>THEN</I></TT></FONT><FONT SIZE=2><TT>; right 0 <I>ELSE</I></TT></FONT><FONT SIZE=2><TT>; </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> nonassoc 4 "<="; nonassoc 4 "="; nonassoc 0 <I>DO</I></TT></FONT><FONT SIZE=2><TT>; nonassoc 0 ":=";
</TT></FONT></TD>
</TR></TABLE><FONT SIZE=2>
</TD></TR></TABLE><P>
The following declarations define the nonterminal <TT>dec</TT> and three
further nonterminals.
<TABLE BORDER="2" BGCOLOR="#E0E0E0" WIDTH="100%"><TR><TD>
</FONT><TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> dec {<I>Decl</I></TT></FONT><FONT SIZE=2><TT>};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> dec {d} : vardec {d};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> {d} | fundec {d};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> vardec {<I>Decl</I></TT></FONT><FONT SIZE=2><TT>};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> vardec {<I>Variable</I></TT></FONT><FONT SIZE=2><TT> v e} : <I>VAR</I></TT></FONT><FONT SIZE=2><TT>, <I>ID</I></TT></FONT><FONT SIZE=2><TT> {v}, ":=", exp {e};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> fundec {<I>Decl</I></TT></FONT><FONT SIZE=2><TT>};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> fundec {<I>Function</I></TT></FONT><FONT SIZE=2><TT> f xs e} : <I>FUNCTION</I></TT></FONT><FONT SIZE=2><TT>, <I>ID</I></TT></FONT><FONT SIZE=2><TT> {f}, "(", sepBy (<I>ID</I></TT></FONT><FONT SIZE=2><TT> {}) "," {xs}, ")", "=", exp {e};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> formal {(<I>Ident</I></TT></FONT><FONT SIZE=2><TT>, <I>TyIdent</I></TT></FONT><FONT SIZE=2><TT>)};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> formal {(v, t)} : <I>ID</I></TT></FONT><FONT SIZE=2><TT> {v}, ":", <I>ID</I></TT></FONT><FONT SIZE=2><TT> {t};</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> }%
</TT></FONT></TD>
</TR></TABLE><FONT SIZE=2>
</TD></TR></TABLE><P>
The grammar part ends here. The source file typically includes a
couple of Haskell declarations. The user-defined function <TT>frown</TT> is
the error routine invoked by the parser in case of a syntax error; its
definition is mandatory.
<TABLE BORDER="2" BGCOLOR="#E0E0E0" WIDTH="100%"><TR><TD>
</FONT><TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> frown _ = error "syntax error"</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> </TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> tc f = <B>do</B> { putStrLn "*** reading ..."; s <- readFile f; print s;</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> putStrLn "*** lexing ..."; <B>let</B> {ts = lexer s}; print ts;</TT></FONT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><FONT SIZE=2><TT>> putStrLn "*** parsing ..."; e <- exp ts; print e }</TT></FONT></TD>
</TR></TABLE><FONT SIZE=2>
</TD></TR></TABLE><P>
<BR>
<BR>
</FONT><DIV CLASS="center"><FONT SIZE=2>Figure 2.1: </FONT><A NAME="fig:tiger"></A><FONT SIZE=2>A sample <FONT COLOR=purple>Frown</FONT></FONT><FONT SIZE=2> grammar file.</FONT></DIV><BR>
<BR>
<FONT SIZE=2>
</FONT><DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV></BLOCKQUOTE>
Now, type
<TABLE border=0 cellspacing=0 cellpadding=0>
<TR><TD ALIGN=left NOWRAP><TT> ralf/Frown/QuickStart> frown -v Tiger.lg</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT> ralf/Frown/QuickStart> hugs Tiger.hs</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT> ...</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT> Tiger> exp [ID "a", PLUS, ID "b", TIMES, INT "2"] >>= print</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT> Bin (Var "a") Add (Bin (Var "b") Mul (Int "2"))</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT> Tiger> tc "fib.tig"</TT></TD>
</TR>
<TR><TD ALIGN=left NOWRAP><TT> ...
</TT></TD>
</TR></TABLE>
The call <TT>frown -v Tiger.lg</TT> generates a Haskell parser which can then
be loaded into <TT>hugs</TT> (or <TT>ghci</TT>). The parser has type <TT>exp :: (<I>Monad</I></TT><TT> m) => [<I>Terminal</I></TT><TT>] -> m <I>Expr</I></TT>, that is, the parser is a computation that
takes a list of terminals as input and returns an expression.<BR>
<BR>
<BR>
More examples can be found in the directory <TT>Manual/Examples</TT>:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B><TT>Paren1.lg</TT></B><DD CLASS="dd-description"><BR>
well-balanced parentheses: a pure grammar (see Sec. <A HREF="Manual004.html#sec:pure">3.2.1</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Paren2.lg</TT></B><DD CLASS="dd-description"><BR>
an extension of <TT>Paren1.lg</TT> illustrating the definition of attributes
(see Sec. <A HREF="Manual004.html#sec:attributes">3.2.2</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Calc.lg</TT></B><DD CLASS="dd-description"><BR>
a simple evaluator for arithmetic expressions: a parser that
interfaces with a separate lexer (see Sec. <A HREF="Manual004.html#sec:lexer">3.2.3</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>MCalc.lg</TT></B><DD CLASS="dd-description"><BR>
a variant of the desktop calculator (<TT>Calc.lg</TT>) that prints all
intermediate results: illustrates monadic actions (see
Sec. <A HREF="Manual004.html#sec:monadicactions">3.2.4</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let1.lg</TT></B><DD CLASS="dd-description"><BR>
an ambiguous expression grammar: illustrates backtracking parsers (see
Sec. <A HREF="Manual004.html#sec:backtracking">3.2.5</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let2.lg</TT></B><DD CLASS="dd-description"><BR>
an expression grammar: illustrates the use of precedences and
associativity (see Sec. <A HREF="Manual004.html#sec:prec">3.2.6</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let3.lg</TT></B><DD CLASS="dd-description"><BR>
a variant of the expression grammar: shows how to simulate inherited
attributes using a reader monad (see Sec. <A HREF="Manual004.html#sec:reader">3.2.8</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let4.lg</TT></B><DD CLASS="dd-description"><BR>
an expression grammar: illustrates a parser
that interfaces with a monadic lexer (see Sec. <A HREF="Manual004.html#sec:mlexer">3.3.1</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let5.lg</TT></B><DD CLASS="dd-description"><BR>
a variant of <TT>Let4.lg</TT> with better error reporting (see
Sec. <A HREF="Manual004.html#sec:reporting">3.3.2</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let6.lg</TT></B><DD CLASS="dd-description"><BR>
a variant of <TT>Let5.lg</TT> with even better error reporting: prints a
list of expected tokens upon error (see Sec. <A HREF="Manual004.html#sec:expected">3.3.3</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let7.lg</TT></B><DD CLASS="dd-description"><BR>
yet another variant of the expression grammar: illustrates a simple
form of error correction (see Sec. <A HREF="Manual004.html#sec:errorcorrection">3.3.4</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Let8.lg</TT></B><DD CLASS="dd-description"><BR>
variant of <TT>Let7.lg</TT> that notifies the user of corrections (see
Sec. <A HREF="Manual004.html#sec:errorcorrection">3.3.4</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>VarCalc.lg</TT></B><DD CLASS="dd-description"><BR>
a variant of the desktop calculator (<TT>Calc.lg</TT>) that works without a
separate lexer: illustrates guards (see Sec. <A HREF="Manual004.html#sec:terminal2">3.4.2</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>Paren3.lg</TT></B><DD CLASS="dd-description"><BR>
illustrates the tracing facilities (see Sec. <A HREF="Manual004.html#sec:tracing">3.4.4</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>VarParen.lg</TT></B><DD CLASS="dd-description"><BR>
illustrates irrefutable patterns on the right-hand side of productions
(see Sec. <A HREF="Manual005.html#sec:irrefutable">4.1</A>);<BR>
<BR>
<DT CLASS="dt-description"><B><TT>RepMin.lg</TT></B><DD CLASS="dd-description"><BR>
a solution to the rep-min problem: illustrates how to simulate
inherited attributes using functional attributes (see
Sec. <A HREF="Manual005.html#sec:inherited">4.2</A>).
</DL>
<HR>
<A HREF="Manual002.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="Manual004.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
|