git @ Cat's Eye Technologies PL-GOTO.NET / 462d0ab
Markdown(-in-LHS) tweaks. catseye 8 years ago
1 changed file(s) with 16 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
0 encoding: UTF-8
1
20 PL-{GOTO}.NET
31 =============
42
4947
5048 Sample code from the book:
5149
52 V ← 0;
53 LOOP W;
54 LOOP X;
50 V ← 0;
51 LOOP W;
52 LOOP X;
53 V ← V + 1;
54 END;
55 GOTO L;
56 END;
57 LOOP Y;
5558 V ← V + 1;
5659 END;
57 GOTO L;
58 END;
59 LOOP Y;
60 V ← V + 1;
61 END;
62 L: LOOP Z;
63 V ← V + 1;
64 END;
60 L: LOOP Z;
61 V ← V + 1;
62 END;
6563
6664 Since we are implementing PL-{GOTO}, we can simplify the grammar; we do not
6765 accept GOTO instructions or labels. The "label instruction" production
285283
286284 The generated source consists of:
287285
288 * a prelude, which is the same for all programs;
289 * a declaration of all the variables used in the program;
290 * generated code corresponding to the computation proper;
291 * a set of statements to display the final values of all variables; and
292 * a postlude, which is the same for all programs.
286 * a prelude, which is the same for all programs;
287 * a declaration of all the variables used in the program;
288 * generated code corresponding to the computation proper;
289 * a set of statements to display the final values of all variables; and
290 * a postlude, which is the same for all programs.
293291
294292 > translate ast =
295293 > let