SCM Repository
Annotation of /branches/vis15/doc/syntax.md
Parent Directory
|
Revision Log
Revision 3995 - (view) (download)
1 : | jhr | 3822 | ## Collected syntax of Diderot |
2 : | |||
3 : | |||
4 : | :---------------|:--:|:----------- | ||
5 : | jhr | 3995 | _Program_ | ::= | { _GlobalDcl_ } [ _Block_ ] _StrandDcl_ _InitialStrands_ [ _GlobalInitially_ ] [ _GlobalUpdate_ ] |
6 : | jhr | 3822 | | | | | |
7 : | _GlobalDcl_ | ::= | _InputDcl_ | ||
8 : | | \| | _ConstDcl_ | ||
9 : | | \| | _GlobalVarDcl_ | ||
10 : | | \| | _FunctionDcl_ | ||
11 : | | | | | | ||
12 : | _InputDcl_ | ::= | **input** _ValueType_ Id [ `(` String `)` ] [ `=` _ConstExpr_ ] `;` | ||
13 : | | | | | | ||
14 : | _ConstDcl_ | ::= | **const** _ValueType_ Id [ `=` _ConstExpr_ ] `;` | ||
15 : | | | | | | ||
16 : | _GlobalVarDcl_ | ::= | _Type_ Id [ `=` _Expression_ ] `;` | ||
17 : | | | | | | ||
18 : | _FunctionDcl_ | ::= | **function** _Type_ Id `(` _Parameters_ `)` `=` _Expression_ `;` | ||
19 : | | \| | **function** _Type_ Id `(` _Parameters_ `)` _Block_ | ||
20 : | | | | | | ||
21 : | _Parameters_ | ::= | [ _Parameter_ { `,` _Parameter_ } ] | ||
22 : | | | | | | ||
23 : | _Parameter_ | ::= | _Type_ Id | ||
24 : | | | | | | ||
25 : | _StrandDcl_ | ::= | **strand** Id _Parameters_ `{` { _StateVarDcl_ } { _MethodDcl_ } `}` | ||
26 : | | | | | | ||
27 : | _MethodDcl_ | ::= | _MethodName_ _Block_ | ||
28 : | | | | | | ||
29 : | _MethodName_ | ::= | **initially** \| **update** \| **stabilize** | ||
30 : | | | | | | ||
31 : | _InitialStrands_ | ::= | **collection** _Comprehension_ | ||
32 : | | \| | **grid** `(` _ConstExpr_ `)` _Comprehension_ | ||
33 : | | | | | | ||
34 : | jhr | 3995 | _GlobalInitially_ | ::= | **initially** _Block_ |
35 : | jhr | 3822 | | | | | |
36 : | jhr | 3995 | _GlobalUpdate_ | ::= | **update** _Block_ |
37 : | | | | | | ||
38 : | jhr | 3822 | _Block_ | ::= | `{` { _Statement_ } `}` |
39 : | | | | | | ||
40 : | _Statement_ | ::= | _Block_ | ||
41 : | | \| | **if** `(` _Expression_ `)` _Block_ { _ElseIf_ } [ **else** _Block_ ] | ||
42 : | | \| | **foreach** `(` _Iterator_ `)` _Block_ | ||
43 : | | \| | **print** `(` _Expression_ { `,` _Expression_ } `)` `;` | ||
44 : | | \| | **new** Id `(` _Arguments_ `)` `;` | ||
45 : | | \| | **stabilize** `;` | ||
46 : | | \| | **die** `;` | ||
47 : | | \| | **continue** `;` | ||
48 : | | \| | **return** _Expression_ `;` | ||
49 : | | \| | _Type_ Id `=` _Expression_ `;` | ||
50 : | | \| | Id _AssignOp_ _Expression_ `;` | ||
51 : | | | | | | ||
52 : | _ElseIf_ | ::= | **else** **if** `(` _Expression_ `)` _Block_ | ||
53 : | | | | | | ||
54 : | _AssignOp_ | ::= | `=` \| `+=` \| `-=` \| `*=` \| `/=` \| `%=` | ||
55 : | | | | | | ||
56 : | _Type_ | ::= | **image** `(` _ConstExpr_ `)` _Shape_ | ||
57 : | | \| | **field** `#` _Dimension_ `(` _ConstExpr_ `)` _Shape_ | ||
58 : | | \| | **kernel** `#` _Dimension_ | ||
59 : | | \| | _ConcreteType_ | ||
60 : | | | | | | ||
61 : | _Dimension_ | ::= | Int | ||
62 : | | | | | | ||
63 : | _ConcreteType_ | ::= | _PrimitiveType_ [ _SequenceDims_ ] | ||
64 : | | | | | | ||
65 : | _SequenceDims_ | ::= | | ||
66 : | | \| | `[` `]` | ||
67 : | | \| | `[` _ConstExpr_ `]` | ||
68 : | | | | | | ||
69 : | _PrimitiveType_ | ::= | **tensor** _Shape_ | ||
70 : | | \| | **vec2** | ||
71 : | | \| | **vec3** | ||
72 : | | \| | **vec4** | ||
73 : | | \| | **mat2** | ||
74 : | | \| | **mat3** | ||
75 : | | \| | **mat4** | ||
76 : | | \| | **bool** | ||
77 : | | \| | **int** | ||
78 : | | \| | **real** | ||
79 : | | \| | **string** | ||
80 : | | | | | | ||
81 : | _Shape_ | ::= | `[` [ _ConstExpr_ { `,` _ConstExpr_ } ] `]` | ||
82 : | | | | | | ||
83 : | _Comprehension_ | ::= | `{` _Expression_ `|` _Iterator_ { `,` _Iterator_ } `}` | ||
84 : | | | | | | ||
85 : | _Iterator_ | ::= | Id **in** _Expression_ | ||
86 : | | | | | | ||
87 : | _Expression_ | ::= | _RangeExpr_ [ `?` _Expression_ `:` _Expression_ ] | ||
88 : | | | | | | ||
89 : | _RangeExpr_ | ::= | _OrExpr_ `..` _OrExpr_ | ||
90 : | | | | | | ||
91 : | _OrExpr_ | ::= | _AndExpr_ { `||` _AndExpr_ } | ||
92 : | | | | | | ||
93 : | _AndExpr_ | ::= | _CompareExpr_ { `&&` _CompareExpr_ } | ||
94 : | | | | | | ||
95 : | _CompareExpr_ | ::= | _AddExpr_ { _CompareOp_ _AddExpr_ } | ||
96 : | | | | | | ||
97 : | _CompareOp_ | ::= | `<` \| `<=` \| `==` \| `!=` \| `>=` \| `>` | ||
98 : | | | | | | ||
99 : | _AddExpr_ | ::= | _MultiplyExpr_ { _AddOp_ _MultiplyExpr_ } | ||
100 : | | | | | | ||
101 : | _AddOp_ | ::= | `+` \| `-` \| `@` | ||
102 : | | | | | | ||
103 : | _MultiplyExpr_ | ::= | _PrefixExpr_ { _MultiplyOp_ _PrefixExpr_ } | ||
104 : | | | | | | ||
105 : | _MultiplyOp_ | ::= | `*` \| `/` \| `%` \| `⊛` \| `•` \| `×` \| `⊗` \| `:` | ||
106 : | | | | | | ||
107 : | _PrefixExpr_ | ::= | _PowerExpr_ | ||
108 : | | \| | _PrefixOp_ _PrefixExpr_ | ||
109 : | | | | | | ||
110 : | _PrefixOp_ | ::= | `-` \| `!` | ||
111 : | | | | | | ||
112 : | _PowerExpr_ | ::= | _SuffixExpr_ { `^` _SuffixExpr_ } | ||
113 : | | | | | | ||
114 : | _SuffixExpr_ | ::= | _DiffExpr_ { _Suffix_ } | ||
115 : | | \| | **real** `(` _Expression_ `)` | ||
116 : | | \| | **load** `(` _ConstExpr_ `)` | ||
117 : | | \| | **image** `(` _ConstExpr_ `)` | ||
118 : | | | | | | ||
119 : | _Suffix_ | ::= | _AtomicExpr_ | ||
120 : | | \| | `[` _Indices_ `]` | ||
121 : | | \| | `.` Id | ||
122 : | | | | | | ||
123 : | _Indices_ | ::= | _IndexExpr_ [ `,` _IndexExpr_ ] | ||
124 : | | | | | | ||
125 : | _IndexExpr_ | ::= | _Expression_ | ||
126 : | | \| | `:` | ||
127 : | | | | | | ||
128 : | _DiffExpr_ | ::= | _AtomicExpr_ | ||
129 : | | \| | _DiffOp_ _DiffExpr_ | ||
130 : | | | | | | ||
131 : | _DiffOp_ | ::= | `∇` \| `∇⊗` \| `∇×` \| `∇•` | ||
132 : | | | | | | ||
133 : | _AtomicExpr_ | ::= | Id | ||
134 : | | \| | Id `#` _Dimension_ | ||
135 : | | \| | Int | ||
136 : | | \| | Real | ||
137 : | | \| | String | ||
138 : | | \| | **true** | ||
139 : | | \| | **false** | ||
140 : | | \| | **identity** `[` _ConstExpr_ `]` | ||
141 : | | \| | **zeros** [ _Shape_ ] | ||
142 : | | \| | **nan** [ _Shape_ ] | ||
143 : | | \| | `{` _Expression_ `|` _Iterator_ `}` | ||
144 : | | \| | `(` _Expression_ { `,` _Expression_ } `)` | ||
145 : | | \| | `{` `}` | ||
146 : | | \| | `{` _Expression_ { `,` _Expression_ } `}` | ||
147 : | | \| | `[` _Expression_ { `,` _Expression_ } `]` | ||
148 : | | \| | `|` _Expression_ `|` | ||
149 : | | \| | `(` _Arguments_ `)` | ||
150 : | | | | | | ||
151 : | _Arguments_ | ::= | [ _Expression_ { `,` _Expression_ } ] | ||
152 : | | | | | | ||
153 : | _ConstExpr_ | ::= | _Expression_ | ||
154 : | |||
155 : | |||
156 : | ### Syntactic restrictions | ||
157 : | |||
158 : | * Constant expressions (_ConstExpr_) are restricted to have a concrete type (_ConcreteType_) | ||
159 : | and be can be evaluated statically. | ||
160 : | |||
161 : | * When indexing a tensor or field (e.g., `e1[e2]`), the index expression must be a constant | ||
162 : | expression. | ||
163 : | |||
164 : | ### Questions | ||
165 : | |||
166 : | * What about tuples? Can we have sequences of tuples? Tuples of sequences? Fields inside | ||
167 : | tuples? |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |