1 : |
jhr |
97 |
%!TEX root = report.tex
|
2 : |
|
|
%
|
3 : |
|
|
% Macros for the various rules of the Diderot grammar. We collect the
|
4 : |
|
|
% grammer into these macros to ensure consistency between the collected
|
5 : |
|
|
% syntax and the body of the text.
|
6 : |
|
|
%
|
7 : |
|
|
\newcommand{\ProgramRULES}{
|
8 : |
|
|
\begin{Rules}{Program}
|
9 : |
|
|
\RHS{\LISTONE{\nt{Declaration}}}
|
10 : |
|
|
\end{Rules}}
|
11 : |
|
|
\newcommand{\DeclarationRULES}{
|
12 : |
|
|
\begin{Rules}{Declaration}
|
13 : |
|
|
\RHS{\nt{InputDecl}}
|
14 : |
|
|
\RHS{\nt{VarDecl}}
|
15 : |
|
|
\RHS{\nt{ActorDecl}}
|
16 : |
|
|
\RHS{\nt{CoordinationDecl}}
|
17 : |
|
|
\end{Rules}}
|
18 : |
|
|
\newcommand{\InputDeclRULES}{
|
19 : |
|
|
\begin{Rules}{InputDecl}
|
20 : |
|
|
\RHS{\kw{input} \nt{Type} \term{Id} \OPTGRP{\kw{=} \nt{Expr}} \kw{;}}
|
21 : |
|
|
\end{Rules}}
|
22 : |
|
|
\newcommand{\ActorDeclRULES}{
|
23 : |
|
|
\begin{Rules}{ActorDecl}
|
24 : |
|
|
\RHS{\kw{actor} \term{Id} \kw{(} \nt{Params} \kw{)} \kw{\{} \LISTGRP{\nt{VarDecl}} \LISTONEGRP{\nt{ActorMethod}} \kw{\}}}
|
25 : |
|
|
\end{Rules}}
|
26 : |
|
|
\newcommand{\ParamsRULES}{
|
27 : |
|
|
\begin{Rules}{Params}
|
28 : |
|
|
\RHS{\OPTGRP{\nt{Param} \LISTGRP{\kw{,} \nt{Param}}}}
|
29 : |
|
|
\end{Rules}}
|
30 : |
|
|
\newcommand{\ParamRULES}{
|
31 : |
|
|
\begin{Rules}{Param}
|
32 : |
|
|
\RHS{\nt{Type} \term{Id}}
|
33 : |
|
|
\end{Rules}}
|
34 : |
|
|
\newcommand{\ActorMethodRULES}{
|
35 : |
|
|
\begin{Rules}{ActorMethod}
|
36 : |
|
|
\RHS{\term{Id} \nt{Block}}
|
37 : |
|
|
\end{Rules}}
|
38 : |
|
|
\newcommand{\BlockRULES}{
|
39 : |
|
|
\begin{Rules}{Block}
|
40 : |
|
|
\RHS{\kw{\{} \LISTGRP{\nt{Stmt}} \kw{\}}}
|
41 : |
|
|
\end{Rules}}
|
42 : |
|
|
\newcommand{\StmtRULES}{
|
43 : |
|
|
\begin{Rules}{Stmt}
|
44 : |
|
|
\RHS{\nt{Block}}
|
45 : |
|
|
\RHS{\nt{VarDecl}}
|
46 : |
|
|
\RHS{\kw{stabilize} \kw{;}}
|
47 : |
|
|
\RHS{\kw{die} \kw{;}}
|
48 : |
|
|
\RHS{\kw{new} \term{Id} \kw{(} \nt{Arguments} \kw{)} \kw{;}}
|
49 : |
|
|
\RHS{\term{Id} \kw{=} \nt{Expr} \kw{;}}
|
50 : |
|
|
\RHS{\kw{if} \kw{(} \nt{Expr} \kw{)} \nt{Stmt} \kw{else} \nt{Stmt}}
|
51 : |
|
|
\RHS{\kw{if} \kw{(} \nt{Expr} \kw{)} \nt{Stmt}}
|
52 : |
|
|
\end{Rules}}
|
53 : |
|
|
\newcommand{\VarDeclRULES}{
|
54 : |
|
|
\begin{Rules}{VarDecl}
|
55 : |
|
|
\RHS{\nt{Type} \term{Id} \kw{=} \nt{Expr} \kw{;}}
|
56 : |
|
|
\end{Rules}}
|
57 : |
|
|
\newcommand{\TypeRULES}{
|
58 : |
|
|
\begin{Rules}{Type}
|
59 : |
|
|
\RHS{\kw{image} \kw{(} \nt{Dimension} \kw{)} \nt{Dimensions}}
|
60 : |
|
|
\RHS{\kw{field} \kw{\#} \nt{Dimension} \kw{(} \nt{Dimension} \kw{)} \nt{Dimensions}}
|
61 : |
|
|
\RHS{\kw{kernel} \kw{\#} \nt{Dimension}}
|
62 : |
|
|
\RHS{\nt{ValueType} \LISTGRP{\kw{[} \nt{Dimension} \kw{]}}}
|
63 : |
|
|
\end{Rules}}
|
64 : |
jhr |
98 |
\newcommand{\ValueTypeRULES}{
|
65 : |
|
|
\begin{Rules}{ValueType}
|
66 : |
|
|
\RHS{\kw{tensor} \nt{Dimensions}}
|
67 : |
|
|
\RHS{\kw{vec2}}
|
68 : |
|
|
\RHS{\kw{vec3}}
|
69 : |
|
|
\RHS{\kw{vec4}}
|
70 : |
|
|
\RHS{\kw{bool}}
|
71 : |
|
|
\RHS{\kw{int}}
|
72 : |
|
|
\RHS{\kw{real}}
|
73 : |
|
|
\RHS{\kw{string}}
|
74 : |
|
|
\end{Rules}}
|
75 : |
|
|
\newcommand{\DimensionsRULES}{
|
76 : |
|
|
\begin{Rules}{Dimensions}
|
77 : |
|
|
\RHS{\kw{[} \OPTGRP{\nt{Dimension} \LISTGRP{\kw{,} \nt{Dimension}}} \kw{]}}
|
78 : |
|
|
\end{Rules}}
|
79 : |
|
|
\newcommand{\DimensionRULES}{
|
80 : |
|
|
\begin{Rules}{Dimension}
|
81 : |
|
|
\RHS{\term{Int}}
|
82 : |
|
|
\end{Rules}}
|
83 : |
jhr |
97 |
\newcommand{\CoordinationDeclRULES}{
|
84 : |
|
|
\begin{Rules}{CoordinationDecl}
|
85 : |
|
|
\RHS{\kw{initially} \nt{\GRP{\nt{Array} $\;|\;$ \nt{Collection}}} \kw{;}}
|
86 : |
|
|
\end{Rules}}
|
87 : |
|
|
\newcommand{\ArrayRULES}{
|
88 : |
|
|
\begin{Rules}{Array}
|
89 : |
|
|
\RHS{\kw{[} \nt{Create} \kw{|} \nt{Iterations} \kw{]}}
|
90 : |
|
|
\end{Rules}}
|
91 : |
|
|
\newcommand{\CollectionRULES}{
|
92 : |
|
|
\begin{Rules}{Collection}
|
93 : |
|
|
\RHS{\kw{\{} \nt{Create} \kw{|} \nt{Iterations} \kw{]}}
|
94 : |
|
|
\end{Rules}}
|
95 : |
|
|
\newcommand{\CreateRULES}{
|
96 : |
|
|
\begin{Rules}{Create}
|
97 : |
|
|
\RHS{\term{Id} \kw{(} \nt{Arguments} \kw{)}}
|
98 : |
|
|
\end{Rules}}
|
99 : |
|
|
\newcommand{\IterationsRULES}{
|
100 : |
|
|
\begin{Rules}{Iterations}
|
101 : |
|
|
\RHS{\nt{Iteration} \LISTONEGRP{\kw{,} \nt{Iteration}}}
|
102 : |
|
|
\end{Rules}}
|
103 : |
|
|
\newcommand{\IterationRULES}{
|
104 : |
|
|
\begin{Rules}{Iteration}
|
105 : |
|
|
\RHS{\term{Id} \kw{in} \nt{Expr} \kw{..} \nt{Expr}}
|
106 : |
|
|
\end{Rules}}
|
107 : |
|
|
\newcommand{\ExprRULES}{
|
108 : |
|
|
\begin{Rules}{Expr}
|
109 : |
|
|
\RHS{\nt{AndExpr} \LISTGRP{\kw{||} \nt{AndExpr}}}
|
110 : |
|
|
\end{Rules}}
|
111 : |
|
|
\newcommand{\AndExprRULES}{
|
112 : |
|
|
\begin{Rules}{AndExpr}
|
113 : |
|
|
\RHS{\nt{CmpExpr} \LISTGRP{\kw{\&\&} \nt{CmpExpr}}}
|
114 : |
|
|
\end{Rules}}
|
115 : |
|
|
\newcommand{\CmpExprRULES}{
|
116 : |
|
|
\begin{Rules}{AddExprCmpExpr}
|
117 : |
|
|
\RHS{\nt{AddExpr} \LISTGRP{\nt{CmpOp} \nt{AddExpr}}}
|
118 : |
|
|
\end{Rules}}
|
119 : |
|
|
\newcommand{\AddExprRULES}{
|
120 : |
|
|
\begin{Rules}{AddExpr}
|
121 : |
|
|
\RHS{\nt{MulExpr} \LISTGRP{\nt{AddOp} \nt{MulExpr}}}
|
122 : |
|
|
\end{Rules}}
|
123 : |
|
|
\newcommand{\MulExprRULES}{
|
124 : |
|
|
\begin{Rules}{MulExpr}
|
125 : |
|
|
\RHS{\nt{PrefixExpr} \LISTGRP{\nt{MulOp} \nt{PrefixExpr}}}
|
126 : |
|
|
\end{Rules}}
|
127 : |
|
|
\newcommand{\PrefixExprRULES}{
|
128 : |
|
|
\begin{Rules}{PrefixExpr}
|
129 : |
|
|
\RHS{\nt{SelExpr}}
|
130 : |
|
|
\RHS{\kw{-} \nt{PrefixExpr}}
|
131 : |
|
|
\RHS{\kw{!} \nt{PrefixExpr}}
|
132 : |
|
|
\RHS{\kw{D} \nt{PrefixExpr}}
|
133 : |
|
|
\end{Rules}}
|
134 : |
|
|
\newcommand{\SelExprRULES}{
|
135 : |
|
|
\begin{Rules}{SelExpr}
|
136 : |
|
|
\RHS{\nt{AtomExp} \LISTGRP{\kw{@} \nt{AtomExp} $\;|\;$ \kw{[} \nt{Expr} \kw{]}}}
|
137 : |
|
|
\end{Rules}}
|
138 : |
|
|
\newcommand{\AtomExpRULES}{
|
139 : |
|
|
\begin{Rules}{AtomExp}
|
140 : |
|
|
\RHS{\term{Id} \OPTGRP{\kw{(} \nt{Arguments} \kw{)}}}
|
141 : |
jhr |
98 |
\RHS{\kw{real} \kw{(} \nt{Expr} \kw{)}}
|
142 : |
|
|
\RHS{\kw{[} \nt{Expr} \LISTGRP{\kw{,} \nt{Expr}} \kw{]}}
|
143 : |
jhr |
97 |
\RHS{\term{Int}}
|
144 : |
|
|
\RHS{\term{Float}}
|
145 : |
|
|
\RHS{\term{String}}
|
146 : |
|
|
\RHS{\kw{(} \nt{Expr} \LISTGRP{\kw{,} \nt{Expr}} \kw{)}}
|
147 : |
|
|
\RHS{\kw{$|$} \nt{Expr} \kw{$|$}}
|
148 : |
|
|
\end{Rules}}
|
149 : |
|
|
\newcommand{\ArgumentsRULES}{
|
150 : |
|
|
\begin{Rules}{Arguments}
|
151 : |
|
|
\RHS{\OPTGRP{\nt{Expr} \LISTGRP{\kw{,} \nt{Expr}}}}
|
152 : |
|
|
\end{Rules}}
|
153 : |
|
|
\newcommand{\CmpOpRULES}{
|
154 : |
|
|
\begin{Rules}{CmpOp}
|
155 : |
|
|
\RHS{\kw{<}}
|
156 : |
|
|
\RHS{\kw{<=}}
|
157 : |
|
|
\RHS{\kw{==}}
|
158 : |
|
|
\RHS{\kw{!=}}
|
159 : |
|
|
\RHS{\kw{>=}}
|
160 : |
|
|
\RHS{\kw{>}}
|
161 : |
|
|
\end{Rules}}
|
162 : |
|
|
\newcommand{\AddOpRULES}{
|
163 : |
|
|
\begin{Rules}{AddOp}
|
164 : |
|
|
\RHS{\kw{+}}
|
165 : |
|
|
\RHS{\kw{-}}
|
166 : |
|
|
\end{Rules}}
|
167 : |
|
|
\newcommand{\MulOpRULES}{
|
168 : |
|
|
\begin{Rules}{MulOp}
|
169 : |
|
|
\RHS{\kw{*}}
|
170 : |
|
|
\RHS{\kw{/}}
|
171 : |
|
|
\end{Rules}}
|