From 4a943d4ed313eff001504c2b5c472266e86a38af Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 12 Mar 2019 18:56:55 -0700 Subject: 5001 - drop the :(scenario) DSL I've been saying for a while[1][2][3] that adding extra abstractions makes things harder for newcomers, and adding new notations doubly so. And then I notice this DSL in my own backyard. Makes me feel like a hypocrite. [1] https://news.ycombinator.com/item?id=13565743#13570092 [2] https://lobste.rs/s/to8wpr/configuration_files_are_canary_warning [3] https://lobste.rs/s/mdmcdi/little_languages_by_jon_bentley_1986#c_3miuf2 The implementation of the DSL was also highly hacky: a) It was happening in the tangle/ tool, but was utterly unrelated to tangling layers. b) There were several persnickety constraints on the different kinds of lines and the specific order they were expected in. I kept finding bugs where the translator would silently do the wrong thing. Or the error messages sucked, and readers may be stuck looking at the generated code to figure out what happened. Fixing error messages would require a lot more code, which is one of my arguments against DSLs in the first place: they may be easy to implement, but they're hard to design to go with the grain of the underlying platform. They require lots of iteration. Is that effort worth prioritizing in this project? On the other hand, the DSL did make at least some readers' life easier, the ones who weren't immediately put off by having to learn a strange syntax. There were fewer quotes to parse, fewer backslash escapes. Anyway, since there are also people who dislike having to put up with strange syntaxes, we'll call that consideration a wash and tear this DSL out. --- This commit was sheer drudgery. Hopefully it won't need to be redone with a new DSL because I grow sick of backslashes. --- 017parse_tree.cc | 72 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 27 deletions(-) (limited to '017parse_tree.cc') diff --git a/017parse_tree.cc b/017parse_tree.cc index f0130d97..02170f6d 100644 --- a/017parse_tree.cc +++ b/017parse_tree.cc @@ -10,12 +10,16 @@ // For now you can't use the simpler 'colon-based' representation inside type // trees. Once you start typing parens, keep on typing parens. -:(scenarios load) -:(scenario dilated_reagent_with_nested_brackets) -def main [ - {1: number, foo: (bar (baz quux))} <- copy 34 -] -+parse: product: {1: "number", "foo": ("bar" ("baz" "quux"))} +void test_dilated_reagent_with_nested_brackets() { + load( + "def main [\n" + " {1: number, foo: (bar (baz quux))} <- copy 34\n" + "]\n" + ); + CHECK_TRACE_CONTENTS( + "parse: product: {1: \"number\", \"foo\": (\"bar\" (\"baz\" \"quux\"))}\n" + ); +} :(before "End Parsing Dilated Reagent Property(value)") value = parse_string_tree(value); @@ -81,26 +85,40 @@ string_tree* parse_string_tree(istream& in) { return result; } -:(scenario dilated_reagent_with_type_tree) -% Hide_errors = true; // 'map' isn't defined yet -def main [ - {1: (foo (address array character) (bar number))} <- copy 34 -] -# just to avoid errors -container foo [ -] -container bar [ -] -+parse: product: {1: ("foo" ("address" "array" "character") ("bar" "number"))} +void test_dilated_reagent_with_type_tree() { + Hide_errors = true; // 'map' isn't defined yet + load( + "def main [\n" + " {1: (foo (address array character) (bar number))} <- copy 34\n" + "]\n" + "container foo [\n" + "]\n" + "container bar [\n" + "]\n" + ); + CHECK_TRACE_CONTENTS( + "parse: product: {1: (\"foo\" (\"address\" \"array\" \"character\") (\"bar\" \"number\"))}\n" + ); +} -:(scenario dilated_empty_tree) -def main [ - {1: number, foo: ()} <- copy 34 -] -+parse: product: {1: "number", "foo": ()} +void test_dilated_empty_tree() { + load( + "def main [\n" + " {1: number, foo: ()} <- copy 34\n" + "]\n" + ); + CHECK_TRACE_CONTENTS( + "parse: product: {1: \"number\", \"foo\": ()}\n" + ); +} -:(scenario dilated_singleton_tree) -def main [ - {1: number, foo: (bar)} <- copy 34 -] -+parse: product: {1: "number", "foo": ("bar")} +void test_dilated_singleton_tree() { + load( + "def main [\n" + " {1: number, foo: (bar)} <- copy 34\n" + "]\n" + ); + CHECK_TRACE_CONTENTS( + "parse: product: {1: \"number\", \"foo\": (\"bar\")}\n" + ); +} -- cgit 1.4.1-2-gfad0 -tty/blame/src/ui/chatwin.c?id=8966c59fe142d18ace924c7c390618cb90064f72'>^
e8fc80f5 ^
c99ff8d9 ^














