SCM Repository
Annotation of /trunk/doc/report/lang.tex
Parent Directory
|
Revision Log
Revision 2636 - (view) (download) (as text)
1 : | jhr | 329 | %!TEX root = report.tex |
2 : | % | ||
3 : | \chapter{The Diderot Language} | ||
4 : | \label{chap:lang} | ||
5 : | |||
6 : | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
7 : | jhr | 2636 | \section{Program structure} |
8 : | |||
9 : | \begin{Grammar} | ||
10 : | \ProgramRULES{} | ||
11 : | \end{Grammar}% | ||
12 : | |||
13 : | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
14 : | jhr | 329 | \section{Global declarations} |
15 : | |||
16 : | jhr | 2636 | \begin{Grammar} |
17 : | \GlobalDeclRULES{} | ||
18 : | \end{Grammar}% | ||
19 : | |||
20 : | \subsection{Global variable declarations} | ||
21 : | |||
22 : | \begin{Grammar} | ||
23 : | \VarDeclRULES{} | ||
24 : | \end{Grammar}% | ||
25 : | |||
26 : | \subsection{Input variable declarations} | ||
27 : | |||
28 : | \begin{Grammar} | ||
29 : | \InputDeclRULES{} | ||
30 : | \end{Grammar}% | ||
31 : | |||
32 : | \subsection{Function declarations} | ||
33 : | \begin{Grammar} | ||
34 : | \FuncDeclRULES{} | ||
35 : | \ParamsRULES{} | ||
36 : | \ParamRULES{} | ||
37 : | \end{Grammar}% | ||
38 : | |||
39 : | jhr | 329 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
40 : | jhr | 1116 | \section{Strand definitions} |
41 : | jhr | 329 | |
42 : | jhr | 2636 | \begin{Grammar} |
43 : | \StrandDeclRULES{} | ||
44 : | \end{Grammar}% | ||
45 : | |||
46 : | jhr | 1116 | \subsection{Strand state} |
47 : | jhr | 329 | |
48 : | jhr | 2636 | \begin{Grammar} |
49 : | \StrandStateDeclRULES{} | ||
50 : | \end{Grammar}% | ||
51 : | |||
52 : | jhr | 329 | \subsection{The update method} |
53 : | |||
54 : | \subsection{The stabilize method} | ||
55 : | |||
56 : | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
57 : | \section{Initialization} | ||
58 : | jhr | 330 | |
59 : | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
60 : | \section{Statements} | ||
61 : | jhr | 473 | |
62 : | jhr | 2636 | \begin{Grammar} |
63 : | \BlockRULES{} | ||
64 : | \StmtRULES{} | ||
65 : | \end{Grammar}% | ||
66 : | |||
67 : | jhr | 473 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
68 : | \section{Expressions} | ||
69 : | |||
70 : | jhr | 1116 | In this section, we describe Diderot's expression syntax. |
71 : | The section is organized from lowest to highest precedence. | ||
72 : | |||
73 : | jhr | 473 | \subsection{Conditional expressions} |
74 : | There are three conditional expression forms in Diderot: | ||
75 : | \emph{if-else} expressions, \emph{or-else} expressions, and \emph{and-also} | ||
76 : | expressions. | ||
77 : | The syntax of these is given by the following grammar fragment: | ||
78 : | \begin{Grammar} | ||
79 : | \ExprRULES{} | ||
80 : | jhr | 2636 | \OrExprRULES{} |
81 : | jhr | 473 | \AndExprRULES{} |
82 : | \end{Grammar}% | ||
83 : | |||
84 : | \subsubsection{If-else expressions} | ||
85 : | The if-else expression has the following typing rule: | ||
86 : | \begin{displaymath} | ||
87 : | \infer{ | ||
88 : | \HasTy{\ENV}{e_1\;\mkw{if}\;e_2\;\mkw{else}\;e_3}{\tau} | ||
89 : | }{ | ||
90 : | \HasTy{\ENV}{e_1}{\tau} \quad | ||
91 : | \HasTy{\ENV}{e_2}{\TYbool} \quad | ||
92 : | \HasTy{\ENV}{e_3}{\tau} \quad | ||
93 : | } | ||
94 : | \end{displaymath}% | ||
95 : | Its semantics are that it evaluates $e_2$ first. | ||
96 : | If the value is true, then it evaluate $e_1$, otherwise it evaluates $e_3$. | ||
97 : | |||
98 : | \subsubsection{Or-else expressions} | ||
99 : | \begin{displaymath} | ||
100 : | \infer{ | ||
101 : | \HasTy{\ENV}{e_1\;\mkw{||}\;e_2}{\TYbool} | ||
102 : | }{ | ||
103 : | \HasTy{\ENV}{e_1}{\TYbool} \quad | ||
104 : | \HasTy{\ENV}{e_2}{\TYbool} | ||
105 : | } | ||
106 : | \end{displaymath}% | ||
107 : | The or-else form is derived from the if-else form as follows: | ||
108 : | \begin{displaymath} | ||
109 : | e_1\;\mkw{||}\;e_2 \quad \equiv \quad \mkw{true}\;\mkw{if}\;e_1\;\mkw{else}\;e_2 | ||
110 : | \end{displaymath}% | ||
111 : | |||
112 : | jhr | 2636 | \subsubsection{And-also expressions} |
113 : | jhr | 473 | \begin{displaymath} |
114 : | \infer{ | ||
115 : | \HasTy{\ENV}{e_1\;\mkw{\&\&}\;e_2}{\TYbool} | ||
116 : | }{ | ||
117 : | \HasTy{\ENV}{e_1}{\TYbool} \quad | ||
118 : | \HasTy{\ENV}{e_2}{\TYbool} | ||
119 : | } | ||
120 : | \end{displaymath}% | ||
121 : | The and-also form is derived from the if-else form as follows: | ||
122 : | \begin{displaymath} | ||
123 : | e_1\;\mkw{\&\&}\;e_2 \quad \equiv \quad e_2\;\mkw{if}\;e_1\;\mkw{else}\;\mkw{false} | ||
124 : | \end{displaymath}% | ||
125 : | |||
126 : | \subsection{Binary expressions} | ||
127 : | \begin{Grammar} | ||
128 : | \CmpExprRULES{} | ||
129 : | jhr | 1116 | \CmpOpRULES{} |
130 : | jhr | 473 | \AddExprRULES{} |
131 : | jhr | 1116 | \AddOpRULES{} |
132 : | jhr | 473 | \MulExprRULES{} |
133 : | \MulOpRULES{} | ||
134 : | jhr | 1116 | \PowerExprRULES{} |
135 : | jhr | 473 | \ProbeExprRULES{} |
136 : | \end{Grammar}% | ||
137 : | |||
138 : | jhr | 1116 | \subsection{Prefix-operator expressions} |
139 : | jhr | 473 | \begin{Grammar} |
140 : | \PrefixExprRULES{} | ||
141 : | \end{Grammar}% | ||
142 : | |||
143 : | jhr | 1116 | \subsection{Suffix-operator expressions} |
144 : | jhr | 473 | \begin{Grammar} |
145 : | jhr | 1116 | \SuffixExprRULES{} |
146 : | \SuffixRULES{} | ||
147 : | jhr | 473 | \IndexRULES{} |
148 : | \end{Grammar}% | ||
149 : | |||
150 : | jhr | 1116 | \subsection{Derivative expressions} |
151 : | \begin{Grammar} | ||
152 : | \DerivExprRULES{} | ||
153 : | \end{Grammar}% | ||
154 : | |||
155 : | jhr | 473 | \subsection{Atomic expressions} |
156 : | \begin{Grammar} | ||
157 : | jhr | 1116 | \AtomExprRULES{} |
158 : | jhr | 473 | \ArgumentsRULES{} |
159 : | \end{Grammar}% |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |