shen-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +0 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/MIT_LICENSE.txt +26 -0
- data/README.md +94 -0
- data/bin/shen_test_suite.rb +9 -0
- data/bin/srrepl +23 -0
- data/lib/kl.rb +7 -0
- data/lib/kl/absvector.rb +12 -0
- data/lib/kl/compiler.rb +253 -0
- data/lib/kl/cons.rb +51 -0
- data/lib/kl/empty_list.rb +12 -0
- data/lib/kl/environment.rb +123 -0
- data/lib/kl/error.rb +4 -0
- data/lib/kl/internal_error.rb +7 -0
- data/lib/kl/lexer.rb +186 -0
- data/lib/kl/primitives/arithmetic.rb +60 -0
- data/lib/kl/primitives/assignments.rb +18 -0
- data/lib/kl/primitives/booleans.rb +17 -0
- data/lib/kl/primitives/error_handling.rb +13 -0
- data/lib/kl/primitives/generic_functions.rb +22 -0
- data/lib/kl/primitives/lists.rb +21 -0
- data/lib/kl/primitives/streams.rb +38 -0
- data/lib/kl/primitives/strings.rb +55 -0
- data/lib/kl/primitives/symbols.rb +17 -0
- data/lib/kl/primitives/time.rb +17 -0
- data/lib/kl/primitives/vectors.rb +30 -0
- data/lib/kl/reader.rb +40 -0
- data/lib/kl/trampoline.rb +14 -0
- data/lib/shen_ruby.rb +7 -0
- data/lib/shen_ruby/version.rb +3 -0
- data/shen-ruby.gemspec +26 -0
- data/shen/README.txt +17 -0
- data/shen/lib/shen_ruby/shen.rb +124 -0
- data/shen/license.txt +34 -0
- data/shen/release/benchmarks/N_queens.shen +45 -0
- data/shen/release/benchmarks/README.shen +14 -0
- data/shen/release/benchmarks/benchmarks.shen +56 -0
- data/shen/release/benchmarks/bigprog +2173 -0
- data/shen/release/benchmarks/br.shen +13 -0
- data/shen/release/benchmarks/einstein.shen +33 -0
- data/shen/release/benchmarks/heatwave.gif +0 -0
- data/shen/release/benchmarks/interpreter.shen +219 -0
- data/shen/release/benchmarks/picture.jpg +0 -0
- data/shen/release/benchmarks/plato.jpg +0 -0
- data/shen/release/benchmarks/powerset.shen +10 -0
- data/shen/release/benchmarks/prime.shen +10 -0
- data/shen/release/benchmarks/short.shen +129 -0
- data/shen/release/benchmarks/text.txt +68 -0
- data/shen/release/k_lambda/core.kl +1002 -0
- data/shen/release/k_lambda/declarations.kl +1021 -0
- data/shen/release/k_lambda/load.kl +94 -0
- data/shen/release/k_lambda/macros.kl +479 -0
- data/shen/release/k_lambda/prolog.kl +1309 -0
- data/shen/release/k_lambda/reader.kl +1058 -0
- data/shen/release/k_lambda/sequent.kl +556 -0
- data/shen/release/k_lambda/sys.kl +582 -0
- data/shen/release/k_lambda/t-star.kl +3493 -0
- data/shen/release/k_lambda/toplevel.kl +223 -0
- data/shen/release/k_lambda/track.kl +208 -0
- data/shen/release/k_lambda/types.kl +455 -0
- data/shen/release/k_lambda/writer.kl +108 -0
- data/shen/release/k_lambda/yacc.kl +280 -0
- data/shen/release/test_programs/Chap13/problems.txt +26 -0
- data/shen/release/test_programs/README.shen +53 -0
- data/shen/release/test_programs/TinyLispFunctions.txt +16 -0
- data/shen/release/test_programs/TinyTypes.shen +55 -0
- data/shen/release/test_programs/binary.shen +24 -0
- data/shen/release/test_programs/bubble_version_1.shen +28 -0
- data/shen/release/test_programs/bubble_version_2.shen +22 -0
- data/shen/release/test_programs/calculator.shen +21 -0
- data/shen/release/test_programs/cartprod.shen +23 -0
- data/shen/release/test_programs/change.shen +25 -0
- data/shen/release/test_programs/classes-defaults.shen +94 -0
- data/shen/release/test_programs/classes-inheritance.shen +100 -0
- data/shen/release/test_programs/classes-typed.shen +74 -0
- data/shen/release/test_programs/classes-untyped.shen +46 -0
- data/shen/release/test_programs/depth_.shen +14 -0
- data/shen/release/test_programs/einstein.shen +33 -0
- data/shen/release/test_programs/fruit_machine.shen +46 -0
- data/shen/release/test_programs/interpreter.shen +219 -0
- data/shen/release/test_programs/metaprog.shen +85 -0
- data/shen/release/test_programs/minim.shen +193 -0
- data/shen/release/test_programs/mutual.shen +11 -0
- data/shen/release/test_programs/n_queens.shen +45 -0
- data/shen/release/test_programs/newton_version_1.shen +33 -0
- data/shen/release/test_programs/newton_version_2.shen +24 -0
- data/shen/release/test_programs/parse.prl +14 -0
- data/shen/release/test_programs/parser.shen +52 -0
- data/shen/release/test_programs/powerset.shen +10 -0
- data/shen/release/test_programs/prime.shen +10 -0
- data/shen/release/test_programs/proof_assistant.shen +81 -0
- data/shen/release/test_programs/proplog_version_1.shen +25 -0
- data/shen/release/test_programs/proplog_version_2.shen +27 -0
- data/shen/release/test_programs/qmachine.shen +67 -0
- data/shen/release/test_programs/red-black.shen +55 -0
- data/shen/release/test_programs/search.shen +56 -0
- data/shen/release/test_programs/semantic_net.shen +44 -0
- data/shen/release/test_programs/spreadsheet.shen +35 -0
- data/shen/release/test_programs/stack.shen +27 -0
- data/shen/release/test_programs/streams.shen +20 -0
- data/shen/release/test_programs/strings.shen +59 -0
- data/shen/release/test_programs/structures-typed.shen +71 -0
- data/shen/release/test_programs/structures-untyped.shen +42 -0
- data/shen/release/test_programs/tests.shen +294 -0
- data/shen/release/test_programs/types.shen +11 -0
- data/shen/release/test_programs/whist.shen +240 -0
- data/shen/release/test_programs/yacc.shen +136 -0
- data/spec/kl/cons_spec.rb +12 -0
- data/spec/kl/environment_spec.rb +306 -0
- data/spec/kl/lexer_spec.rb +149 -0
- data/spec/kl/primitives/generic_functions_spec.rb +29 -0
- data/spec/kl/primitives/symbols_spec.rb +21 -0
- data/spec/kl/reader_spec.rb +36 -0
- data/spec/spec_helper.rb +2 -0
- metadata +189 -0
@@ -0,0 +1,1002 @@
|
|
1
|
+
|
2
|
+
" The License
|
3
|
+
|
4
|
+
The user is free to produce commercial applications with the software, to distribute these applications in source or binary form, and to charge monies for them as he sees fit and in concordance with the laws of the land subject to the following license.
|
5
|
+
|
6
|
+
1. The license applies to all the software and all derived software and must appear on such.
|
7
|
+
2. It is illegal to distribute the software without this license attached to it and use of the software implies agreement
|
8
|
+
with the license as such. It is illegal for anyone who is not the copyright holder to tamper with or change the license.
|
9
|
+
3. Neither the names of Lambda Associates or the copyright holder may be used to endorse or promote products built using
|
10
|
+
the software without specific prior written permission from the copyright holder.
|
11
|
+
4. That possession of this license does not confer on the copyright holder any special contractual obligation towards the user. That in no event shall the copyright holder be liable for any direct, indirect, incidental, special, exemplary or consequential damages (including but not limited to procurement of substitute goods or services, loss of use, data, or profits; or business interruption), however caused and on any theory of liability, whether in contract, strict liability or tort (including negligence) arising in any way out of the use of the software, even if advised of the possibility of such damage.
|
12
|
+
5. It is permitted for the user to change the software, for the purpose of improving performance, correcting an error, or porting to a new platform, and distribute the modified version of Shen (hereafter the modified version) provided the resulting program conforms in all respects to the Shen standard and is issued under that title. The user must make it clear with his distribution that he/she is the author of the changes and what these changes are and why.
|
13
|
+
6. Derived versions of this software in whatever form are subject to the same restrictions. In particular it is not permitted to make derived copies of this software which do not conform to the Shen standard or appear under a different title.
|
14
|
+
7. It is permitted to distribute versions of Shen which incorporate libraries, graphics or other facilities which are not part of the Shen standard.
|
15
|
+
|
16
|
+
For an explication of this license see http://www.lambdassociates.org/News/june11/license.htm which explains this license in full."
|
17
|
+
|
18
|
+
(defun shen-shen->kl (V380 V381)
|
19
|
+
(compile (lambda V382 (shen-<define> V382)) (cons V380 V381)
|
20
|
+
(lambda X (shen-shen-syntax-error V380 X))))
|
21
|
+
|
22
|
+
(defun shen-shen-syntax-error (V383 V384)
|
23
|
+
(interror "syntax error in ~A here:~%~% ~A~%"
|
24
|
+
(@p V383 (@p (shen-next-50 50 V384) ()))))
|
25
|
+
|
26
|
+
(defun shen-<define> (V385)
|
27
|
+
(let Result
|
28
|
+
(let Parse_<name> (shen-<name> V385)
|
29
|
+
(if (not (= (fail) Parse_<name>))
|
30
|
+
(let Parse_<signature> (shen-<signature> Parse_<name>)
|
31
|
+
(if (not (= (fail) Parse_<signature>))
|
32
|
+
(let Parse_<rules> (shen-<rules> Parse_<signature>)
|
33
|
+
(if (not (= (fail) Parse_<rules>))
|
34
|
+
(shen-reassemble (fst Parse_<rules>)
|
35
|
+
(shen-compile_to_machine_code (snd Parse_<name>) (snd Parse_<rules>)))
|
36
|
+
(fail)))
|
37
|
+
(fail)))
|
38
|
+
(fail)))
|
39
|
+
(if (= Result (fail))
|
40
|
+
(let Result
|
41
|
+
(let Parse_<name> (shen-<name> V385)
|
42
|
+
(if (not (= (fail) Parse_<name>))
|
43
|
+
(let Parse_<rules> (shen-<rules> Parse_<name>)
|
44
|
+
(if (not (= (fail) Parse_<rules>))
|
45
|
+
(shen-reassemble (fst Parse_<rules>)
|
46
|
+
(shen-compile_to_machine_code (snd Parse_<name>) (snd Parse_<rules>)))
|
47
|
+
(fail)))
|
48
|
+
(fail)))
|
49
|
+
(if (= Result (fail)) (fail) Result))
|
50
|
+
Result)))
|
51
|
+
|
52
|
+
(defun shen-<name> (V386)
|
53
|
+
(let Result
|
54
|
+
(if (cons? (fst V386))
|
55
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V386)) (snd V386)))
|
56
|
+
(if (and (symbol? (hd (fst V386))) (not (shen-sysfunc? (hd (fst V386)))))
|
57
|
+
(hd (fst V386))
|
58
|
+
(interror "~A is not a legitimate function name.~%"
|
59
|
+
(@p (hd (fst V386)) ()))))
|
60
|
+
(fail))
|
61
|
+
(if (= Result (fail)) (fail) Result)))
|
62
|
+
|
63
|
+
(defun shen-sysfunc? (V387) (element? V387 (value shen-*system*)))
|
64
|
+
|
65
|
+
(defun shen-<signature> (V388)
|
66
|
+
(let Result
|
67
|
+
(if (and (cons? (fst V388)) (= { (hd (fst V388))))
|
68
|
+
(let Parse_<signature-help>
|
69
|
+
(shen-<signature-help> (shen-reassemble (tl (fst V388)) (snd V388)))
|
70
|
+
(if (not (= (fail) Parse_<signature-help>))
|
71
|
+
(if
|
72
|
+
(and (cons? (fst Parse_<signature-help>))
|
73
|
+
(= } (hd (fst Parse_<signature-help>))))
|
74
|
+
(shen-reassemble
|
75
|
+
(fst
|
76
|
+
(shen-reassemble (tl (fst Parse_<signature-help>))
|
77
|
+
(snd Parse_<signature-help>)))
|
78
|
+
(shen-normalise-type (shen-curry-type (snd Parse_<signature-help>))))
|
79
|
+
(fail))
|
80
|
+
(fail)))
|
81
|
+
(fail))
|
82
|
+
(if (= Result (fail)) (fail) Result)))
|
83
|
+
|
84
|
+
(defun shen-curry-type (V391)
|
85
|
+
(cond
|
86
|
+
((and (cons? V391)
|
87
|
+
(and (cons? (tl V391))
|
88
|
+
(and (= --> (hd (tl V391)))
|
89
|
+
(and (cons? (tl (tl V391)))
|
90
|
+
(and (cons? (tl (tl (tl V391))))
|
91
|
+
(= --> (hd (tl (tl (tl V391))))))))))
|
92
|
+
(shen-curry-type (cons (hd V391) (cons --> (cons (tl (tl V391)) ())))))
|
93
|
+
((and (cons? V391)
|
94
|
+
(and (= cons (hd V391))
|
95
|
+
(and (cons? (tl V391))
|
96
|
+
(and (cons? (tl (tl V391))) (= () (tl (tl (tl V391))))))))
|
97
|
+
(cons list (cons (shen-curry-type (hd (tl V391))) ())))
|
98
|
+
((and (cons? V391)
|
99
|
+
(and (cons? (tl V391))
|
100
|
+
(and (= * (hd (tl V391)))
|
101
|
+
(and (cons? (tl (tl V391)))
|
102
|
+
(and (cons? (tl (tl (tl V391)))) (= * (hd (tl (tl (tl V391))))))))))
|
103
|
+
(shen-curry-type (cons (hd V391) (cons * (cons (tl (tl V391)) ())))))
|
104
|
+
((cons? V391) (map (lambda V392 (shen-curry-type V392)) V391)) (true V391)))
|
105
|
+
|
106
|
+
(defun shen-<signature-help> (V393)
|
107
|
+
(let Result
|
108
|
+
(if (cons? (fst V393))
|
109
|
+
(let Parse_<signature-help>
|
110
|
+
(shen-<signature-help> (shen-reassemble (tl (fst V393)) (snd V393)))
|
111
|
+
(if (not (= (fail) Parse_<signature-help>))
|
112
|
+
(shen-reassemble (fst Parse_<signature-help>)
|
113
|
+
(if (element? (hd (fst V393)) (cons { (cons } ()))) (fail)
|
114
|
+
(cons (hd (fst V393)) (snd Parse_<signature-help>))))
|
115
|
+
(fail)))
|
116
|
+
(fail))
|
117
|
+
(if (= Result (fail))
|
118
|
+
(let Result
|
119
|
+
(let Parse_<e> (<e> V393)
|
120
|
+
(if (not (= (fail) Parse_<e>)) (shen-reassemble (fst Parse_<e>) ())
|
121
|
+
(fail)))
|
122
|
+
(if (= Result (fail)) (fail) Result))
|
123
|
+
Result)))
|
124
|
+
|
125
|
+
(defun shen-<rules> (V394)
|
126
|
+
(let Result
|
127
|
+
(let Parse_<rule> (shen-<rule> V394)
|
128
|
+
(if (not (= (fail) Parse_<rule>))
|
129
|
+
(let Parse_<rules> (shen-<rules> Parse_<rule>)
|
130
|
+
(if (not (= (fail) Parse_<rules>))
|
131
|
+
(shen-reassemble (fst Parse_<rules>)
|
132
|
+
(cons (snd Parse_<rule>) (snd Parse_<rules>)))
|
133
|
+
(fail)))
|
134
|
+
(fail)))
|
135
|
+
(if (= Result (fail))
|
136
|
+
(let Result
|
137
|
+
(let Parse_<rule> (shen-<rule> V394)
|
138
|
+
(if (not (= (fail) Parse_<rule>))
|
139
|
+
(shen-reassemble (fst Parse_<rule>) (cons (snd Parse_<rule>) ()))
|
140
|
+
(fail)))
|
141
|
+
(if (= Result (fail)) (fail) Result))
|
142
|
+
Result)))
|
143
|
+
|
144
|
+
(defun shen-<rule> (V395)
|
145
|
+
(let Result
|
146
|
+
(let Parse_<patterns> (shen-<patterns> V395)
|
147
|
+
(if (not (= (fail) Parse_<patterns>))
|
148
|
+
(if
|
149
|
+
(and (cons? (fst Parse_<patterns>)) (= -> (hd (fst Parse_<patterns>))))
|
150
|
+
(let Parse_<action>
|
151
|
+
(shen-<action>
|
152
|
+
(shen-reassemble (tl (fst Parse_<patterns>)) (snd Parse_<patterns>)))
|
153
|
+
(if (not (= (fail) Parse_<action>))
|
154
|
+
(if
|
155
|
+
(and (cons? (fst Parse_<action>))
|
156
|
+
(= where (hd (fst Parse_<action>))))
|
157
|
+
(let Parse_<guard>
|
158
|
+
(shen-<guard>
|
159
|
+
(shen-reassemble (tl (fst Parse_<action>)) (snd Parse_<action>)))
|
160
|
+
(if (not (= (fail) Parse_<guard>))
|
161
|
+
(shen-reassemble (fst Parse_<guard>)
|
162
|
+
(cons (snd Parse_<patterns>)
|
163
|
+
(cons
|
164
|
+
(cons where
|
165
|
+
(cons (snd Parse_<guard>) (cons (snd Parse_<action>) ())))
|
166
|
+
())))
|
167
|
+
(fail)))
|
168
|
+
(fail))
|
169
|
+
(fail)))
|
170
|
+
(fail))
|
171
|
+
(fail)))
|
172
|
+
(if (= Result (fail))
|
173
|
+
(let Result
|
174
|
+
(let Parse_<patterns> (shen-<patterns> V395)
|
175
|
+
(if (not (= (fail) Parse_<patterns>))
|
176
|
+
(if
|
177
|
+
(and (cons? (fst Parse_<patterns>))
|
178
|
+
(= -> (hd (fst Parse_<patterns>))))
|
179
|
+
(let Parse_<action>
|
180
|
+
(shen-<action>
|
181
|
+
(shen-reassemble (tl (fst Parse_<patterns>)) (snd Parse_<patterns>)))
|
182
|
+
(if (not (= (fail) Parse_<action>))
|
183
|
+
(shen-reassemble (fst Parse_<action>)
|
184
|
+
(cons (snd Parse_<patterns>) (cons (snd Parse_<action>) ())))
|
185
|
+
(fail)))
|
186
|
+
(fail))
|
187
|
+
(fail)))
|
188
|
+
(if (= Result (fail))
|
189
|
+
(let Result
|
190
|
+
(let Parse_<patterns> (shen-<patterns> V395)
|
191
|
+
(if (not (= (fail) Parse_<patterns>))
|
192
|
+
(if
|
193
|
+
(and (cons? (fst Parse_<patterns>))
|
194
|
+
(= <- (hd (fst Parse_<patterns>))))
|
195
|
+
(let Parse_<action>
|
196
|
+
(shen-<action>
|
197
|
+
(shen-reassemble (tl (fst Parse_<patterns>))
|
198
|
+
(snd Parse_<patterns>)))
|
199
|
+
(if (not (= (fail) Parse_<action>))
|
200
|
+
(if
|
201
|
+
(and (cons? (fst Parse_<action>))
|
202
|
+
(= where (hd (fst Parse_<action>))))
|
203
|
+
(let Parse_<guard>
|
204
|
+
(shen-<guard>
|
205
|
+
(shen-reassemble (tl (fst Parse_<action>)) (snd Parse_<action>)))
|
206
|
+
(if (not (= (fail) Parse_<guard>))
|
207
|
+
(shen-reassemble (fst Parse_<guard>)
|
208
|
+
(cons (snd Parse_<patterns>)
|
209
|
+
(cons
|
210
|
+
(cons where
|
211
|
+
(cons (snd Parse_<guard>)
|
212
|
+
(cons
|
213
|
+
(cons shen-choicepoint! (cons (snd Parse_<action>) ()))
|
214
|
+
())))
|
215
|
+
())))
|
216
|
+
(fail)))
|
217
|
+
(fail))
|
218
|
+
(fail)))
|
219
|
+
(fail))
|
220
|
+
(fail)))
|
221
|
+
(if (= Result (fail))
|
222
|
+
(let Result
|
223
|
+
(let Parse_<patterns> (shen-<patterns> V395)
|
224
|
+
(if (not (= (fail) Parse_<patterns>))
|
225
|
+
(if
|
226
|
+
(and (cons? (fst Parse_<patterns>))
|
227
|
+
(= <- (hd (fst Parse_<patterns>))))
|
228
|
+
(let Parse_<action>
|
229
|
+
(shen-<action>
|
230
|
+
(shen-reassemble (tl (fst Parse_<patterns>))
|
231
|
+
(snd Parse_<patterns>)))
|
232
|
+
(if (not (= (fail) Parse_<action>))
|
233
|
+
(shen-reassemble (fst Parse_<action>)
|
234
|
+
(cons (snd Parse_<patterns>)
|
235
|
+
(cons (cons shen-choicepoint! (cons (snd Parse_<action>) ()))
|
236
|
+
())))
|
237
|
+
(fail)))
|
238
|
+
(fail))
|
239
|
+
(fail)))
|
240
|
+
(if (= Result (fail)) (fail) Result))
|
241
|
+
Result))
|
242
|
+
Result))
|
243
|
+
Result)))
|
244
|
+
|
245
|
+
(defun shen-fail_if (V396 V397) (if (V396 V397) (fail) V397))
|
246
|
+
|
247
|
+
(defun shen-succeeds? (V402) (cond ((= V402 (fail)) false) (true true)))
|
248
|
+
|
249
|
+
(defun shen-<patterns> (V403)
|
250
|
+
(let Result
|
251
|
+
(let Parse_<pattern> (shen-<pattern> V403)
|
252
|
+
(if (not (= (fail) Parse_<pattern>))
|
253
|
+
(let Parse_<patterns> (shen-<patterns> Parse_<pattern>)
|
254
|
+
(if (not (= (fail) Parse_<patterns>))
|
255
|
+
(shen-reassemble (fst Parse_<patterns>)
|
256
|
+
(cons (snd Parse_<pattern>) (snd Parse_<patterns>)))
|
257
|
+
(fail)))
|
258
|
+
(fail)))
|
259
|
+
(if (= Result (fail))
|
260
|
+
(let Result
|
261
|
+
(let Parse_<e> (<e> V403)
|
262
|
+
(if (not (= (fail) Parse_<e>)) (shen-reassemble (fst Parse_<e>) ())
|
263
|
+
(fail)))
|
264
|
+
(if (= Result (fail)) (fail) Result))
|
265
|
+
Result)))
|
266
|
+
|
267
|
+
(defun shen-<pattern> (V404)
|
268
|
+
(let Result
|
269
|
+
(if (and (cons? (fst V404)) (cons? (hd (fst V404))))
|
270
|
+
(shen-snd-or-fail
|
271
|
+
(if
|
272
|
+
(and (cons? (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
273
|
+
(= @p (hd (fst (shen-reassemble (hd (fst V404)) (snd V404))))))
|
274
|
+
(let Parse_<pattern1>
|
275
|
+
(shen-<pattern1>
|
276
|
+
(shen-reassemble (tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
277
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404)))))
|
278
|
+
(if (not (= (fail) Parse_<pattern1>))
|
279
|
+
(let Parse_<pattern2> (shen-<pattern2> Parse_<pattern1>)
|
280
|
+
(if (not (= (fail) Parse_<pattern2>))
|
281
|
+
(shen-reassemble (fst Parse_<pattern2>)
|
282
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V404)) (snd V404)))
|
283
|
+
(cons @p
|
284
|
+
(cons (snd Parse_<pattern1>) (cons (snd Parse_<pattern2>) ())))))
|
285
|
+
(fail)))
|
286
|
+
(fail)))
|
287
|
+
(fail)))
|
288
|
+
(fail))
|
289
|
+
(if (= Result (fail))
|
290
|
+
(let Result
|
291
|
+
(if (and (cons? (fst V404)) (cons? (hd (fst V404))))
|
292
|
+
(shen-snd-or-fail
|
293
|
+
(if
|
294
|
+
(and (cons? (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
295
|
+
(= cons (hd (fst (shen-reassemble (hd (fst V404)) (snd V404))))))
|
296
|
+
(let Parse_<pattern1>
|
297
|
+
(shen-<pattern1>
|
298
|
+
(shen-reassemble
|
299
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
300
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404)))))
|
301
|
+
(if (not (= (fail) Parse_<pattern1>))
|
302
|
+
(let Parse_<pattern2> (shen-<pattern2> Parse_<pattern1>)
|
303
|
+
(if (not (= (fail) Parse_<pattern2>))
|
304
|
+
(shen-reassemble (fst Parse_<pattern2>)
|
305
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V404)) (snd V404)))
|
306
|
+
(cons cons
|
307
|
+
(cons (snd Parse_<pattern1>)
|
308
|
+
(cons (snd Parse_<pattern2>) ())))))
|
309
|
+
(fail)))
|
310
|
+
(fail)))
|
311
|
+
(fail)))
|
312
|
+
(fail))
|
313
|
+
(if (= Result (fail))
|
314
|
+
(let Result
|
315
|
+
(if (and (cons? (fst V404)) (cons? (hd (fst V404))))
|
316
|
+
(shen-snd-or-fail
|
317
|
+
(if
|
318
|
+
(and (cons? (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
319
|
+
(= @v (hd (fst (shen-reassemble (hd (fst V404)) (snd V404))))))
|
320
|
+
(let Parse_<pattern1>
|
321
|
+
(shen-<pattern1>
|
322
|
+
(shen-reassemble
|
323
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
324
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404)))))
|
325
|
+
(if (not (= (fail) Parse_<pattern1>))
|
326
|
+
(let Parse_<pattern2> (shen-<pattern2> Parse_<pattern1>)
|
327
|
+
(if (not (= (fail) Parse_<pattern2>))
|
328
|
+
(shen-reassemble (fst Parse_<pattern2>)
|
329
|
+
(shen-reassemble
|
330
|
+
(fst (shen-reassemble (tl (fst V404)) (snd V404)))
|
331
|
+
(cons @v
|
332
|
+
(cons (snd Parse_<pattern1>)
|
333
|
+
(cons (snd Parse_<pattern2>) ())))))
|
334
|
+
(fail)))
|
335
|
+
(fail)))
|
336
|
+
(fail)))
|
337
|
+
(fail))
|
338
|
+
(if (= Result (fail))
|
339
|
+
(let Result
|
340
|
+
(if (and (cons? (fst V404)) (cons? (hd (fst V404))))
|
341
|
+
(shen-snd-or-fail
|
342
|
+
(if
|
343
|
+
(and (cons? (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
344
|
+
(= @s (hd (fst (shen-reassemble (hd (fst V404)) (snd V404))))))
|
345
|
+
(let Parse_<pattern1>
|
346
|
+
(shen-<pattern1>
|
347
|
+
(shen-reassemble
|
348
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
349
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404)))))
|
350
|
+
(if (not (= (fail) Parse_<pattern1>))
|
351
|
+
(let Parse_<pattern2> (shen-<pattern2> Parse_<pattern1>)
|
352
|
+
(if (not (= (fail) Parse_<pattern2>))
|
353
|
+
(shen-reassemble (fst Parse_<pattern2>)
|
354
|
+
(shen-reassemble
|
355
|
+
(fst (shen-reassemble (tl (fst V404)) (snd V404)))
|
356
|
+
(cons @s
|
357
|
+
(cons (snd Parse_<pattern1>)
|
358
|
+
(cons (snd Parse_<pattern2>) ())))))
|
359
|
+
(fail)))
|
360
|
+
(fail)))
|
361
|
+
(fail)))
|
362
|
+
(fail))
|
363
|
+
(if (= Result (fail))
|
364
|
+
(let Result
|
365
|
+
(if (and (cons? (fst V404)) (cons? (hd (fst V404))))
|
366
|
+
(shen-snd-or-fail
|
367
|
+
(if
|
368
|
+
(and (cons? (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
369
|
+
(= vector
|
370
|
+
(hd (fst (shen-reassemble (hd (fst V404)) (snd V404))))))
|
371
|
+
(if
|
372
|
+
(and
|
373
|
+
(cons?
|
374
|
+
(fst
|
375
|
+
(shen-reassemble
|
376
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
377
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404))))))
|
378
|
+
(= 0
|
379
|
+
(hd
|
380
|
+
(fst
|
381
|
+
(shen-reassemble
|
382
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
383
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404))))))))
|
384
|
+
(shen-reassemble
|
385
|
+
(fst
|
386
|
+
(shen-reassemble
|
387
|
+
(tl
|
388
|
+
(fst
|
389
|
+
(shen-reassemble
|
390
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
391
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404))))))
|
392
|
+
(snd
|
393
|
+
(shen-reassemble
|
394
|
+
(tl (fst (shen-reassemble (hd (fst V404)) (snd V404))))
|
395
|
+
(snd (shen-reassemble (hd (fst V404)) (snd V404)))))))
|
396
|
+
(shen-reassemble
|
397
|
+
(fst (shen-reassemble (tl (fst V404)) (snd V404)))
|
398
|
+
(cons vector (cons 0 ()))))
|
399
|
+
(fail))
|
400
|
+
(fail)))
|
401
|
+
(fail))
|
402
|
+
(if (= Result (fail))
|
403
|
+
(let Result
|
404
|
+
(if (cons? (fst V404))
|
405
|
+
(shen-reassemble
|
406
|
+
(fst (shen-reassemble (tl (fst V404)) (snd V404)))
|
407
|
+
(if (cons? (hd (fst V404)))
|
408
|
+
(interror "~A is not a legitimate constructor~%"
|
409
|
+
(@p (hd (fst V404)) ()))
|
410
|
+
(fail)))
|
411
|
+
(fail))
|
412
|
+
(if (= Result (fail))
|
413
|
+
(let Result
|
414
|
+
(let Parse_<simple_pattern> (shen-<simple_pattern> V404)
|
415
|
+
(if (not (= (fail) Parse_<simple_pattern>))
|
416
|
+
(shen-reassemble (fst Parse_<simple_pattern>)
|
417
|
+
(snd Parse_<simple_pattern>))
|
418
|
+
(fail)))
|
419
|
+
(if (= Result (fail)) (fail) Result))
|
420
|
+
Result))
|
421
|
+
Result))
|
422
|
+
Result))
|
423
|
+
Result))
|
424
|
+
Result))
|
425
|
+
Result)))
|
426
|
+
|
427
|
+
(defun shen-<simple_pattern> (V405)
|
428
|
+
(let Result
|
429
|
+
(if (cons? (fst V405))
|
430
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V405)) (snd V405)))
|
431
|
+
(if (= (hd (fst V405)) _) (gensym X) (fail)))
|
432
|
+
(fail))
|
433
|
+
(if (= Result (fail))
|
434
|
+
(let Result
|
435
|
+
(if (cons? (fst V405))
|
436
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V405)) (snd V405)))
|
437
|
+
(if (element? (hd (fst V405)) (cons -> (cons <- ()))) (fail)
|
438
|
+
(hd (fst V405))))
|
439
|
+
(fail))
|
440
|
+
(if (= Result (fail)) (fail) Result))
|
441
|
+
Result)))
|
442
|
+
|
443
|
+
(defun shen-<pattern1> (V406)
|
444
|
+
(let Result
|
445
|
+
(let Parse_<pattern> (shen-<pattern> V406)
|
446
|
+
(if (not (= (fail) Parse_<pattern>))
|
447
|
+
(shen-reassemble (fst Parse_<pattern>) (snd Parse_<pattern>)) (fail)))
|
448
|
+
(if (= Result (fail)) (fail) Result)))
|
449
|
+
|
450
|
+
(defun shen-<pattern2> (V407)
|
451
|
+
(let Result
|
452
|
+
(let Parse_<pattern> (shen-<pattern> V407)
|
453
|
+
(if (not (= (fail) Parse_<pattern>))
|
454
|
+
(shen-reassemble (fst Parse_<pattern>) (snd Parse_<pattern>)) (fail)))
|
455
|
+
(if (= Result (fail)) (fail) Result)))
|
456
|
+
|
457
|
+
(defun shen-<action> (V408)
|
458
|
+
(let Result
|
459
|
+
(if (cons? (fst V408))
|
460
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V408)) (snd V408)))
|
461
|
+
(hd (fst V408)))
|
462
|
+
(fail))
|
463
|
+
(if (= Result (fail)) (fail) Result)))
|
464
|
+
|
465
|
+
(defun shen-<guard> (V409)
|
466
|
+
(let Result
|
467
|
+
(if (cons? (fst V409))
|
468
|
+
(shen-reassemble (fst (shen-reassemble (tl (fst V409)) (snd V409)))
|
469
|
+
(hd (fst V409)))
|
470
|
+
(fail))
|
471
|
+
(if (= Result (fail)) (fail) Result)))
|
472
|
+
|
473
|
+
(defun shen-compile_to_machine_code (V410 V411)
|
474
|
+
(let Lambda+ (shen-compile_to_lambda+ V410 V411)
|
475
|
+
(let KL (shen-compile_to_kl V410 Lambda+)
|
476
|
+
(let Record (shen-record-source V410 KL) KL))))
|
477
|
+
|
478
|
+
(defun shen-record-source (V414 V415)
|
479
|
+
(cond ((value shen-*installing-kl*) shen-skip)
|
480
|
+
(true (put V414 shen-source V415 (value shen-*property-vector*)))))
|
481
|
+
|
482
|
+
(defun shen-compile_to_lambda+ (V416 V417)
|
483
|
+
(let Arity (shen-aritycheck V416 V417)
|
484
|
+
(let Free (map (lambda Rule (shen-free_variable_check V416 Rule)) V417)
|
485
|
+
(let Variables (shen-parameters Arity)
|
486
|
+
(let Linear
|
487
|
+
(map (lambda V418 (shen-linearise V418)) (shen-strip-protect V417))
|
488
|
+
(let Abstractions (map (lambda V419 (shen-abstract_rule V419)) Linear)
|
489
|
+
(let Applications
|
490
|
+
(map (lambda X (shen-application_build Variables X)) Abstractions)
|
491
|
+
(cons Variables (cons Applications ())))))))))
|
492
|
+
|
493
|
+
(defun shen-free_variable_check (V420 V421)
|
494
|
+
(cond
|
495
|
+
((and (cons? V421) (and (cons? (tl V421)) (= () (tl (tl V421)))))
|
496
|
+
(let Bound (shen-extract_vars (hd V421))
|
497
|
+
(let Free (shen-extract_free_vars Bound (hd (tl V421)))
|
498
|
+
(shen-free_variable_warnings V420 Free))))
|
499
|
+
(true (shen-sys-error shen-free_variable_check))))
|
500
|
+
|
501
|
+
(defun shen-extract_vars (V422)
|
502
|
+
(cond ((variable? V422) (cons V422 ()))
|
503
|
+
((cons? V422)
|
504
|
+
(union (shen-extract_vars (hd V422)) (shen-extract_vars (tl V422))))
|
505
|
+
(true ())))
|
506
|
+
|
507
|
+
(defun shen-extract_free_vars (V433 V434)
|
508
|
+
(cond
|
509
|
+
((and (cons? V434)
|
510
|
+
(and (= protect (hd V434))
|
511
|
+
(and (cons? (tl V434)) (= () (tl (tl V434))))))
|
512
|
+
())
|
513
|
+
((and (variable? V434) (not (element? V434 V433))) (cons V434 ()))
|
514
|
+
((and (cons? V434)
|
515
|
+
(and (= lambda (hd V434))
|
516
|
+
(and (cons? (tl V434))
|
517
|
+
(and (cons? (tl (tl V434))) (= () (tl (tl (tl V434))))))))
|
518
|
+
(shen-extract_free_vars (cons (hd (tl V434)) V433) (hd (tl (tl V434)))))
|
519
|
+
((and (cons? V434)
|
520
|
+
(and (= let (hd V434))
|
521
|
+
(and (cons? (tl V434))
|
522
|
+
(and (cons? (tl (tl V434)))
|
523
|
+
(and (cons? (tl (tl (tl V434))))
|
524
|
+
(= () (tl (tl (tl (tl V434))))))))))
|
525
|
+
(union (shen-extract_free_vars V433 (hd (tl (tl V434))))
|
526
|
+
(shen-extract_free_vars (cons (hd (tl V434)) V433)
|
527
|
+
(hd (tl (tl (tl V434)))))))
|
528
|
+
((cons? V434)
|
529
|
+
(union (shen-extract_free_vars V433 (hd V434))
|
530
|
+
(shen-extract_free_vars V433 (tl V434))))
|
531
|
+
(true ())))
|
532
|
+
|
533
|
+
(defun shen-free_variable_warnings (V437 V438)
|
534
|
+
(cond ((= () V438) _)
|
535
|
+
(true
|
536
|
+
(interror "error: the following variables are free in ~A: ~A"
|
537
|
+
(@p V437 (@p (shen-list_variables V438) ()))))))
|
538
|
+
|
539
|
+
(defun shen-list_variables (V439)
|
540
|
+
(cond ((and (cons? V439) (= () (tl V439))) (cn (str (hd V439)) "."))
|
541
|
+
((cons? V439) (cn (str (hd V439)) (cn ", " (shen-list_variables (tl V439)))))
|
542
|
+
(true (shen-sys-error shen-list_variables))))
|
543
|
+
|
544
|
+
(defun shen-strip-protect (V440)
|
545
|
+
(cond
|
546
|
+
((and (cons? V440)
|
547
|
+
(and (= protect (hd V440))
|
548
|
+
(and (cons? (tl V440)) (= () (tl (tl V440))))))
|
549
|
+
(hd (tl V440)))
|
550
|
+
((cons? V440)
|
551
|
+
(cons (shen-strip-protect (hd V440)) (shen-strip-protect (tl V440))))
|
552
|
+
(true V440)))
|
553
|
+
|
554
|
+
(defun shen-linearise (V441)
|
555
|
+
(cond
|
556
|
+
((and (cons? V441) (and (cons? (tl V441)) (= () (tl (tl V441)))))
|
557
|
+
(shen-linearise_help (shen-flatten (hd V441)) (hd V441) (hd (tl V441))))
|
558
|
+
(true (shen-sys-error shen-linearise))))
|
559
|
+
|
560
|
+
(defun shen-flatten (V442)
|
561
|
+
(cond ((= () V442) ())
|
562
|
+
((cons? V442) (append (shen-flatten (hd V442)) (shen-flatten (tl V442))))
|
563
|
+
(true (cons V442 ()))))
|
564
|
+
|
565
|
+
(defun shen-linearise_help (V443 V444 V445)
|
566
|
+
(cond ((= () V443) (cons V444 (cons V445 ())))
|
567
|
+
((cons? V443)
|
568
|
+
(if (and (variable? (hd V443)) (element? (hd V443) (tl V443)))
|
569
|
+
(let Var (gensym (hd V443))
|
570
|
+
(let NewAction
|
571
|
+
(cons where
|
572
|
+
(cons (cons = (cons (hd V443) (cons Var ()))) (cons V445 ())))
|
573
|
+
(let NewPatts (shen-linearise_X (hd V443) Var V444)
|
574
|
+
(shen-linearise_help (tl V443) NewPatts NewAction))))
|
575
|
+
(shen-linearise_help (tl V443) V444 V445)))
|
576
|
+
(true (shen-sys-error shen-linearise_help))))
|
577
|
+
|
578
|
+
(defun shen-linearise_X (V454 V455 V456)
|
579
|
+
(cond ((= V456 V454) V455)
|
580
|
+
((cons? V456)
|
581
|
+
(let L (shen-linearise_X V454 V455 (hd V456))
|
582
|
+
(if (= L (hd V456))
|
583
|
+
(cons (hd V456) (shen-linearise_X V454 V455 (tl V456)))
|
584
|
+
(cons L (tl V456)))))
|
585
|
+
(true V456)))
|
586
|
+
|
587
|
+
(defun shen-aritycheck (V458 V459)
|
588
|
+
(cond
|
589
|
+
((and (cons? V459)
|
590
|
+
(and (cons? (hd V459))
|
591
|
+
(and (cons? (tl (hd V459)))
|
592
|
+
(and (= () (tl (tl (hd V459)))) (= () (tl V459))))))
|
593
|
+
(do (shen-aritycheck-action (hd (tl (hd V459))))
|
594
|
+
(shen-aritycheck-name V458 (arity V458) (length (hd (hd V459))))))
|
595
|
+
((and (cons? V459)
|
596
|
+
(and (cons? (hd V459))
|
597
|
+
(and (cons? (tl (hd V459)))
|
598
|
+
(and (= () (tl (tl (hd V459))))
|
599
|
+
(and (cons? (tl V459))
|
600
|
+
(and (cons? (hd (tl V459)))
|
601
|
+
(and (cons? (tl (hd (tl V459))))
|
602
|
+
(= () (tl (tl (hd (tl V459))))))))))))
|
603
|
+
(if (= (length (hd (hd V459))) (length (hd (hd (tl V459)))))
|
604
|
+
(do (shen-aritycheck-action Action) (shen-aritycheck V458 (tl V459)))
|
605
|
+
(interror "arity error in ~A~%" (@p V458 ()))))
|
606
|
+
(true (shen-sys-error shen-aritycheck))))
|
607
|
+
|
608
|
+
(defun shen-aritycheck-name (V468 V469 V470)
|
609
|
+
(cond ((= -1 V469) V470) ((= V470 V469) V470)
|
610
|
+
(true
|
611
|
+
(do
|
612
|
+
(intoutput "~%warning: changing the arity of ~A can cause errors.~%"
|
613
|
+
(@p V468 ()))
|
614
|
+
V470))))
|
615
|
+
|
616
|
+
(defun shen-aritycheck-action (V476)
|
617
|
+
(cond
|
618
|
+
((cons? V476)
|
619
|
+
(do (shen-aah (hd V476) (tl V476))
|
620
|
+
(map (lambda V477 (shen-aritycheck-action V477)) V476)))
|
621
|
+
(true shen-skip)))
|
622
|
+
|
623
|
+
(defun shen-aah (V478 V479)
|
624
|
+
(let Arity (arity V478)
|
625
|
+
(let Len (length V479)
|
626
|
+
(if (and (> Arity -1) (> Len Arity))
|
627
|
+
(intoutput "warning: ~A might not like ~A argument~A.~%"
|
628
|
+
(@p V478 (@p Len (@p (if (> Len 1) "s" "") ()))))
|
629
|
+
shen-skip))))
|
630
|
+
|
631
|
+
(defun shen-abstract_rule (V480)
|
632
|
+
(cond
|
633
|
+
((and (cons? V480) (and (cons? (tl V480)) (= () (tl (tl V480)))))
|
634
|
+
(shen-abstraction_build (hd V480) (hd (tl V480))))
|
635
|
+
(true (shen-sys-error shen-abstract_rule))))
|
636
|
+
|
637
|
+
(defun shen-abstraction_build (V481 V482)
|
638
|
+
(cond ((= () V481) V482)
|
639
|
+
((cons? V481)
|
640
|
+
(cons /.
|
641
|
+
(cons (hd V481) (cons (shen-abstraction_build (tl V481) V482) ()))))
|
642
|
+
(true (shen-sys-error shen-abstraction_build))))
|
643
|
+
|
644
|
+
(defun shen-parameters (V483)
|
645
|
+
(cond ((= 0 V483) ())
|
646
|
+
(true (cons (gensym V) (shen-parameters (- V483 1))))))
|
647
|
+
|
648
|
+
(defun shen-application_build (V484 V485)
|
649
|
+
(cond ((= () V484) V485)
|
650
|
+
((cons? V484)
|
651
|
+
(shen-application_build (tl V484) (cons V485 (cons (hd V484) ()))))
|
652
|
+
(true (shen-sys-error shen-application_build))))
|
653
|
+
|
654
|
+
(defun shen-compile_to_kl (V486 V487)
|
655
|
+
(cond
|
656
|
+
((and (cons? V487) (and (cons? (tl V487)) (= () (tl (tl V487)))))
|
657
|
+
(let Arity (shen-store-arity V486 (length (hd V487)))
|
658
|
+
(let Reduce (map (lambda V488 (shen-reduce V488)) (hd (tl V487)))
|
659
|
+
(let CondExpression (shen-cond-expression V486 (hd V487) Reduce)
|
660
|
+
(let KL
|
661
|
+
(cons defun (cons V486 (cons (hd V487) (cons CondExpression ()))))
|
662
|
+
KL)))))
|
663
|
+
(true (shen-sys-error shen-compile_to_kl))))
|
664
|
+
|
665
|
+
(defun shen-store-arity (V491 V492)
|
666
|
+
(cond ((value shen-*installing-kl*) shen-skip)
|
667
|
+
(true (put V491 arity V492 (value shen-*property-vector*)))))
|
668
|
+
|
669
|
+
(defun shen-reduce (V493)
|
670
|
+
(do (set shen-*teststack* ())
|
671
|
+
(let Result (shen-reduce_help V493)
|
672
|
+
(cons (cons shen-tests (reverse (value shen-*teststack*)))
|
673
|
+
(cons Result ())))))
|
674
|
+
|
675
|
+
(defun shen-reduce_help (V494)
|
676
|
+
(cond
|
677
|
+
((and (cons? V494)
|
678
|
+
(and (cons? (hd V494))
|
679
|
+
(and (= /. (hd (hd V494)))
|
680
|
+
(and (cons? (tl (hd V494)))
|
681
|
+
(and (cons? (hd (tl (hd V494))))
|
682
|
+
(and (= cons (hd (hd (tl (hd V494)))))
|
683
|
+
(and (cons? (tl (hd (tl (hd V494)))))
|
684
|
+
(and (cons? (tl (tl (hd (tl (hd V494))))))
|
685
|
+
(and (= () (tl (tl (tl (hd (tl (hd V494)))))))
|
686
|
+
(and (cons? (tl (tl (hd V494))))
|
687
|
+
(and (= () (tl (tl (tl (hd V494)))))
|
688
|
+
(and (cons? (tl V494)) (= () (tl (tl V494)))))))))))))))
|
689
|
+
(do (shen-add_test (cons cons? (tl V494)))
|
690
|
+
(let Abstraction
|
691
|
+
(cons /.
|
692
|
+
(cons (hd (tl (hd (tl (hd V494)))))
|
693
|
+
(cons
|
694
|
+
(cons /.
|
695
|
+
(cons (hd (tl (tl (hd (tl (hd V494))))))
|
696
|
+
(cons
|
697
|
+
(shen-ebr (hd (tl V494)) (hd (tl (hd V494)))
|
698
|
+
(hd (tl (tl (hd V494)))))
|
699
|
+
())))
|
700
|
+
())))
|
701
|
+
(let Application
|
702
|
+
(cons (cons Abstraction (cons (cons hd (tl V494)) ()))
|
703
|
+
(cons (cons tl (tl V494)) ()))
|
704
|
+
(shen-reduce_help Application)))))
|
705
|
+
((and (cons? V494)
|
706
|
+
(and (cons? (hd V494))
|
707
|
+
(and (= /. (hd (hd V494)))
|
708
|
+
(and (cons? (tl (hd V494)))
|
709
|
+
(and (cons? (hd (tl (hd V494))))
|
710
|
+
(and (= @p (hd (hd (tl (hd V494)))))
|
711
|
+
(and (cons? (tl (hd (tl (hd V494)))))
|
712
|
+
(and (cons? (tl (tl (hd (tl (hd V494))))))
|
713
|
+
(and (= () (tl (tl (tl (hd (tl (hd V494)))))))
|
714
|
+
(and (cons? (tl (tl (hd V494))))
|
715
|
+
(and (= () (tl (tl (tl (hd V494)))))
|
716
|
+
(and (cons? (tl V494)) (= () (tl (tl V494)))))))))))))))
|
717
|
+
(do (shen-add_test (cons tuple? (tl V494)))
|
718
|
+
(let Abstraction
|
719
|
+
(cons /.
|
720
|
+
(cons (hd (tl (hd (tl (hd V494)))))
|
721
|
+
(cons
|
722
|
+
(cons /.
|
723
|
+
(cons (hd (tl (tl (hd (tl (hd V494))))))
|
724
|
+
(cons
|
725
|
+
(shen-ebr (hd (tl V494)) (hd (tl (hd V494)))
|
726
|
+
(hd (tl (tl (hd V494)))))
|
727
|
+
())))
|
728
|
+
())))
|
729
|
+
(let Application
|
730
|
+
(cons (cons Abstraction (cons (cons fst (tl V494)) ()))
|
731
|
+
(cons (cons snd (tl V494)) ()))
|
732
|
+
(shen-reduce_help Application)))))
|
733
|
+
((and (cons? V494)
|
734
|
+
(and (cons? (hd V494))
|
735
|
+
(and (= /. (hd (hd V494)))
|
736
|
+
(and (cons? (tl (hd V494)))
|
737
|
+
(and (cons? (hd (tl (hd V494))))
|
738
|
+
(and (= @v (hd (hd (tl (hd V494)))))
|
739
|
+
(and (cons? (tl (hd (tl (hd V494)))))
|
740
|
+
(and (cons? (tl (tl (hd (tl (hd V494))))))
|
741
|
+
(and (= () (tl (tl (tl (hd (tl (hd V494)))))))
|
742
|
+
(and (cons? (tl (tl (hd V494))))
|
743
|
+
(and (= () (tl (tl (tl (hd V494)))))
|
744
|
+
(and (cons? (tl V494)) (= () (tl (tl V494)))))))))))))))
|
745
|
+
(do (shen-add_test (cons shen-+vector? (tl V494)))
|
746
|
+
(let Abstraction
|
747
|
+
(cons /.
|
748
|
+
(cons (hd (tl (hd (tl (hd V494)))))
|
749
|
+
(cons
|
750
|
+
(cons /.
|
751
|
+
(cons (hd (tl (tl (hd (tl (hd V494))))))
|
752
|
+
(cons
|
753
|
+
(shen-ebr (hd (tl V494)) (hd (tl (hd V494)))
|
754
|
+
(hd (tl (tl (hd V494)))))
|
755
|
+
())))
|
756
|
+
())))
|
757
|
+
(let Application
|
758
|
+
(cons (cons Abstraction (cons (cons hdv (tl V494)) ()))
|
759
|
+
(cons (cons tlv (tl V494)) ()))
|
760
|
+
(shen-reduce_help Application)))))
|
761
|
+
((and (cons? V494)
|
762
|
+
(and (cons? (hd V494))
|
763
|
+
(and (= /. (hd (hd V494)))
|
764
|
+
(and (cons? (tl (hd V494)))
|
765
|
+
(and (cons? (hd (tl (hd V494))))
|
766
|
+
(and (= @s (hd (hd (tl (hd V494)))))
|
767
|
+
(and (cons? (tl (hd (tl (hd V494)))))
|
768
|
+
(and (cons? (tl (tl (hd (tl (hd V494))))))
|
769
|
+
(and (= () (tl (tl (tl (hd (tl (hd V494)))))))
|
770
|
+
(and (cons? (tl (tl (hd V494))))
|
771
|
+
(and (= () (tl (tl (tl (hd V494)))))
|
772
|
+
(and (cons? (tl V494)) (= () (tl (tl V494)))))))))))))))
|
773
|
+
(do (shen-add_test (cons shen-+string? (tl V494)))
|
774
|
+
(let Abstraction
|
775
|
+
(cons /.
|
776
|
+
(cons (hd (tl (hd (tl (hd V494)))))
|
777
|
+
(cons
|
778
|
+
(cons /.
|
779
|
+
(cons (hd (tl (tl (hd (tl (hd V494))))))
|
780
|
+
(cons
|
781
|
+
(shen-ebr (hd (tl V494)) (hd (tl (hd V494)))
|
782
|
+
(hd (tl (tl (hd V494)))))
|
783
|
+
())))
|
784
|
+
())))
|
785
|
+
(let Application
|
786
|
+
(cons
|
787
|
+
(cons Abstraction
|
788
|
+
(cons (cons pos (cons (hd (tl V494)) (cons 0 ()))) ()))
|
789
|
+
(cons (cons tlstr (tl V494)) ()))
|
790
|
+
(shen-reduce_help Application)))))
|
791
|
+
((and (cons? V494)
|
792
|
+
(and (cons? (hd V494))
|
793
|
+
(and (= /. (hd (hd V494)))
|
794
|
+
(and (cons? (tl (hd V494)))
|
795
|
+
(and (cons? (tl (tl (hd V494))))
|
796
|
+
(and (= () (tl (tl (tl (hd V494)))))
|
797
|
+
(and (cons? (tl V494))
|
798
|
+
(and (= () (tl (tl V494)))
|
799
|
+
(not (variable? (hd (tl (hd V494)))))))))))))
|
800
|
+
(do (shen-add_test (cons = (cons (hd (tl (hd V494))) (tl V494))))
|
801
|
+
(shen-reduce_help (hd (tl (tl (hd V494)))))))
|
802
|
+
((and (cons? V494)
|
803
|
+
(and (cons? (hd V494))
|
804
|
+
(and (= /. (hd (hd V494)))
|
805
|
+
(and (cons? (tl (hd V494)))
|
806
|
+
(and (cons? (tl (tl (hd V494))))
|
807
|
+
(and (= () (tl (tl (tl (hd V494)))))
|
808
|
+
(and (cons? (tl V494)) (= () (tl (tl V494))))))))))
|
809
|
+
(shen-reduce_help
|
810
|
+
(shen-ebr (hd (tl V494)) (hd (tl (hd V494))) (hd (tl (tl (hd V494)))))))
|
811
|
+
((and (cons? V494)
|
812
|
+
(and (= where (hd V494))
|
813
|
+
(and (cons? (tl V494))
|
814
|
+
(and (cons? (tl (tl V494))) (= () (tl (tl (tl V494))))))))
|
815
|
+
(do (shen-add_test (hd (tl V494))) (shen-reduce_help (hd (tl (tl V494))))))
|
816
|
+
((and (cons? V494) (and (cons? (tl V494)) (= () (tl (tl V494)))))
|
817
|
+
(let Z (shen-reduce_help (hd V494))
|
818
|
+
(if (= (hd V494) Z) V494 (shen-reduce_help (cons Z (tl V494))))))
|
819
|
+
(true V494)))
|
820
|
+
|
821
|
+
(defun shen-+string? (V495)
|
822
|
+
(cond ((= "" V495) false) (true (string? V495))))
|
823
|
+
|
824
|
+
(defun shen-+vector (V496)
|
825
|
+
(cond ((= V496 (vector 0)) false) (true (vector? V496))))
|
826
|
+
|
827
|
+
(defun shen-ebr (V505 V506 V507)
|
828
|
+
(cond ((= V507 V506) V505)
|
829
|
+
((and (cons? V507)
|
830
|
+
(and (= /. (hd V507))
|
831
|
+
(and (cons? (tl V507))
|
832
|
+
(and (cons? (tl (tl V507)))
|
833
|
+
(and (= () (tl (tl (tl V507))))
|
834
|
+
(> (occurrences V506 (hd (tl V507))) 0))))))
|
835
|
+
V507)
|
836
|
+
((and (cons? V507)
|
837
|
+
(and (= let (hd V507))
|
838
|
+
(and (cons? (tl V507))
|
839
|
+
(and (cons? (tl (tl V507)))
|
840
|
+
(and (cons? (tl (tl (tl V507))))
|
841
|
+
(and (= () (tl (tl (tl (tl V507)))))
|
842
|
+
(= (hd (tl V507)) V506)))))))
|
843
|
+
(cons let
|
844
|
+
(cons (hd (tl V507))
|
845
|
+
(cons (shen-ebr V505 (hd (tl V507)) (hd (tl (tl V507))))
|
846
|
+
(tl (tl (tl V507)))))))
|
847
|
+
((cons? V507)
|
848
|
+
(cons (shen-ebr V505 V506 (hd V507)) (shen-ebr V505 V506 (tl V507))))
|
849
|
+
(true V507)))
|
850
|
+
|
851
|
+
(defun shen-add_test (V510)
|
852
|
+
(set shen-*teststack* (cons V510 (value shen-*teststack*))))
|
853
|
+
|
854
|
+
(defun shen-cond-expression (V511 V512 V513)
|
855
|
+
(let Err (shen-err-condition V511)
|
856
|
+
(let Cases (shen-case-form V513 Err)
|
857
|
+
(let EncodeChoices (shen-encode-choices Cases V511)
|
858
|
+
(shen-cond-form EncodeChoices)))))
|
859
|
+
|
860
|
+
(defun shen-cond-form (V516)
|
861
|
+
(cond
|
862
|
+
((and (cons? V516)
|
863
|
+
(and (cons? (hd V516))
|
864
|
+
(and (= true (hd (hd V516)))
|
865
|
+
(and (cons? (tl (hd V516))) (= () (tl (tl (hd V516))))))))
|
866
|
+
(hd (tl (hd V516))))
|
867
|
+
(true (cons cond V516))))
|
868
|
+
|
869
|
+
(defun shen-encode-choices (V519 V520)
|
870
|
+
(cond ((= () V519) ())
|
871
|
+
((and (cons? V519)
|
872
|
+
(and (cons? (hd V519))
|
873
|
+
(and (= true (hd (hd V519)))
|
874
|
+
(and (cons? (tl (hd V519)))
|
875
|
+
(and (cons? (hd (tl (hd V519))))
|
876
|
+
(and (= shen-choicepoint! (hd (hd (tl (hd V519)))))
|
877
|
+
(and (cons? (tl (hd (tl (hd V519)))))
|
878
|
+
(and (= () (tl (tl (hd (tl (hd V519))))))
|
879
|
+
(and (= () (tl (tl (hd V519)))) (= () (tl V519)))))))))))
|
880
|
+
(cons
|
881
|
+
(cons true
|
882
|
+
(cons
|
883
|
+
(cons let
|
884
|
+
(cons Result
|
885
|
+
(cons (hd (tl (hd (tl (hd V519)))))
|
886
|
+
(cons
|
887
|
+
(cons if
|
888
|
+
(cons (cons = (cons Result (cons (cons fail ()) ())))
|
889
|
+
(cons
|
890
|
+
(if (value shen-*installing-kl*)
|
891
|
+
(cons shen-sys-error (cons V520 ()))
|
892
|
+
(cons shen-f_error (cons V520 ())))
|
893
|
+
(cons Result ()))))
|
894
|
+
()))))
|
895
|
+
()))
|
896
|
+
()))
|
897
|
+
((and (cons? V519)
|
898
|
+
(and (cons? (hd V519))
|
899
|
+
(and (= true (hd (hd V519)))
|
900
|
+
(and (cons? (tl (hd V519)))
|
901
|
+
(and (cons? (hd (tl (hd V519))))
|
902
|
+
(and (= shen-choicepoint! (hd (hd (tl (hd V519)))))
|
903
|
+
(and (cons? (tl (hd (tl (hd V519)))))
|
904
|
+
(and (= () (tl (tl (hd (tl (hd V519))))))
|
905
|
+
(= () (tl (tl (hd V519))))))))))))
|
906
|
+
(cons
|
907
|
+
(cons true
|
908
|
+
(cons
|
909
|
+
(cons let
|
910
|
+
(cons Result
|
911
|
+
(cons (hd (tl (hd (tl (hd V519)))))
|
912
|
+
(cons
|
913
|
+
(cons if
|
914
|
+
(cons (cons = (cons Result (cons (cons fail ()) ())))
|
915
|
+
(cons (shen-cond-form (shen-encode-choices (tl V519) V520))
|
916
|
+
(cons Result ()))))
|
917
|
+
()))))
|
918
|
+
()))
|
919
|
+
()))
|
920
|
+
((and (cons? V519)
|
921
|
+
(and (cons? (hd V519))
|
922
|
+
(and (cons? (tl (hd V519)))
|
923
|
+
(and (cons? (hd (tl (hd V519))))
|
924
|
+
(and (= shen-choicepoint! (hd (hd (tl (hd V519)))))
|
925
|
+
(and (cons? (tl (hd (tl (hd V519)))))
|
926
|
+
(and (= () (tl (tl (hd (tl (hd V519))))))
|
927
|
+
(= () (tl (tl (hd V519)))))))))))
|
928
|
+
(cons
|
929
|
+
(cons true
|
930
|
+
(cons
|
931
|
+
(cons let
|
932
|
+
(cons Freeze
|
933
|
+
(cons
|
934
|
+
(cons freeze
|
935
|
+
(cons (shen-cond-form (shen-encode-choices (tl V519) V520)) ()))
|
936
|
+
(cons
|
937
|
+
(cons if
|
938
|
+
(cons (hd (hd V519))
|
939
|
+
(cons
|
940
|
+
(cons let
|
941
|
+
(cons Result
|
942
|
+
(cons (hd (tl (hd (tl (hd V519)))))
|
943
|
+
(cons
|
944
|
+
(cons if
|
945
|
+
(cons (cons = (cons Result (cons (cons fail ()) ())))
|
946
|
+
(cons (cons thaw (cons Freeze ())) (cons Result ()))))
|
947
|
+
()))))
|
948
|
+
(cons (cons thaw (cons Freeze ())) ()))))
|
949
|
+
()))))
|
950
|
+
()))
|
951
|
+
()))
|
952
|
+
((and (cons? V519)
|
953
|
+
(and (cons? (hd V519))
|
954
|
+
(and (cons? (tl (hd V519))) (= () (tl (tl (hd V519)))))))
|
955
|
+
(cons (hd V519) (shen-encode-choices (tl V519) V520)))
|
956
|
+
(true (shen-sys-error shen-encode-choices))))
|
957
|
+
|
958
|
+
(defun shen-case-form (V525 V526)
|
959
|
+
(cond ((= () V525) (cons V526 ()))
|
960
|
+
((and (cons? V525)
|
961
|
+
(and (cons? (hd V525))
|
962
|
+
(and (cons? (hd (hd V525)))
|
963
|
+
(and (= shen-tests (hd (hd (hd V525))))
|
964
|
+
(and (= () (tl (hd (hd V525))))
|
965
|
+
(and (cons? (tl (hd V525)))
|
966
|
+
(and (cons? (hd (tl (hd V525))))
|
967
|
+
(and (= shen-choicepoint! (hd (hd (tl (hd V525)))))
|
968
|
+
(and (cons? (tl (hd (tl (hd V525)))))
|
969
|
+
(and (= () (tl (tl (hd (tl (hd V525))))))
|
970
|
+
(= () (tl (tl (hd V525))))))))))))))
|
971
|
+
(cons (cons true (tl (hd V525))) (shen-case-form (tl V525) V526)))
|
972
|
+
((and (cons? V525)
|
973
|
+
(and (cons? (hd V525))
|
974
|
+
(and (cons? (hd (hd V525)))
|
975
|
+
(and (= shen-tests (hd (hd (hd V525))))
|
976
|
+
(and (= () (tl (hd (hd V525))))
|
977
|
+
(and (cons? (tl (hd V525))) (= () (tl (tl (hd V525))))))))))
|
978
|
+
(cons (cons true (tl (hd V525))) ()))
|
979
|
+
((and (cons? V525)
|
980
|
+
(and (cons? (hd V525))
|
981
|
+
(and (cons? (hd (hd V525)))
|
982
|
+
(and (= shen-tests (hd (hd (hd V525))))
|
983
|
+
(and (cons? (tl (hd V525))) (= () (tl (tl (hd V525)))))))))
|
984
|
+
(cons (cons (shen-embed-and (tl (hd (hd V525)))) (tl (hd V525)))
|
985
|
+
(shen-case-form (tl V525) V526)))
|
986
|
+
(true (shen-sys-error shen-case-form))))
|
987
|
+
|
988
|
+
(defun shen-embed-and (V527)
|
989
|
+
(cond ((and (cons? V527) (= () (tl V527))) (hd V527))
|
990
|
+
((cons? V527)
|
991
|
+
(cons and (cons (hd V527) (cons (shen-embed-and (tl V527)) ()))))
|
992
|
+
(true (shen-sys-error shen-embed-and))))
|
993
|
+
|
994
|
+
(defun shen-err-condition (V528)
|
995
|
+
(cond
|
996
|
+
((value shen-*installing-kl*)
|
997
|
+
(cons true (cons (cons shen-sys-error (cons V528 ())) ())))
|
998
|
+
(true (cons true (cons (cons shen-f_error (cons V528 ())) ())))))
|
999
|
+
|
1000
|
+
(defun shen-sys-error (V529)
|
1001
|
+
(interror "system function ~A: unexpected argument~%" (@p V529 ())))
|
1002
|
+
|