-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdt.grammar
320 lines (273 loc) · 19.3 KB
/
pdt.grammar
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
313
314
315
316
317
318
319
320
// This file is part of the Peano project. For conditions of distribution and
// use, please see the copyright notice at www.peano-framework.org.
Package org.peano.pdt;
Helpers
all = [ 0 .. 127 ];
dot = '.';
digit = [ '0' .. '9' ];
five = '5';
nondigit = [ '_' + [ [ 'a' .. 'z' ] + [ 'A' .. 'Z' ] ] ];
nonzero_digit = [ '1' .. '9' ];
filename_element = digit | nondigit | '-' | '_' | dot;
namespace_element = digit | nondigit | '_' | dot;
not_star = [ all - '*' ];
not_star_not_slash = [ not_star - '/' ];
cr = 13;
lf = 10;
tab = 9;
line_terminator = lf | cr | cr lf;
not_line_terminator = [[all - cr] - lf];
Tokens
token_vertex = 'vertex:';
token_cell = 'cell:';
token_state = 'state:';
token_component = 'component:';
token_namespace = 'namespace:';
token_heap_dastgen_file = 'heap-dastgen-file:';
token_read = 'read';
token_write = 'write';
token_scalar_double = 'scalar(double):';
token_scalar_int = 'scalar(int):';
token_scalar_complex = 'scalar(complex):';
token_vector_d_double = 'vector(double):';
token_vector_d_int = 'vector(int):';
token_vector_d_complex = 'vector(complex):';
token_vector_two_pow_d_double = 'vector2PowD(double):';
token_vector_two_pow_d_int = 'vector2PowD(int):';
token_vector_two_pow_d_complex = 'vector2PowD(complex):';
token_vector_five_pow_d_double = 'intergrid-operator(double):';
token_vector_five_pow_d_int = 'intergrid-operator(int):';
token_vector_five_pow_d_complex = 'intergrid-operator(complex):';
token_stencil_double = 'stencil(double):';
token_stencil_int = 'stencil(int):';
token_stencil_complex = 'stencil(complex):';
token_name = 'name:';
token_dastgen_file = 'dastgen-file:';
token_event_mapping = 'event-mapping:';
token_open_bracket = '(';
token_close_bracket = ')';
token_comma = ',';
token_adapter = 'adapter:';
token_merge_with_user_defined_adapter = 'merge-with-user-defined-mapping:';
token_merge_with_predefined_adapter = 'merge-with-predefined-mapping:';
blank = ( cr | lf | tab | ' ' ) +;
identifier = nondigit ( digit | nondigit ) *;
filename = '/' ? (filename_element + '/') * filename_element +;
namespace = '::' ? (namespace_element + '::') * namespace_element +;
traditional_comment = '/*' not_star+ '*'+ (not_star_not_slash not_star* '*'+)* '/';
documentation_comment = '/**' '*'* (not_star_not_slash not_star* '*'+)* '/';
end_of_line_comment = '//' not_line_terminator * line_terminator;
Ignored Tokens
traditional_comment,
documentation_comment,
end_of_line_comment,
blank;
Productions
description {->description} =
token_component [name]:identifier token_namespace namespace heap_dastgen_file_list? vertex cell state event_mapping_list? adapter_list?
{ -> New description( name,namespace,[heap_dastgen_file_list.heap_dastgen_file],vertex, cell, state, [event_mapping_list.event_mapping], [adapter_list.adapter] ) };
heap_dastgen_file_list {->heap_dastgen_file*} =
{single} token_heap_dastgen_file filename {-> [New heap_dastgen_file(filename)] }
| {multi} token_heap_dastgen_file filename heap_dastgen_file_list {-> [New heap_dastgen_file(filename),heap_dastgen_file_list.heap_dastgen_file] };
vertex {->vertex} =
token_vertex token_dastgen_file filename operation_list?
{ -> New vertex( filename, [operation_list.operation]) };
state {->state} =
token_state token_dastgen_file filename
{ -> New state( filename) };
cell {->cell} =
token_cell token_dastgen_file filename
{ -> New cell( filename) };
operation_list { -> operation* } =
{single_read_scalar_double} token_read token_scalar_double identifier
{ -> [New operation.read_scalar_double(identifier) ] }
| {list_read_scalar_double} token_read token_scalar_double identifier operation_list
{ -> [New operation.read_scalar_double(identifier),operation_list.operation] }
| {single_read_vector_double} token_read token_vector_d_double identifier
{ -> [New operation.read_vector_double(identifier) ] }
| {list_read_vector_double} token_read token_vector_d_double identifier operation_list
{ -> [New operation.read_vector_double(identifier),operation_list.operation] }
| {single_read_token_vector_two_pow_d_double} token_read token_vector_two_pow_d_double identifier
{ -> [New operation.read_vector_two_pow_d_double(identifier) ] }
| {list_read_token_vector_two_pow_d_double} token_read token_vector_two_pow_d_double identifier operation_list
{ -> [New operation.read_vector_two_pow_d_double(identifier),operation_list.operation] }
| {single_read_stencil_double} token_read token_stencil_double identifier
{ -> [New operation.read_stencil_double(identifier) ] }
| {list_read_stencil_double} token_read token_stencil_double identifier operation_list
{ -> [New operation.read_stencil_double(identifier),operation_list.operation] }
| {single_read_intergrid_operator_double} token_read token_vector_five_pow_d_double identifier
{ -> [New operation.read_intergrid_operator_double(identifier) ] }
| {list_read_intergrid_operator_double} token_read token_vector_five_pow_d_double identifier operation_list
{ -> [New operation.read_intergrid_operator_double(identifier),operation_list.operation] }
| {single_write_scalar_double} token_write token_scalar_double identifier
{ -> [New operation.write_scalar_double(identifier) ] }
| {list_write_scalar_double} token_write token_scalar_double identifier operation_list
{ -> [New operation.write_scalar_double(identifier),operation_list.operation] }
| {single_write_vector_two_pow_d_double} token_write token_vector_two_pow_d_double identifier
{ -> [New operation.write_vector_two_pow_d_double(identifier) ] }
| {list_write_vector_two_pow_d_double} token_write token_vector_two_pow_d_double identifier operation_list
{ -> [New operation.write_vector_two_pow_d_double(identifier),operation_list.operation] }
| {single_write_vector_double} token_write token_vector_d_double identifier
{ -> [New operation.write_vector_double(identifier) ] }
| {list_write_vector_double} token_write token_vector_d_double identifier operation_list
{ -> [New operation.write_vector_double(identifier),operation_list.operation] }
| {single_write_stencil_double} token_write token_stencil_double identifier
{ -> [New operation.write_stencil_double(identifier) ] }
| {list_write_stencil_double} token_write token_stencil_double identifier operation_list
{ -> [New operation.write_stencil_double(identifier),operation_list.operation] }
| {single_write_intergrid_operator_double} token_write token_vector_five_pow_d_double identifier
{ -> [New operation.write_intergrid_operator_double(identifier) ] }
| {list_write_intergrid_operator_double} token_write token_vector_five_pow_d_double identifier operation_list
{ -> [New operation.write_intergrid_operator_double(identifier),operation_list.operation] }
| {single_read_scalar_int} token_read token_scalar_int identifier
{ -> [New operation.read_scalar_int(identifier) ] }
| {list_read_scalar_int} token_read token_scalar_int identifier operation_list
{ -> [New operation.read_scalar_int(identifier),operation_list.operation] }
| {single_read_vector_int} token_read token_vector_d_int identifier
{ -> [New operation.read_vector_int(identifier) ] }
| {list_read_vector_int} token_read token_vector_d_int identifier operation_list
{ -> [New operation.read_vector_int(identifier),operation_list.operation] }
| {single_read_token_vector_two_pow_d_int} token_read token_vector_two_pow_d_int identifier
{ -> [New operation.read_vector_two_pow_d_int(identifier) ] }
| {list_read_token_vector_two_pow_d_int} token_read token_vector_two_pow_d_int identifier operation_list
{ -> [New operation.read_vector_two_pow_d_int(identifier),operation_list.operation] }
| {single_read_stencil_int} token_read token_stencil_int identifier
{ -> [New operation.read_stencil_int(identifier) ] }
| {list_read_stencil_int} token_read token_stencil_int identifier operation_list
{ -> [New operation.read_stencil_int(identifier),operation_list.operation] }
| {single_read_intergrid_operator_int} token_read token_vector_five_pow_d_int identifier
{ -> [New operation.read_intergrid_operator_int(identifier) ] }
| {list_read_intergrid_operator_int} token_read token_vector_five_pow_d_int identifier operation_list
{ -> [New operation.read_intergrid_operator_int(identifier),operation_list.operation] }
| {single_write_scalar_int} token_write token_scalar_int identifier
{ -> [New operation.write_scalar_int(identifier) ] }
| {list_write_scalar_int} token_write token_scalar_int identifier operation_list
{ -> [New operation.write_scalar_int(identifier),operation_list.operation] }
| {single_write_vector_two_pow_d_int} token_write token_vector_two_pow_d_int identifier
{ -> [New operation.write_vector_two_pow_d_int(identifier) ] }
| {list_write_vector_two_pow_d_int} token_write token_vector_two_pow_d_int identifier operation_list
{ -> [New operation.write_vector_two_pow_d_int(identifier),operation_list.operation] }
| {single_write_vector_int} token_write token_vector_d_int identifier
{ -> [New operation.write_vector_int(identifier) ] }
| {list_write_vector_int} token_write token_vector_d_int identifier operation_list
{ -> [New operation.write_vector_int(identifier),operation_list.operation] }
| {single_write_stencil_int} token_write token_stencil_int identifier
{ -> [New operation.write_stencil_int(identifier) ] }
| {list_write_stencil_int} token_write token_stencil_int identifier operation_list
{ -> [New operation.write_stencil_int(identifier),operation_list.operation] }
| {single_write_intergrid_operator_int} token_write token_vector_five_pow_d_int identifier
{ -> [New operation.write_intergrid_operator_int(identifier) ] }
| {list_write_intergrid_operator_int} token_write token_vector_five_pow_d_int identifier operation_list
{ -> [New operation.write_intergrid_operator_int(identifier),operation_list.operation] }
| {single_read_scalar_complex} token_read token_scalar_complex identifier
{ -> [New operation.read_scalar_complex(identifier) ] }
| {list_read_scalar_complex} token_read token_scalar_complex identifier operation_list
{ -> [New operation.read_scalar_complex(identifier),operation_list.operation] }
| {single_read_vector_complex} token_read token_vector_d_complex identifier
{ -> [New operation.read_vector_complex(identifier) ] }
| {list_read_vector_complex} token_read token_vector_d_complex identifier operation_list
{ -> [New operation.read_vector_complex(identifier),operation_list.operation] }
| {single_read_token_vector_two_pow_d_complex} token_read token_vector_two_pow_d_complex identifier
{ -> [New operation.read_vector_two_pow_d_complex(identifier) ] }
| {list_read_token_vector_two_pow_d_complex} token_read token_vector_two_pow_d_complex identifier operation_list
{ -> [New operation.read_vector_two_pow_d_complex(identifier),operation_list.operation] }
| {single_read_stencil_complex} token_read token_stencil_complex identifier
{ -> [New operation.read_stencil_complex(identifier) ] }
| {list_read_stencil_complex} token_read token_stencil_complex identifier operation_list
{ -> [New operation.read_stencil_complex(identifier),operation_list.operation] }
| {single_read_intergrid_operator_complex} token_read token_vector_five_pow_d_complex identifier
{ -> [New operation.read_intergrid_operator_complex(identifier) ] }
| {list_read_intergrid_operator_complex} token_read token_vector_five_pow_d_complex identifier operation_list
{ -> [New operation.read_intergrid_operator_complex(identifier),operation_list.operation] }
| {single_write_scalar_complex} token_write token_scalar_complex identifier
{ -> [New operation.write_scalar_complex(identifier) ] }
| {list_write_scalar_complex} token_write token_scalar_complex identifier operation_list
{ -> [New operation.write_scalar_complex(identifier),operation_list.operation] }
| {single_write_vector_two_pow_d_complex} token_write token_vector_two_pow_d_complex identifier
{ -> [New operation.write_vector_two_pow_d_complex(identifier) ] }
| {list_write_vector_two_pow_d_complex} token_write token_vector_two_pow_d_complex identifier operation_list
{ -> [New operation.write_vector_two_pow_d_complex(identifier),operation_list.operation] }
| {single_write_vector_complex} token_write token_vector_d_complex identifier
{ -> [New operation.write_vector_complex(identifier) ] }
| {list_write_vector_complex} token_write token_vector_d_complex identifier operation_list
{ -> [New operation.write_vector_complex(identifier),operation_list.operation] }
| {single_write_stencil_complex} token_write token_stencil_complex identifier
{ -> [New operation.write_stencil_complex(identifier) ] }
| {list_write_stencil_complex} token_write token_stencil_complex identifier operation_list
{ -> [New operation.write_stencil_complex(identifier),operation_list.operation] }
| {single_write_intergrid_operator_complex} token_write token_vector_five_pow_d_complex identifier
{ -> [New operation.write_intergrid_operator_complex(identifier) ] }
| {list_write_intergrid_operator_complex} token_write token_vector_five_pow_d_complex identifier operation_list
{ -> [New operation.write_intergrid_operator_complex(identifier),operation_list.operation] }
;
event_mapping_list {->event_mapping*} =
{single} token_event_mapping token_name identifier
{ -> [New event_mapping(identifier)] }
| {list} token_event_mapping token_name identifier event_mapping_list
{ -> [New event_mapping(identifier),event_mapping_list.event_mapping] };
adapter_list {->adapter*} =
{single} token_adapter token_name identifier merge_with_user_defined_adapter_list? merge_with_predefined_adapter_list?
{ -> [New adapter(identifier,[merge_with_user_defined_adapter_list.identifier],[merge_with_predefined_adapter_list.predefined_adapter])] }
| {list} token_adapter token_name identifier merge_with_user_defined_adapter_list? merge_with_predefined_adapter_list? adapter_list
{ -> [New adapter(identifier,[merge_with_user_defined_adapter_list.identifier],[merge_with_predefined_adapter_list.predefined_adapter]),adapter_list.adapter] };
merge_with_user_defined_adapter_list {->identifier*} =
{single} token_merge_with_user_defined_adapter identifier
{ -> [identifier] }
| {list} token_merge_with_user_defined_adapter identifier merge_with_user_defined_adapter_list
{ -> [identifier,merge_with_user_defined_adapter_list.identifier] };
merge_with_predefined_adapter_list {->predefined_adapter*} =
{single_with_parameter} token_merge_with_predefined_adapter identifier token_open_bracket predefined_adapter_parameter_list token_close_bracket
{ -> [New predefined_adapter(identifier,[predefined_adapter_parameter_list.identifier])] }
| {list_with_parameter} token_merge_with_predefined_adapter identifier token_open_bracket predefined_adapter_parameter_list token_close_bracket merge_with_predefined_adapter_list
{ -> [New predefined_adapter(identifier,[predefined_adapter_parameter_list.identifier]),merge_with_predefined_adapter_list.predefined_adapter] }
| {single_without_parameter} token_merge_with_predefined_adapter identifier token_open_bracket token_close_bracket
{ -> [New predefined_adapter(identifier,[])] }
| {list_without_parameter} token_merge_with_predefined_adapter identifier token_open_bracket token_close_bracket merge_with_predefined_adapter_list
{ -> [New predefined_adapter(identifier,[]),merge_with_predefined_adapter_list.predefined_adapter] };
predefined_adapter_parameter_list {->identifier*} =
{single} identifier
{ -> [identifier] }
| {list} identifier token_comma predefined_adapter_parameter_list
{ -> [identifier,predefined_adapter_parameter_list.identifier] };
Abstract Syntax Tree
description = [name]:identifier namespace heap_dastgen_file* vertex cell state event_mapping* adapter*;
repository = [name]:identifier;
vertex = [filename]:filename operation*;
operation =
{read_scalar_double} [name]:identifier
| {read_vector_double} [name]:identifier
| {read_vector_two_pow_d_double} [name]:identifier
| {read_stencil_double} [name]:identifier
| {read_intergrid_operator_double} [name]:identifier
| {write_scalar_double} [name]:identifier
| {write_vector_double} [name]:identifier
| {write_vector_two_pow_d_double} [name]:identifier
| {write_stencil_double} [name]:identifier
| {write_intergrid_operator_double} [name]:identifier
| {read_scalar_int} [name]:identifier
| {read_vector_int} [name]:identifier
| {read_vector_two_pow_d_int} [name]:identifier
| {read_stencil_int} [name]:identifier
| {read_intergrid_operator_int} [name]:identifier
| {write_scalar_int} [name]:identifier
| {write_vector_int} [name]:identifier
| {write_vector_two_pow_d_int} [name]:identifier
| {write_stencil_int} [name]:identifier
| {write_intergrid_operator_int} [name]:identifier
| {read_scalar_complex} [name]:identifier
| {read_vector_complex} [name]:identifier
| {read_vector_two_pow_d_complex} [name]:identifier
| {read_stencil_complex} [name]:identifier
| {read_intergrid_operator_complex} [name]:identifier
| {write_scalar_complex} [name]:identifier
| {write_vector_complex} [name]:identifier
| {write_vector_two_pow_d_complex} [name]:identifier
| {write_stencil_complex} [name]:identifier
| {write_intergrid_operator_complex} [name]:identifier
;
cell = [filename]:filename;
state = [filename]:filename;
heap_dastgen_file = [filename]:filename;
event_mapping = [name]:identifier;
adapter = [name]:identifier [user_defined]:identifier* predefined_adapter*;
predefined_adapter = [name]:identifier [parameters]:identifier*;