• R/O
  • SSH
  • HTTPS

descartes: Commit


Commit MetaInfo

Revision1650 (tree)
Time2012-12-20 20:40:51
Authorhniwa

Log Message

update of example

Change Summary

Incremental Difference

--- trunk/descartes/example/translator/pl0.8/r.c (nonexistent)
+++ trunk/descartes/example/translator/pl0.8/r.c (revision 1650)
@@ -0,0 +1,33 @@
1+#include <stdio.h>
2+#include <stdlib.h>
3+typedef int (*func) ();
4+
5+int main()
6+{
7+#define N (10)
8+ static int ary1[N];
9+ static int ary2[N * 2];
10+ static int i;
11+ int a(int i) {
12+ {
13+ return ary1[i];
14+ }
15+ }
16+ int b(int i) {
17+ {
18+ return ary2[i];
19+ }
20+ }
21+ {
22+ for (i = 0; i < N; i = i + 1) { {
23+ ary1[i] = i;
24+ ary2[i] = N - i;
25+ ary2[i * 2] = i;
26+ }
27+ }
28+ printf("%d ", a(7));
29+ printf("%d ", b(3));
30+ printf("%d ", b(2 * 7));
31+ printf("\n");
32+ }
33+}
--- trunk/descartes/example/translator/pl0.8/c.c (nonexistent)
+++ trunk/descartes/example/translator/pl0.8/c.c (revision 1650)
@@ -0,0 +1,66 @@
1+#include <stdio.h>
2+#include <stdlib.h>
3+typedef int (*func) ();
4+
5+int main()
6+{
7+ static func INC;
8+ static func DEC;
9+ static func DOUBLE;
10+ static func PR;
11+ int counter() {
12+ {
13+ static int n;
14+ int Inc() {
15+ {
16+ n = n + 1;
17+ printf("%d ", n);
18+ printf("\n");
19+ }
20+ }
21+ int Dec() {
22+ {
23+ n = n - 1;
24+ printf("%d ", n);
25+ printf("\n");
26+ }
27+ }
28+ int Double() {
29+ {
30+ n = n * 2;
31+ printf("%d ", n);
32+ printf("\n");
33+ }
34+ }
35+ int Pr() {
36+ {
37+ printf("%d ", n);
38+ printf("\n");
39+ }
40+ }
41+ n = 0;
42+ INC = Inc;
43+ DEC = Dec;
44+ DOUBLE = Double;
45+ PR = Pr;
46+ }
47+ }
48+ {
49+ counter();
50+ PR();
51+ INC();
52+ INC();
53+ INC();
54+ INC();
55+ INC();
56+ INC();
57+ INC();
58+ DEC();
59+ DEC();
60+ DEC();
61+ INC();
62+ INC();
63+ DOUBLE();
64+ PR();
65+ }
66+}
Show on old repository browser