9b177a9e ^
17488ca3 ^
c99ff8d9 ^

93c3feea ^
c99ff8d9 ^
25a6252a ^
c99ff8d9 ^
90b9b48a ^
c99ff8d9 ^




41fe8c22 ^
9b177a9e ^
17488ca3 ^

c99ff8d9 ^
77e854c1 ^
c99ff8d9 ^
af1124f2 ^






77e854c1 ^
af1124f2 ^














c99ff8d9 ^
40dcd597 ^
c99ff8d9 ^
93c3feea ^

2efaa464 ^

c99ff8d9 ^

9b177a9e ^
c99ff8d9 ^
40dcd597 ^
c99ff8d9 ^
93c3feea ^

c99ff8d9 ^

4fb0b4b0 ^

c99ff8d9 ^
8f1d3ab5 ^
c99ff8d9 ^
8f1d3ab5 ^
c99ff8d9 ^











4fb0b4b0 ^
c99ff8d9 ^




40dcd597 ^
c99ff8d9 ^
93c3feea ^

9d3bcf5f ^

c99ff8d9 ^
9d3bcf5f ^
8f1d3ab5 ^
9d3bcf5f ^

c99ff8d9 ^



ff9abecd ^
c99ff8d9 ^
55e857d6 ^

ff9abecd ^

8f1d3ab5 ^
ff9abecd ^


8f1d3ab5 ^
ff9abecd ^
8f1d3ab5 ^

ff9abecd ^

8f1d3ab5 ^
ff9abecd ^



8f1d3ab5 ^
ff9abecd ^


8f1d3ab5 ^
ff9abecd ^

8f1d3ab5 ^
ff9abecd ^

8f1d3ab5 ^
ff9abecd ^

8f1d3ab5 ^
ff9abecd ^

8f1d3ab5 ^
ff9abecd ^

8f1d3ab5 ^
ff9abecd ^



c99ff8d9 ^


40dcd597 ^
c99ff8d9 ^
124aaa98 ^





8f1d3ab5 ^
124aaa98 ^

c99ff8d9 ^



40dcd597 ^
c99ff8d9 ^
124aaa98 ^
c99ff8d9 ^
124aaa98 ^



8f1d3ab5 ^
124aaa98 ^

c99ff8d9 ^

24896a3b ^
c99ff8d9 ^

ae890287 ^
c99ff8d9 ^
31016a21 ^

62c2febc ^






c99ff8d9 ^
62c2febc ^

c99ff8d9 ^
62c2febc ^
8f1d3ab5 ^
c99ff8d9 ^

c99ff8d9 ^
af1124f2 ^
c99ff8d9 ^
31016a21 ^

5d6b2d0b ^
41fe8c22 ^
c99ff8d9 ^




d3389db2 ^
83422656 ^
d3389db2 ^
c99ff8d9 ^

41fe8c22 ^
c99ff8d9 ^





19a3066e ^
c99ff8d9 ^





6702bb97 ^
c99ff8d9 ^
77e854c1 ^
c99ff8d9 ^









41fe8c22 ^
c99ff8d9 ^





c14ef339 ^
41fe8c22 ^
c99ff8d9 ^


41fe8c22 ^
5d6b2d0b ^
41fe8c22 ^

c99ff8d9 ^


a978bb12 ^

c99ff8d9 ^
31016a21 ^

c99ff8d9 ^






a978bb12 ^
7b31af30 ^
c99ff8d9 ^
24f0dc27 ^
c99ff8d9 ^



6f537c38 ^
c99ff8d9 ^
31016a21 ^
c99ff8d9 ^
6f537c38 ^




24f0dc27 ^
c99ff8d9 ^




3f7f1186 ^
c99ff8d9 ^
3f7f1186 ^

c99ff8d9 ^
3f7f1186 ^
c99ff8d9 ^
c99ff8d9 ^
3f7f1186 ^
c99ff8d9 ^




3f7f1186 ^
c99ff8d9 ^
3f7f1186 ^


c99ff8d9 ^
c99ff8d9 ^
3f7f1186 ^
c99ff8d9 ^



d9435d3b ^






3bb1f124 ^
055a5f71 ^








d9435d3b ^
055a5f71 ^
d9435d3b ^











c99ff8d9 ^
77e854c1 ^
c99ff8d9 ^

d1c71e98 ^
c99ff8d9 ^










2f888979 ^
c99ff8d9 ^


8f1d3ab5 ^
c99ff8d9 ^







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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416