-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmenu.rkt
193 lines (183 loc) · 6.62 KB
/
xmenu.rkt
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
#lang racket
(require "xio.rkt"
"x-misc.rkt"
"xpre.rkt"
"xgen.rkt"
"xpost.rkt"
"x-macro.rkt")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; File: xmenu.scm ;;
;; Project: the specializer Unmix ;;
;; Author: S.A.Romanenko, the Institute for Applied ;;
;; Mathematics, the USSR Acedemy of Sciences, ;;
;; Moscow. ;;
;; Created: 11 April 1990 ;;
;; Revised: July 1990, December 1992, October 1993, December 2013;;
;; ;;
;; Contents: The main function of Unmix. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define uctmw:Scheme-to-Mixwell #f)
(define uctmwrl:rem-let-prog #f)
(define uctmwrl:cut-let-prog #f)
(define usepsd:unmix-static-and-dynamic #f)
(define ufcd:find-congruent-division #f)
(define uann:make-annotated-program #f)
(define uresfn:collect-residual-functions #f)
(define upiu:prevent-infinite-unfolding! #f)
(define upcd:prevent-call-duplication! #f)
(define umainpe:generate-residual-program #f)
(define xapply #f)
(define $specialize-fundef #f)
(define ucgr:main #f)
(define uar:main #f)
(define uarta:analyze-argument-types #f)
(define uaraa:analyze-parameter-access! #f)
(define uarps:optimize #f)
(define uensg:main #f)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Main Function ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (unmix)
(ux:main))
(define (ux:main)
(set! uctmw:Scheme-to-Mixwell #f)
(set! uctmwrl:rem-let-prog #f)
(set! uctmwrl:cut-let-prog #f)
(set! usepsd:unmix-static-and-dynamic #f)
(set! ufcd:find-congruent-division #f)
(set! uann:make-annotated-program #f)
(set! uresfn:collect-residual-functions #f)
(set! upiu:prevent-infinite-unfolding! #f)
(set! upcd:prevent-call-duplication! #f)
(set! umainpe:generate-residual-program #f)
(set! xapply #f)
(set! $specialize-fundef #f)
(set! ucgr:main #f)
(set! uar:main #f)
(set! uarta:analyze-argument-types #f)
(set! uaraa:analyze-parameter-access! #f)
(set! uarps:optimize #f)
(set! uensg:main #f)
(let ((reply
(uio:display-menu
'("U N M I X : M a i n m e n u")
25
'("Preprocessing"
"Residual program generation"
"pOstprocessing"
""
"Compile SEX to RKT"
"eValuating Scheme expression"
""
"Quit Unmix"
"eXit Scheme")
"Work to do"
'(P R O C V Q X))))
(when (memq reply '(C V S Q))
(uio:clear-screen))
(case reply
((P) (ux:pre:main))
((R) (ux:gen:main))
((O) (ux:post:main))
((C) (ux:cmp:main) (uio:pause) (ux:main))
((V)
(display "Enter an expression:") (newline)
(let ((result (eval-t (read))))
(do () ((not (char-ready?))) (read-char))
(newline)(write result)
(uio:pause)
(ux:main)))
((Q)
(display "Enter \"(unmix)\" to resume Unmix")(newline)
'OK)
((X) (exit)))))
(define (ux:pre:main)
(define (pre-switch action)
(upre:switch action)
'OK)
(let ((reply
(uio:display-menu
'("U N M I X : P r e p r o c e s s i n g")
6
'("Preprocessing ann(desugar(s-prog),sdsd) -> ann-prog"
""
"Desugaring desugar(s-prog) -> mw-prog"
"Annotating Mixwell program ann(mw-prog,sdsd) -> ann-prog"
"Expanding macros ensugar(desugar(s-prog)) -> s-prog"
""
"Main menu")
"Work to do"
'(P D A E M))))
(when (memq reply '(P D R A))
(uio:clear-screen))
(case reply
((P) (pre-switch 'pre) (uio:pause) (ux:main))
((D) (pre-switch 'dsg) (uio:pause) (ux:main))
((A) (pre-switch 'ann) (uio:pause) (ux:main))
((E) (pre-switch 'rmm) (uio:pause) (ux:main))
(else (ux:main)))))
(define (ux:gen:main)
(define (gen-switch action)
(ugen:switch action)
'OK)
(let ((reply
(uio:display-menu
'("U N M I X : G e n e r a t i o n")
9
'("Residual program generation pe(ann-prog,statics) -> res-prog"
"Self-application pe(ann-pe,ann-prog) -> gen"
"Double self-application pe(ann-pe,ann-pe) -> gen-gen"
"Generator generation gen-gen(ann-prog) -> gen"
"Using program generator gen(statics) -> res-prog"
""
"Main menu")
"Work to do"
'(R S D G U M))))
(when (memq reply '(R S D G U))
(uio:clear-screen))
(case reply
((R) (gen-switch 'pe) (uio:pause) (ux:main))
((S) (gen-switch 'pepe) (uio:pause) (ux:main))
((D) (gen-switch 'pepepe) (uio:pause) (ux:main))
((G) (gen-switch 'gengen) (uio:pause) (ux:main))
((U) (gen-switch 'gen) (uio:pause) (ux:main))
(else (ux:main)))))
(define (ux:post:main)
(define (post-switch action)
(upost:switch action)
'OK)
(let ((reply
(uio:display-menu
'("U N M I X : P o s t p r o c e s s i n g")
10
'("Postprocessing post(mw-prog) -> s-prog"
"Call graph reduction cgr(mw-prog) -> mw-prog"
"Arity raising ar(mw-prog) -> mw-prog"
"Ensugaring ensugar(mw-prog) -> s-prog"
"Formatting format(prog) -> prog"
""
"Main menu")
"Work to do"
'(P C A E F M))))
(when (memq reply '(P C A E F))
(uio:clear-screen))
(case reply
((P) (post-switch 'post) (uio:pause) (ux:main))
((C) (post-switch 'cgr) (uio:pause) (ux:main))
((A) (post-switch 'ar) (uio:pause) (ux:main))
((E) (post-switch 'ensugar) (uio:pause) (ux:main))
((F) (post-switch 'form) (uio:pause) (ux:main))
(else (ux:main)))))
(define (ux:cmp:main)
(let* ((src
(uio:request-file-name
"Source Scheme program file name" "" "sex"))
(file-name (uio:cut-off-ext src))
)
(sex file-name)
'OK))
(provide (all-defined-out))