[project @ 1996-01-08 20:28:12 by partain]
[ghc.git] / ghc / docs / add_to_compiler / stg-summary-fig.verb
1 \begin{figure} \fbox{
2 $\begin{array}{lrcll}
3 %\mbox{Program} & prog & \rightarrow & binds & \\
4 %\\
5 \mbox{Bindings} & binds & \rightarrow 
6         & bind_1 @;@ \ldots @;@~ bind_n & n \geq 1 \\
7 & bind & \rightarrow &  var ~@=@~ vars_f ~@\@ upd~ vars_a ~@->@~expr
8                         & \mbox{Closure} \\
9                         &&&& (vars_f = \freevars{expr} \setminus vars_a) \\
10 \\
11 \mbox{Update flag} & upd & \rightarrow & @u@ & \mbox{Updatable} \\
12         && | & @n@                              & \mbox{Not updatable} \\
13 \\
14 \mbox{Expression} & expr 
15         & \rightarrow & @let@~binds~@in@~ expr
16                 & \mbox{Local definition} \\
17         && | & @letrec@~binds~@in@~expr
18                 & \mbox{Local recursive definition} \\
19         && | & @case@~expr~@of@~alts 
20                 & \mbox{Case expression} \\
21         && | & var~vars & \mbox{Application}\\
22         && | & con~vars 
23                 & \mbox{Saturated constructor} \\
24         && | & prim~vars 
25                 & \mbox{Saturated primitive}   \\
26         && | & literal & \\
27 \\
28
29 \mbox{Alternatives} & alts & \rightarrow 
30         & calt_1@;@ \ldots @;@~calt_n@; default ->@~ expr 
31                 & n \geq 0~\mbox{(Boxed)}       \\
32         && | & lalt_1@;@ \ldots @;@~lalt_n@;@~var ~@->@~ expr 
33                 & n \geq 0~\mbox{(Unboxed)}     \\
34 \\
35 \mbox{Constructor alt}  
36         & calt & \rightarrow & con~vars~@->@~expr &  \\
37 \mbox{Literal alt}      
38         & lalt & \rightarrow & literal~@->@~expr &  \\
39 \\
40 \mbox{Literals} & literal 
41         & \rightarrow & integer                 & \\
42         && | & \ldots & \\
43 \\
44 \mbox{Primitives} & prim
45         & \rightarrow & @+@ ~|~ @-@ ~|~ @*@ ~|~ @/@ \\
46         && | & \ldots & \\
47 \\
48 \mbox{Variable lists} & vars & \rightarrow & 
49                 @[@var_1@,@ \ldots @,@~var_n@]@                 & n \geq 0 \\
50 \\
51 \end{array}$
52 }
53 \caption{Syntax of the STG language}
54 \label{fig:stg-syntax}
55 \end{figure}