shen-ruby 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -2
- data/HISTORY.md +12 -0
- data/README.md +10 -7
- data/Rakefile +92 -0
- data/bin/srrepl +2 -2
- data/k_lambda_spec/primitives/arithmetic_spec.rb +175 -0
- data/k_lambda_spec/primitives/assignments_spec.rb +44 -0
- data/k_lambda_spec/primitives/generic_functions_spec.rb +115 -2
- data/k_lambda_spec/primitives/lists_spec.rb +40 -0
- data/k_lambda_spec/primitives/strings_spec.rb +77 -0
- data/k_lambda_spec/primitives/symbols_spec.rb +24 -0
- data/k_lambda_spec/primitives/vectors_spec.rb +92 -0
- data/k_lambda_spec/support/shared_examples.rb +93 -2
- data/k_lambda_spec/tail_recursion_spec.rb +30 -0
- data/lib/kl/compiler.rb +19 -33
- data/lib/kl/environment.rb +1 -0
- data/lib/kl/primitives/assignments.rb +1 -0
- data/lib/kl/primitives/generic_functions.rb +7 -0
- data/lib/kl/primitives/lists.rb +2 -0
- data/lib/kl/primitives/strings.rb +13 -5
- data/lib/kl/primitives/symbols.rb +1 -0
- data/lib/kl/primitives/vectors.rb +5 -0
- data/lib/shen_ruby/version.rb +1 -1
- data/shen-ruby.gemspec +1 -1
- data/shen/lib/shen_ruby/shen.rb +5 -6
- data/shen/release/benchmarks/benchmarks.shen +0 -4
- data/shen/release/benchmarks/interpreter.shen +2 -2
- data/shen/release/benchmarks/plato.jpg +0 -0
- data/shen/release/k_lambda/core.kl +171 -1000
- data/shen/release/k_lambda/declarations.kl +90 -992
- data/shen/release/k_lambda/load.kl +69 -81
- data/shen/release/k_lambda/macros.kl +113 -478
- data/shen/release/k_lambda/prolog.kl +250 -1307
- data/shen/release/k_lambda/reader.kl +115 -996
- data/shen/release/k_lambda/sequent.kl +154 -554
- data/shen/release/k_lambda/sys.kl +246 -562
- data/shen/release/k_lambda/t-star.kl +114 -3643
- data/shen/release/k_lambda/toplevel.kl +136 -221
- data/shen/release/k_lambda/track.kl +101 -206
- data/shen/release/k_lambda/types.kl +143 -298
- data/shen/release/k_lambda/writer.kl +93 -106
- data/shen/release/k_lambda/yacc.kl +77 -252
- data/shen/release/test_programs/README.shen +1 -1
- data/shen/release/test_programs/classes-typed.shen +1 -1
- data/shen/release/test_programs/interpreter.shen +2 -2
- data/shen/release/test_programs/metaprog.shen +2 -2
- data/shen/release/test_programs/prolog.shen +79 -0
- data/shen/release/test_programs/structures-typed.shen +2 -2
- data/shen/release/test_programs/tests.shen +19 -80
- data/shen/release/test_programs/yacc.shen +11 -15
- metadata +14 -6
- data/Gemfile.lock +0 -20
- data/shen/release/benchmarks/br.shen +0 -13
data/lib/kl/environment.rb
CHANGED
@@ -17,6 +17,13 @@ module Kl
|
|
17
17
|
define_method 'eval-kl' do |exp|
|
18
18
|
__eval(exp)
|
19
19
|
end
|
20
|
+
|
21
|
+
# Freeze is also provided as a normal function to support
|
22
|
+
# the partial application of zero arguments case. In this
|
23
|
+
# case it becomes a non-special-form.
|
24
|
+
def freeze(exp)
|
25
|
+
Kernel.lambda { exp }
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
data/lib/kl/primitives/lists.rb
CHANGED
@@ -5,18 +5,23 @@ module Kl
|
|
5
5
|
# its test suite, strings will be extended to support UTF-8.
|
6
6
|
module Strings
|
7
7
|
def pos(s, n)
|
8
|
+
raise Kl::Error, "#{s} is not a string" unless s.kind_of? String
|
9
|
+
raise Kl::Error, "#{n} is not an integer" unless n.kind_of? Fixnum
|
10
|
+
if n < 0 || n >= s.length
|
11
|
+
raise Kl::Error, "out of bounds"
|
12
|
+
end
|
8
13
|
s.byteslice(n)
|
9
14
|
end
|
10
15
|
|
11
16
|
def tlstr(s)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
s.byteslice(1, s.bytesize - 1)
|
16
|
-
end
|
17
|
+
raise Kl::Error, "#{s} is not a string" unless s.kind_of? String
|
18
|
+
raise Kl::Error, "attempted to take tail of an empty string" if s.empty?
|
19
|
+
s.byteslice(1, s.bytesize - 1)
|
17
20
|
end
|
18
21
|
|
19
22
|
def cn(s1, s2)
|
23
|
+
raise Kl::Error, "#{s1} is not a string" unless s1.kind_of? String
|
24
|
+
raise Kl::Error, "#{s2} is not a string" unless s2.kind_of? String
|
20
25
|
s1 + s2
|
21
26
|
end
|
22
27
|
|
@@ -44,10 +49,13 @@ module Kl
|
|
44
49
|
end
|
45
50
|
|
46
51
|
define_method 'n->string' do |n|
|
52
|
+
raise Kl::Error, "#{n} is not an integer" unless n.kind_of? Fixnum
|
47
53
|
"" << n
|
48
54
|
end
|
49
55
|
|
50
56
|
define_method 'string->n' do |s|
|
57
|
+
raise Kl::Error, "#{s} is not a string" unless s.kind_of? String
|
58
|
+
raise Kl::Error, 'attempted to get code point of empty string' if s.empty?
|
51
59
|
s.bytes.to_a.first
|
52
60
|
end
|
53
61
|
end
|
@@ -2,10 +2,13 @@ module Kl
|
|
2
2
|
module Primitives
|
3
3
|
module Vectors
|
4
4
|
def absvector(n)
|
5
|
+
raise Kl::Error, "#{n} is not a number" unless n.kind_of? Fixnum
|
5
6
|
Kl::Absvector.new(n)
|
6
7
|
end
|
7
8
|
|
8
9
|
define_method 'address->' do |v, n, value|
|
10
|
+
raise Kl::Error, "#{v} is not a vector" unless v.kind_of? Kl::Absvector
|
11
|
+
raise Kl::Error, "#{n} is not a number" unless n.kind_of? Fixnum
|
9
12
|
if n < 0 || n >= v.upper_limit
|
10
13
|
raise Kl::Error, "out of bounds"
|
11
14
|
end
|
@@ -15,6 +18,8 @@ module Kl
|
|
15
18
|
end
|
16
19
|
|
17
20
|
define_method '<-address' do |v, n|
|
21
|
+
raise Kl::Error, "#{v} is not a vector" unless v.kind_of? Kl::Absvector
|
22
|
+
raise Kl::Error, "#{n} is not a number" unless n.kind_of? Fixnum
|
18
23
|
if n < 0 || n >= v.upper_limit
|
19
24
|
raise Kl::Error, "out of bounds"
|
20
25
|
end
|
data/lib/shen_ruby/version.rb
CHANGED
data/shen-ruby.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.email = ["greg@sourcematters.org"]
|
13
13
|
s.homepage = "https://github.com/gregspurrier/shen-ruby"
|
14
14
|
s.summary = %q{ShenRuby is a Ruby port of the Shen programming language}
|
15
|
-
s.description = %q{ShenRuby is a port of the Shen programming language to Ruby. It currently supports Shen version
|
15
|
+
s.description = %q{ShenRuby is a port of the Shen programming language to Ruby. It currently supports Shen version 9.0.}
|
16
16
|
|
17
17
|
s.required_ruby_version = ">= 1.9.3"
|
18
18
|
|
data/shen/lib/shen_ruby/shen.rb
CHANGED
@@ -95,12 +95,6 @@ module ShenRuby
|
|
95
95
|
v
|
96
96
|
end
|
97
97
|
|
98
|
-
# The version of shen-explode-string from sys.kl is not tail-recursive.
|
99
|
-
# Replace it with a version that does not blow up the stack.
|
100
|
-
define_method "shen-explode-string" do |str|
|
101
|
-
Kl::Cons.list(str.split(//))
|
102
|
-
end
|
103
|
-
|
104
98
|
# Give a way to bail out
|
105
99
|
define_method 'quit' do
|
106
100
|
::Kernel.exit(0)
|
@@ -130,6 +124,11 @@ module ShenRuby
|
|
130
124
|
).each do |kl_filename|
|
131
125
|
Kl::Environment.load_file(self, File.join(kl_root, kl_filename + ".kl"))
|
132
126
|
end
|
127
|
+
|
128
|
+
# Give type signatures to the new functions added above
|
129
|
+
declare :quit, [:'-->', :unit]
|
130
|
+
declare :eval_string, [:string, :'-->', :unit]
|
131
|
+
declare :'eval-string', [:string, :'-->', :unit]
|
133
132
|
end
|
134
133
|
end
|
135
134
|
end
|
@@ -42,10 +42,6 @@
|
|
42
42
|
|
43
43
|
(benchmark "(tak 18 12 6)" (tak 18 12 6))
|
44
44
|
|
45
|
-
(benchmark "compile 10 line YACC program for paren checking" (load "br.shen"))
|
46
|
-
|
47
|
-
(benchmark "paren check a 2000 line program" (compile <br> (read-file-as-bytelist "bigprog")))
|
48
|
-
|
49
45
|
(tc +)
|
50
46
|
|
51
47
|
(benchmark "type checking the N queens" (load "N_queens.shen"))
|
@@ -101,9 +101,9 @@
|
|
101
101
|
|
102
102
|
(define normal_form
|
103
103
|
{l_formula --> l_formula}
|
104
|
-
X -> (fix
|
104
|
+
X -> (fix (function ==>>) X))
|
105
105
|
|
106
|
-
(define
|
106
|
+
(define ==>>
|
107
107
|
{l_formula --> l_formula}
|
108
108
|
[= X Y] -> (let X* (normal_form X)
|
109
109
|
(let Y* (normal_form Y)
|
Binary file
|
@@ -1,1002 +1,173 @@
|
|
1
|
+
"**********************************************************************************
|
2
|
+
* The License *
|
3
|
+
* *
|
4
|
+
* The user is free to produce commercial applications with the software, to *
|
5
|
+
* distribute these applications in source or binary form, and to charge monies *
|
6
|
+
* for them as he sees fit and in concordance with the laws of the land subject *
|
7
|
+
* to the following license. *
|
8
|
+
* *
|
9
|
+
* 1. The license applies to all the software and all derived software and *
|
10
|
+
* must appear on such. *
|
11
|
+
* *
|
12
|
+
* 2. It is illegal to distribute the software without this license attached *
|
13
|
+
* to it and use of the software implies agreement with the license as such. *
|
14
|
+
* It is illegal for anyone who is not the copyright holder to tamper with *
|
15
|
+
* or change the license. *
|
16
|
+
* *
|
17
|
+
* 3. Neither the names of Lambda Associates or the copyright holder may be used *
|
18
|
+
* to endorse or promote products built using the software without specific *
|
19
|
+
* prior written permission from the copyright holder. *
|
20
|
+
* *
|
21
|
+
* 4. That possession of this license does not confer on the copyright holder *
|
22
|
+
* any special contractual obligation towards the user. That in no event *
|
23
|
+
* shall the copyright holder be liable for any direct, indirect, incidental, *
|
24
|
+
* special, exemplary or consequential damages (including but not limited *
|
25
|
+
* to procurement of substitute goods or services, loss of use, data, *
|
26
|
+
* interruption), however caused and on any theory of liability, whether in *
|
27
|
+
* contract, strict liability or tort (including negligence) arising in any *
|
28
|
+
* way out of the use of the software, even if advised of the possibility of *
|
29
|
+
* such damage. *
|
30
|
+
* *
|
31
|
+
* 5. It is permitted for the user to change the software, for the purpose of *
|
32
|
+
* improving performance, correcting an error, or porting to a new platform, *
|
33
|
+
* and distribute the derived version of Shen provided the resulting program *
|
34
|
+
* conforms in all respects to the Shen standard and is issued under that *
|
35
|
+
* title. The user must make it clear with his distribution that he/she is *
|
36
|
+
* the author of the changes and what these changes are and why. *
|
37
|
+
* *
|
38
|
+
* 6. Derived versions of this software in whatever form are subject to the same *
|
39
|
+
* restrictions. In particular it is not permitted to make derived copies of *
|
40
|
+
* this software which do not conform to the Shen standard or appear under a *
|
41
|
+
* different title. *
|
42
|
+
* *
|
43
|
+
* It is permitted to distribute versions of Shen which incorporate libraries, *
|
44
|
+
* graphics or other facilities which are not part of the Shen standard. *
|
45
|
+
* *
|
46
|
+
* For an explication of this license see www.shenlanguage.org/license.htm which *
|
47
|
+
* explains this license in full. *
|
48
|
+
* *
|
49
|
+
*****************************************************************************************
|
50
|
+
"(defun shen.shen->kl (V605 V606) (compile shen.<define> (cons V605 V606) (lambda X (shen.shen-syntax-error V605 X))))
|
51
|
+
|
52
|
+
(defun shen.shen-syntax-error (V607 V608) (simple-error (cn "syntax error in " (shen.app V607 (cn " here:
|
53
|
+
|
54
|
+
" (shen.app (shen.next-50 50 V608) "
|
55
|
+
" shen.a)) shen.a))))
|
56
|
+
|
57
|
+
(defun shen.<define> (V613) (let Result (let Parse_shen.<name> (shen.<name> V613) (if (not (= (fail) Parse_shen.<name>)) (let Parse_shen.<signature> (shen.<signature> Parse_shen.<name>) (if (not (= (fail) Parse_shen.<signature>)) (let Parse_shen.<rules> (shen.<rules> Parse_shen.<signature>) (if (not (= (fail) Parse_shen.<rules>)) (shen.pair (hd Parse_shen.<rules>) (shen.compile_to_machine_code (shen.hdtl Parse_shen.<name>) (shen.hdtl Parse_shen.<rules>))) (fail))) (fail))) (fail))) (if (= Result (fail)) (let Result (let Parse_shen.<name> (shen.<name> V613) (if (not (= (fail) Parse_shen.<name>)) (let Parse_shen.<rules> (shen.<rules> Parse_shen.<name>) (if (not (= (fail) Parse_shen.<rules>)) (shen.pair (hd Parse_shen.<rules>) (shen.compile_to_machine_code (shen.hdtl Parse_shen.<name>) (shen.hdtl Parse_shen.<rules>))) (fail))) (fail))) (if (= Result (fail)) (fail) Result)) Result)))
|
58
|
+
|
59
|
+
(defun shen.<name> (V618) (let Result (if (cons? (hd V618)) (let Parse_X (hd (hd V618)) (shen.pair (hd (shen.pair (tl (hd V618)) (shen.hdtl V618))) (if (and (symbol? Parse_X) (not (shen.sysfunc? Parse_X))) Parse_X (simple-error (shen.app Parse_X " is not a legitimate function name.
|
60
|
+
" shen.a))))) (fail)) (if (= Result (fail)) (fail) Result)))
|
61
|
+
|
62
|
+
(defun shen.sysfunc? (V619) (element? V619 (get (intern "shen") shen.external-symbols (value *property-vector*))))
|
63
|
+
|
64
|
+
(defun shen.<signature> (V624) (let Result (if (and (cons? (hd V624)) (= { (hd (hd V624)))) (let Parse_shen.<signature-help> (shen.<signature-help> (shen.pair (tl (hd V624)) (shen.hdtl V624))) (if (not (= (fail) Parse_shen.<signature-help>)) (if (and (cons? (hd Parse_shen.<signature-help>)) (= } (hd (hd Parse_shen.<signature-help>)))) (shen.pair (hd (shen.pair (tl (hd Parse_shen.<signature-help>)) (shen.hdtl Parse_shen.<signature-help>))) (shen.normalise-type (shen.curry-type (shen.hdtl Parse_shen.<signature-help>)))) (fail)) (fail))) (fail)) (if (= Result (fail)) (fail) Result)))
|
65
|
+
|
66
|
+
(defun shen.curry-type (V627) (cond ((and (cons? V627) (and (cons? (tl V627)) (and (= --> (hd (tl V627))) (and (cons? (tl (tl V627))) (and (cons? (tl (tl (tl V627)))) (= --> (hd (tl (tl (tl V627)))))))))) (shen.curry-type (cons (hd V627) (cons --> (cons (tl (tl V627)) ()))))) ((and (cons? V627) (and (= cons (hd V627)) (and (cons? (tl V627)) (and (cons? (tl (tl V627))) (= () (tl (tl (tl V627)))))))) (cons list (cons (shen.curry-type (hd (tl V627))) ()))) ((and (cons? V627) (and (cons? (tl V627)) (and (= * (hd (tl V627))) (and (cons? (tl (tl V627))) (and (cons? (tl (tl (tl V627)))) (= * (hd (tl (tl (tl V627)))))))))) (shen.curry-type (cons (hd V627) (cons * (cons (tl (tl V627)) ()))))) ((cons? V627) (map shen.curry-type V627)) (true V627)))
|
67
|
+
|
68
|
+
(defun shen.<signature-help> (V632) (let Result (if (cons? (hd V632)) (let Parse_X (hd (hd V632)) (let Parse_shen.<signature-help> (shen.<signature-help> (shen.pair (tl (hd V632)) (shen.hdtl V632))) (if (not (= (fail) Parse_shen.<signature-help>)) (if (not (element? Parse_X (cons { (cons } ())))) (shen.pair (hd Parse_shen.<signature-help>) (cons Parse_X (shen.hdtl Parse_shen.<signature-help>))) (fail)) (fail)))) (fail)) (if (= Result (fail)) (let Result (let Parse_<e> (<e> V632) (if (not (= (fail) Parse_<e>)) (shen.pair (hd Parse_<e>) ()) (fail))) (if (= Result (fail)) (fail) Result)) Result)))
|
69
|
+
|
70
|
+
(defun shen.<rules> (V637) (let Result (let Parse_shen.<rule> (shen.<rule> V637) (if (not (= (fail) Parse_shen.<rule>)) (let Parse_shen.<rules> (shen.<rules> Parse_shen.<rule>) (if (not (= (fail) Parse_shen.<rules>)) (shen.pair (hd Parse_shen.<rules>) (cons (shen.hdtl Parse_shen.<rule>) (shen.hdtl Parse_shen.<rules>))) (fail))) (fail))) (if (= Result (fail)) (let Result (let Parse_shen.<rule> (shen.<rule> V637) (if (not (= (fail) Parse_shen.<rule>)) (shen.pair (hd Parse_shen.<rule>) (cons (shen.hdtl Parse_shen.<rule>) ())) (fail))) (if (= Result (fail)) (fail) Result)) Result)))
|
71
|
+
|
72
|
+
(defun shen.<rule> (V642) (let Result (let Parse_shen.<patterns> (shen.<patterns> V642) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= -> (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (if (and (cons? (hd Parse_shen.<action>)) (= where (hd (hd Parse_shen.<action>)))) (let Parse_shen.<guard> (shen.<guard> (shen.pair (tl (hd Parse_shen.<action>)) (shen.hdtl Parse_shen.<action>))) (if (not (= (fail) Parse_shen.<guard>)) (shen.pair (hd Parse_shen.<guard>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (cons where (cons (shen.hdtl Parse_shen.<guard>) (cons (shen.hdtl Parse_shen.<action>) ()))) ()))) (fail))) (fail)) (fail))) (fail)) (fail))) (if (= Result (fail)) (let Result (let Parse_shen.<patterns> (shen.<patterns> V642) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= -> (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (shen.pair (hd Parse_shen.<action>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (shen.hdtl Parse_shen.<action>) ()))) (fail))) (fail)) (fail))) (if (= Result (fail)) (let Result (let Parse_shen.<patterns> (shen.<patterns> V642) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= <- (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (if (and (cons? (hd Parse_shen.<action>)) (= where (hd (hd Parse_shen.<action>)))) (let Parse_shen.<guard> (shen.<guard> (shen.pair (tl (hd Parse_shen.<action>)) (shen.hdtl Parse_shen.<action>))) (if (not (= (fail) Parse_shen.<guard>)) (shen.pair (hd Parse_shen.<guard>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (cons where (cons (shen.hdtl Parse_shen.<guard>) (cons (cons shen.choicepoint! (cons (shen.hdtl Parse_shen.<action>) ())) ()))) ()))) (fail))) (fail)) (fail))) (fail)) (fail))) (if (= Result (fail)) (let Result (let Parse_shen.<patterns> (shen.<patterns> V642) (if (not (= (fail) Parse_shen.<patterns>)) (if (and (cons? (hd Parse_shen.<patterns>)) (= <- (hd (hd Parse_shen.<patterns>)))) (let Parse_shen.<action> (shen.<action> (shen.pair (tl (hd Parse_shen.<patterns>)) (shen.hdtl Parse_shen.<patterns>))) (if (not (= (fail) Parse_shen.<action>)) (shen.pair (hd Parse_shen.<action>) (cons (shen.hdtl Parse_shen.<patterns>) (cons (cons shen.choicepoint! (cons (shen.hdtl Parse_shen.<action>) ())) ()))) (fail))) (fail)) (fail))) (if (= Result (fail)) (fail) Result)) Result)) Result)) Result)))
|
73
|
+
|
74
|
+
(defun shen.fail_if (V643 V644) (if (V643 V644) (fail) V644))
|
75
|
+
|
76
|
+
(defun shen.succeeds? (V649) (cond ((= V649 (fail)) false) (true true)))
|
77
|
+
|
78
|
+
(defun shen.<patterns> (V654) (let Result (let Parse_shen.<pattern> (shen.<pattern> V654) (if (not (= (fail) Parse_shen.<pattern>)) (let Parse_shen.<patterns> (shen.<patterns> Parse_shen.<pattern>) (if (not (= (fail) Parse_shen.<patterns>)) (shen.pair (hd Parse_shen.<patterns>) (cons (shen.hdtl Parse_shen.<pattern>) (shen.hdtl Parse_shen.<patterns>))) (fail))) (fail))) (if (= Result (fail)) (let Result (let Parse_<e> (<e> V654) (if (not (= (fail) Parse_<e>)) (shen.pair (hd Parse_<e>) ()) (fail))) (if (= Result (fail)) (fail) Result)) Result)))
|
79
|
+
|
80
|
+
(defun shen.<pattern> (V659) (let Result (if (and (cons? (hd V659)) (cons? (hd (hd V659)))) (shen.snd-or-fail (if (and (cons? (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (= @p (hd (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd Parse_shen.<pattern2>) (shen.pair (hd (shen.pair (tl (hd V659)) (shen.hdtl V659))) (cons @p (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ()))))) (fail))) (fail))) (fail))) (fail)) (if (= Result (fail)) (let Result (if (and (cons? (hd V659)) (cons? (hd (hd V659)))) (shen.snd-or-fail (if (and (cons? (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (= cons (hd (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd Parse_shen.<pattern2>) (shen.pair (hd (shen.pair (tl (hd V659)) (shen.hdtl V659))) (cons cons (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ()))))) (fail))) (fail))) (fail))) (fail)) (if (= Result (fail)) (let Result (if (and (cons? (hd V659)) (cons? (hd (hd V659)))) (shen.snd-or-fail (if (and (cons? (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (= @v (hd (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd Parse_shen.<pattern2>) (shen.pair (hd (shen.pair (tl (hd V659)) (shen.hdtl V659))) (cons @v (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ()))))) (fail))) (fail))) (fail))) (fail)) (if (= Result (fail)) (let Result (if (and (cons? (hd V659)) (cons? (hd (hd V659)))) (shen.snd-or-fail (if (and (cons? (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (= @s (hd (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (let Parse_shen.<pattern1> (shen.<pattern1> (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659))))) (if (not (= (fail) Parse_shen.<pattern1>)) (let Parse_shen.<pattern2> (shen.<pattern2> Parse_shen.<pattern1>) (if (not (= (fail) Parse_shen.<pattern2>)) (shen.pair (hd Parse_shen.<pattern2>) (shen.pair (hd (shen.pair (tl (hd V659)) (shen.hdtl V659))) (cons @s (cons (shen.hdtl Parse_shen.<pattern1>) (cons (shen.hdtl Parse_shen.<pattern2>) ()))))) (fail))) (fail))) (fail))) (fail)) (if (= Result (fail)) (let Result (if (and (cons? (hd V659)) (cons? (hd (hd V659)))) (shen.snd-or-fail (if (and (cons? (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (= vector (hd (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (if (and (cons? (hd (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (= 0 (hd (hd (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659)))))))) (shen.pair (hd (shen.pair (tl (hd (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659)))))) (shen.hdtl (shen.pair (tl (hd (shen.pair (hd (hd V659)) (shen.hdtl V659)))) (shen.hdtl (shen.pair (hd (hd V659)) (shen.hdtl V659))))))) (shen.pair (hd (shen.pair (tl (hd V659)) (shen.hdtl V659))) (cons vector (cons 0 ())))) (fail)) (fail))) (fail)) (if (= Result (fail)) (let Result (if (cons? (hd V659)) (let Parse_X (hd (hd V659)) (if (cons? Parse_X) (shen.pair (hd (shen.pair (tl (hd V659)) (shen.hdtl V659))) (shen.constructor-error Parse_X)) (fail))) (fail)) (if (= Result (fail)) (let Result (let Parse_shen.<simple_pattern> (shen.<simple_pattern> V659) (if (not (= (fail) Parse_shen.<simple_pattern>)) (shen.pair (hd Parse_shen.<simple_pattern>) (shen.hdtl Parse_shen.<simple_pattern>)) (fail))) (if (= Result (fail)) (fail) Result)) Result)) Result)) Result)) Result)) Result)) Result)))
|
81
|
+
|
82
|
+
(defun shen.constructor-error (V660) (simple-error (shen.app V660 " is not a legitimate constructor
|
83
|
+
" shen.a)))
|
84
|
+
|
85
|
+
(defun shen.<simple_pattern> (V665) (let Result (if (cons? (hd V665)) (let Parse_X (hd (hd V665)) (if (= Parse_X _) (shen.pair (hd (shen.pair (tl (hd V665)) (shen.hdtl V665))) (gensym Parse_Y)) (fail))) (fail)) (if (= Result (fail)) (let Result (if (cons? (hd V665)) (let Parse_X (hd (hd V665)) (if (not (element? Parse_X (cons -> (cons <- ())))) (shen.pair (hd (shen.pair (tl (hd V665)) (shen.hdtl V665))) Parse_X) (fail))) (fail)) (if (= Result (fail)) (fail) Result)) Result)))
|
86
|
+
|
87
|
+
(defun shen.<pattern1> (V670) (let Result (let Parse_shen.<pattern> (shen.<pattern> V670) (if (not (= (fail) Parse_shen.<pattern>)) (shen.pair (hd Parse_shen.<pattern>) (shen.hdtl Parse_shen.<pattern>)) (fail))) (if (= Result (fail)) (fail) Result)))
|
88
|
+
|
89
|
+
(defun shen.<pattern2> (V675) (let Result (let Parse_shen.<pattern> (shen.<pattern> V675) (if (not (= (fail) Parse_shen.<pattern>)) (shen.pair (hd Parse_shen.<pattern>) (shen.hdtl Parse_shen.<pattern>)) (fail))) (if (= Result (fail)) (fail) Result)))
|
90
|
+
|
91
|
+
(defun shen.<action> (V680) (let Result (if (cons? (hd V680)) (let Parse_X (hd (hd V680)) (shen.pair (hd (shen.pair (tl (hd V680)) (shen.hdtl V680))) Parse_X)) (fail)) (if (= Result (fail)) (fail) Result)))
|
92
|
+
|
93
|
+
(defun shen.<guard> (V685) (let Result (if (cons? (hd V685)) (let Parse_X (hd (hd V685)) (shen.pair (hd (shen.pair (tl (hd V685)) (shen.hdtl V685))) Parse_X)) (fail)) (if (= Result (fail)) (fail) Result)))
|
94
|
+
|
95
|
+
(defun shen.compile_to_machine_code (V686 V687) (let Lambda+ (shen.compile_to_lambda+ V686 V687) (let KL (shen.compile_to_kl V686 Lambda+) (let Record (shen.record-source V686 KL) KL))))
|
96
|
+
|
97
|
+
(defun shen.record-source (V690 V691) (cond ((value shen.*installing-kl*) shen.skip) (true (put V690 shen.source V691 (value *property-vector*)))))
|
98
|
+
|
99
|
+
(defun shen.compile_to_lambda+ (V692 V693) (let Arity (shen.aritycheck V692 V693) (let Free (map (lambda Rule (shen.free_variable_check V692 Rule)) V693) (let Variables (shen.parameters Arity) (let Linear (map shen.linearise (shen.strip-protect V693)) (let Abstractions (map shen.abstract_rule Linear) (let Applications (map (lambda X (shen.application_build Variables X)) Abstractions) (cons Variables (cons Applications ())))))))))
|
100
|
+
|
101
|
+
(defun shen.free_variable_check (V694 V695) (cond ((and (cons? V695) (and (cons? (tl V695)) (= () (tl (tl V695))))) (let Bound (shen.extract_vars (hd V695)) (let Free (shen.extract_free_vars Bound (hd (tl V695))) (shen.free_variable_warnings V694 Free)))) (true (shen.sys-error shen.free_variable_check))))
|
102
|
+
|
103
|
+
(defun shen.extract_vars (V696) (cond ((variable? V696) (cons V696 ())) ((cons? V696) (union (shen.extract_vars (hd V696)) (shen.extract_vars (tl V696)))) (true ())))
|
104
|
+
|
105
|
+
(defun shen.extract_free_vars (V706 V707) (cond ((and (cons? V707) (and (cons? (tl V707)) (and (= () (tl (tl V707))) (= (hd V707) protect)))) ()) ((and (variable? V707) (not (element? V707 V706))) (cons V707 ())) ((and (cons? V707) (and (= lambda (hd V707)) (and (cons? (tl V707)) (and (cons? (tl (tl V707))) (= () (tl (tl (tl V707)))))))) (shen.extract_free_vars (cons (hd (tl V707)) V706) (hd (tl (tl V707))))) ((and (cons? V707) (and (= let (hd V707)) (and (cons? (tl V707)) (and (cons? (tl (tl V707))) (and (cons? (tl (tl (tl V707)))) (= () (tl (tl (tl (tl V707)))))))))) (union (shen.extract_free_vars V706 (hd (tl (tl V707)))) (shen.extract_free_vars (cons (hd (tl V707)) V706) (hd (tl (tl (tl V707))))))) ((cons? V707) (union (shen.extract_free_vars V706 (hd V707)) (shen.extract_free_vars V706 (tl V707)))) (true ())))
|
106
|
+
|
107
|
+
(defun shen.free_variable_warnings (V710 V711) (cond ((= () V711) _) (true (simple-error (cn "error: the following variables are free in " (shen.app V710 (cn ": " (shen.app (shen.list_variables V711) "" shen.a)) shen.a))))))
|
108
|
+
|
109
|
+
(defun shen.list_variables (V712) (cond ((and (cons? V712) (= () (tl V712))) (cn (str (hd V712)) ".")) ((cons? V712) (cn (str (hd V712)) (cn ", " (shen.list_variables (tl V712))))) (true (shen.sys-error shen.list_variables))))
|
110
|
+
|
111
|
+
(defun shen.strip-protect (V713) (cond ((and (cons? V713) (and (cons? (tl V713)) (and (= () (tl (tl V713))) (= (hd V713) protect)))) (hd (tl V713))) ((cons? V713) (cons (shen.strip-protect (hd V713)) (shen.strip-protect (tl V713)))) (true V713)))
|
112
|
+
|
113
|
+
(defun shen.linearise (V714) (cond ((and (cons? V714) (and (cons? (tl V714)) (= () (tl (tl V714))))) (shen.linearise_help (shen.flatten (hd V714)) (hd V714) (hd (tl V714)))) (true (shen.sys-error shen.linearise))))
|
114
|
+
|
115
|
+
(defun shen.flatten (V715) (cond ((= () V715) ()) ((cons? V715) (append (shen.flatten (hd V715)) (shen.flatten (tl V715)))) (true (cons V715 ()))))
|
116
|
+
|
117
|
+
(defun shen.linearise_help (V716 V717 V718) (cond ((= () V716) (cons V717 (cons V718 ()))) ((cons? V716) (if (and (variable? (hd V716)) (element? (hd V716) (tl V716))) (let Var (gensym (hd V716)) (let NewAction (cons where (cons (cons = (cons (hd V716) (cons Var ()))) (cons V718 ()))) (let NewPatts (shen.linearise_X (hd V716) Var V717) (shen.linearise_help (tl V716) NewPatts NewAction)))) (shen.linearise_help (tl V716) V717 V718))) (true (shen.sys-error shen.linearise_help))))
|
118
|
+
|
119
|
+
(defun shen.linearise_X (V727 V728 V729) (cond ((= V729 V727) V728) ((cons? V729) (let L (shen.linearise_X V727 V728 (hd V729)) (if (= L (hd V729)) (cons (hd V729) (shen.linearise_X V727 V728 (tl V729))) (cons L (tl V729))))) (true V729)))
|
120
|
+
|
121
|
+
(defun shen.aritycheck (V731 V732) (cond ((and (cons? V732) (and (cons? (hd V732)) (and (cons? (tl (hd V732))) (and (= () (tl (tl (hd V732)))) (= () (tl V732)))))) (do (shen.aritycheck-action (hd (tl (hd V732)))) (shen.aritycheck-name V731 (arity V731) (length (hd (hd V732)))))) ((and (cons? V732) (and (cons? (hd V732)) (and (cons? (tl (hd V732))) (and (= () (tl (tl (hd V732)))) (and (cons? (tl V732)) (and (cons? (hd (tl V732))) (and (cons? (tl (hd (tl V732)))) (= () (tl (tl (hd (tl V732)))))))))))) (if (= (length (hd (hd V732))) (length (hd (hd (tl V732))))) (do (shen.aritycheck-action (hd (tl (hd V732)))) (shen.aritycheck V731 (tl V732))) (simple-error (cn "arity error in " (shen.app V731 "
|
122
|
+
" shen.a))))) (true (shen.sys-error shen.aritycheck))))
|
123
|
+
|
124
|
+
(defun shen.aritycheck-name (V741 V742 V743) (cond ((= -1 V742) V743) ((= V743 V742) V743) (true (do (pr (cn "
|
125
|
+
warning: changing the arity of " (shen.app V741 " can cause errors.
|
126
|
+
" shen.a)) (stoutput)) V743))))
|
127
|
+
|
128
|
+
(defun shen.aritycheck-action (V749) (cond ((cons? V749) (do (shen.aah (hd V749) (tl V749)) (map shen.aritycheck-action V749))) (true shen.skip)))
|
129
|
+
|
130
|
+
(defun shen.aah (V750 V751) (let Arity (arity V750) (let Len (length V751) (if (and (> Arity -1) (> Len Arity)) (pr (cn "warning: " (shen.app V750 (cn " might not like " (shen.app Len (cn " argument" (shen.app (if (> Len 1) "s" "") ".
|
131
|
+
" shen.a)) shen.a)) shen.a)) (stoutput)) shen.skip))))
|
132
|
+
|
133
|
+
(defun shen.abstract_rule (V752) (cond ((and (cons? V752) (and (cons? (tl V752)) (= () (tl (tl V752))))) (shen.abstraction_build (hd V752) (hd (tl V752)))) (true (shen.sys-error shen.abstract_rule))))
|
134
|
+
|
135
|
+
(defun shen.abstraction_build (V753 V754) (cond ((= () V753) V754) ((cons? V753) (cons /. (cons (hd V753) (cons (shen.abstraction_build (tl V753) V754) ())))) (true (shen.sys-error shen.abstraction_build))))
|
136
|
+
|
137
|
+
(defun shen.parameters (V755) (cond ((= 0 V755) ()) (true (cons (gensym V) (shen.parameters (- V755 1))))))
|
138
|
+
|
139
|
+
(defun shen.application_build (V756 V757) (cond ((= () V756) V757) ((cons? V756) (shen.application_build (tl V756) (cons V757 (cons (hd V756) ())))) (true (shen.sys-error shen.application_build))))
|
140
|
+
|
141
|
+
(defun shen.compile_to_kl (V758 V759) (cond ((and (cons? V759) (and (cons? (tl V759)) (= () (tl (tl V759))))) (let Arity (shen.store-arity V758 (length (hd V759))) (let Reduce (map shen.reduce (hd (tl V759))) (let CondExpression (shen.cond-expression V758 (hd V759) Reduce) (let KL (cons defun (cons V758 (cons (hd V759) (cons CondExpression ())))) KL))))) (true (shen.sys-error shen.compile_to_kl))))
|
142
|
+
|
143
|
+
(defun shen.store-arity (V762 V763) (cond ((value shen.*installing-kl*) shen.skip) (true (put V762 arity V763 (value *property-vector*)))))
|
144
|
+
|
145
|
+
(defun shen.reduce (V764) (do (set shen.*teststack* ()) (let Result (shen.reduce_help V764) (cons (cons : (cons shen.tests (reverse (value shen.*teststack*)))) (cons Result ())))))
|
146
|
+
|
147
|
+
(defun shen.reduce_help (V765) (cond ((and (cons? V765) (and (cons? (hd V765)) (and (= /. (hd (hd V765))) (and (cons? (tl (hd V765))) (and (cons? (hd (tl (hd V765)))) (and (= cons (hd (hd (tl (hd V765))))) (and (cons? (tl (hd (tl (hd V765))))) (and (cons? (tl (tl (hd (tl (hd V765)))))) (and (= () (tl (tl (tl (hd (tl (hd V765))))))) (and (cons? (tl (tl (hd V765)))) (and (= () (tl (tl (tl (hd V765))))) (and (cons? (tl V765)) (= () (tl (tl V765))))))))))))))) (do (shen.add_test (cons cons? (tl V765))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V765))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V765)))))) (cons (shen.ebr (hd (tl V765)) (hd (tl (hd V765))) (hd (tl (tl (hd V765))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons hd (tl V765)) ())) (cons (cons tl (tl V765)) ())) (shen.reduce_help Application))))) ((and (cons? V765) (and (cons? (hd V765)) (and (= /. (hd (hd V765))) (and (cons? (tl (hd V765))) (and (cons? (hd (tl (hd V765)))) (and (= @p (hd (hd (tl (hd V765))))) (and (cons? (tl (hd (tl (hd V765))))) (and (cons? (tl (tl (hd (tl (hd V765)))))) (and (= () (tl (tl (tl (hd (tl (hd V765))))))) (and (cons? (tl (tl (hd V765)))) (and (= () (tl (tl (tl (hd V765))))) (and (cons? (tl V765)) (= () (tl (tl V765))))))))))))))) (do (shen.add_test (cons tuple? (tl V765))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V765))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V765)))))) (cons (shen.ebr (hd (tl V765)) (hd (tl (hd V765))) (hd (tl (tl (hd V765))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons fst (tl V765)) ())) (cons (cons snd (tl V765)) ())) (shen.reduce_help Application))))) ((and (cons? V765) (and (cons? (hd V765)) (and (= /. (hd (hd V765))) (and (cons? (tl (hd V765))) (and (cons? (hd (tl (hd V765)))) (and (= @v (hd (hd (tl (hd V765))))) (and (cons? (tl (hd (tl (hd V765))))) (and (cons? (tl (tl (hd (tl (hd V765)))))) (and (= () (tl (tl (tl (hd (tl (hd V765))))))) (and (cons? (tl (tl (hd V765)))) (and (= () (tl (tl (tl (hd V765))))) (and (cons? (tl V765)) (= () (tl (tl V765))))))))))))))) (do (shen.add_test (cons shen.+vector? (tl V765))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V765))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V765)))))) (cons (shen.ebr (hd (tl V765)) (hd (tl (hd V765))) (hd (tl (tl (hd V765))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons hdv (tl V765)) ())) (cons (cons tlv (tl V765)) ())) (shen.reduce_help Application))))) ((and (cons? V765) (and (cons? (hd V765)) (and (= /. (hd (hd V765))) (and (cons? (tl (hd V765))) (and (cons? (hd (tl (hd V765)))) (and (= @s (hd (hd (tl (hd V765))))) (and (cons? (tl (hd (tl (hd V765))))) (and (cons? (tl (tl (hd (tl (hd V765)))))) (and (= () (tl (tl (tl (hd (tl (hd V765))))))) (and (cons? (tl (tl (hd V765)))) (and (= () (tl (tl (tl (hd V765))))) (and (cons? (tl V765)) (= () (tl (tl V765))))))))))))))) (do (shen.add_test (cons shen.+string? (tl V765))) (let Abstraction (cons /. (cons (hd (tl (hd (tl (hd V765))))) (cons (cons /. (cons (hd (tl (tl (hd (tl (hd V765)))))) (cons (shen.ebr (hd (tl V765)) (hd (tl (hd V765))) (hd (tl (tl (hd V765))))) ()))) ()))) (let Application (cons (cons Abstraction (cons (cons pos (cons (hd (tl V765)) (cons 0 ()))) ())) (cons (cons tlstr (tl V765)) ())) (shen.reduce_help Application))))) ((and (cons? V765) (and (cons? (hd V765)) (and (= /. (hd (hd V765))) (and (cons? (tl (hd V765))) (and (cons? (tl (tl (hd V765)))) (and (= () (tl (tl (tl (hd V765))))) (and (cons? (tl V765)) (and (= () (tl (tl V765))) (not (variable? (hd (tl (hd V765))))))))))))) (do (shen.add_test (cons = (cons (hd (tl (hd V765))) (tl V765)))) (shen.reduce_help (hd (tl (tl (hd V765))))))) ((and (cons? V765) (and (cons? (hd V765)) (and (= /. (hd (hd V765))) (and (cons? (tl (hd V765))) (and (cons? (tl (tl (hd V765)))) (and (= () (tl (tl (tl (hd V765))))) (and (cons? (tl V765)) (= () (tl (tl V765)))))))))) (shen.reduce_help (shen.ebr (hd (tl V765)) (hd (tl (hd V765))) (hd (tl (tl (hd V765))))))) ((and (cons? V765) (and (= where (hd V765)) (and (cons? (tl V765)) (and (cons? (tl (tl V765))) (= () (tl (tl (tl V765)))))))) (do (shen.add_test (hd (tl V765))) (shen.reduce_help (hd (tl (tl V765)))))) ((and (cons? V765) (and (cons? (tl V765)) (= () (tl (tl V765))))) (let Z (shen.reduce_help (hd V765)) (if (= (hd V765) Z) V765 (shen.reduce_help (cons Z (tl V765)))))) (true V765)))
|
148
|
+
|
149
|
+
(defun shen.+string? (V766) (cond ((= "" V766) false) (true (string? V766))))
|
150
|
+
|
151
|
+
(defun shen.+vector (V767) (cond ((= V767 (vector 0)) false) (true (vector? V767))))
|
152
|
+
|
153
|
+
(defun shen.ebr (V776 V777 V778) (cond ((= V778 V777) V776) ((and (cons? V778) (and (= /. (hd V778)) (and (cons? (tl V778)) (and (cons? (tl (tl V778))) (and (= () (tl (tl (tl V778)))) (> (occurrences V777 (hd (tl V778))) 0)))))) V778) ((and (cons? V778) (and (= let (hd V778)) (and (cons? (tl V778)) (and (cons? (tl (tl V778))) (and (cons? (tl (tl (tl V778)))) (and (= () (tl (tl (tl (tl V778))))) (= (hd (tl V778)) V777))))))) (cons let (cons (hd (tl V778)) (cons (shen.ebr V776 (hd (tl V778)) (hd (tl (tl V778)))) (tl (tl (tl V778))))))) ((cons? V778) (cons (shen.ebr V776 V777 (hd V778)) (shen.ebr V776 V777 (tl V778)))) (true V778)))
|
154
|
+
|
155
|
+
(defun shen.add_test (V781) (set shen.*teststack* (cons V781 (value shen.*teststack*))))
|
156
|
+
|
157
|
+
(defun shen.cond-expression (V782 V783 V784) (let Err (shen.err-condition V782) (let Cases (shen.case-form V784 Err) (let EncodeChoices (shen.encode-choices Cases V782) (shen.cond-form EncodeChoices)))))
|
158
|
+
|
159
|
+
(defun shen.cond-form (V787) (cond ((and (cons? V787) (and (cons? (hd V787)) (and (= true (hd (hd V787))) (and (cons? (tl (hd V787))) (= () (tl (tl (hd V787)))))))) (hd (tl (hd V787)))) (true (cons cond V787))))
|
160
|
+
|
161
|
+
(defun shen.encode-choices (V790 V791) (cond ((= () V790) ()) ((and (cons? V790) (and (cons? (hd V790)) (and (= true (hd (hd V790))) (and (cons? (tl (hd V790))) (and (cons? (hd (tl (hd V790)))) (and (= shen.choicepoint! (hd (hd (tl (hd V790))))) (and (cons? (tl (hd (tl (hd V790))))) (and (= () (tl (tl (hd (tl (hd V790)))))) (and (= () (tl (tl (hd V790)))) (= () (tl V790))))))))))) (cons (cons true (cons (cons let (cons Result (cons (hd (tl (hd (tl (hd V790))))) (cons (cons if (cons (cons = (cons Result (cons (cons fail ()) ()))) (cons (if (value shen.*installing-kl*) (cons shen.sys-error (cons V791 ())) (cons shen.f_error (cons V791 ()))) (cons Result ())))) ())))) ())) ())) ((and (cons? V790) (and (cons? (hd V790)) (and (= true (hd (hd V790))) (and (cons? (tl (hd V790))) (and (cons? (hd (tl (hd V790)))) (and (= shen.choicepoint! (hd (hd (tl (hd V790))))) (and (cons? (tl (hd (tl (hd V790))))) (and (= () (tl (tl (hd (tl (hd V790)))))) (= () (tl (tl (hd V790)))))))))))) (cons (cons true (cons (cons let (cons Result (cons (hd (tl (hd (tl (hd V790))))) (cons (cons if (cons (cons = (cons Result (cons (cons fail ()) ()))) (cons (shen.cond-form (shen.encode-choices (tl V790) V791)) (cons Result ())))) ())))) ())) ())) ((and (cons? V790) (and (cons? (hd V790)) (and (cons? (tl (hd V790))) (and (cons? (hd (tl (hd V790)))) (and (= shen.choicepoint! (hd (hd (tl (hd V790))))) (and (cons? (tl (hd (tl (hd V790))))) (and (= () (tl (tl (hd (tl (hd V790)))))) (= () (tl (tl (hd V790))))))))))) (cons (cons true (cons (cons let (cons Freeze (cons (cons freeze (cons (shen.cond-form (shen.encode-choices (tl V790) V791)) ())) (cons (cons if (cons (hd (hd V790)) (cons (cons let (cons Result (cons (hd (tl (hd (tl (hd V790))))) (cons (cons if (cons (cons = (cons Result (cons (cons fail ()) ()))) (cons (cons thaw (cons Freeze ())) (cons Result ())))) ())))) (cons (cons thaw (cons Freeze ())) ())))) ())))) ())) ())) ((and (cons? V790) (and (cons? (hd V790)) (and (cons? (tl (hd V790))) (= () (tl (tl (hd V790))))))) (cons (hd V790) (shen.encode-choices (tl V790) V791))) (true (shen.sys-error shen.encode-choices))))
|
162
|
+
|
163
|
+
(defun shen.case-form (V796 V797) (cond ((= () V796) (cons V797 ())) ((and (cons? V796) (and (cons? (hd V796)) (and (cons? (hd (hd V796))) (and (= : (hd (hd (hd V796)))) (and (cons? (tl (hd (hd V796)))) (and (= shen.tests (hd (tl (hd (hd V796))))) (and (= () (tl (tl (hd (hd V796))))) (and (cons? (tl (hd V796))) (and (cons? (hd (tl (hd V796)))) (and (= shen.choicepoint! (hd (hd (tl (hd V796))))) (and (cons? (tl (hd (tl (hd V796))))) (and (= () (tl (tl (hd (tl (hd V796)))))) (= () (tl (tl (hd V796)))))))))))))))) (cons (cons true (tl (hd V796))) (shen.case-form (tl V796) V797))) ((and (cons? V796) (and (cons? (hd V796)) (and (cons? (hd (hd V796))) (and (= : (hd (hd (hd V796)))) (and (cons? (tl (hd (hd V796)))) (and (= shen.tests (hd (tl (hd (hd V796))))) (and (= () (tl (tl (hd (hd V796))))) (and (cons? (tl (hd V796))) (= () (tl (tl (hd V796)))))))))))) (cons (cons true (tl (hd V796))) ())) ((and (cons? V796) (and (cons? (hd V796)) (and (cons? (hd (hd V796))) (and (= : (hd (hd (hd V796)))) (and (cons? (tl (hd (hd V796)))) (and (= shen.tests (hd (tl (hd (hd V796))))) (and (cons? (tl (hd V796))) (= () (tl (tl (hd V796))))))))))) (cons (cons (shen.embed-and (tl (tl (hd (hd V796))))) (tl (hd V796))) (shen.case-form (tl V796) V797))) (true (shen.sys-error shen.case-form))))
|
164
|
+
|
165
|
+
(defun shen.embed-and (V798) (cond ((and (cons? V798) (= () (tl V798))) (hd V798)) ((cons? V798) (cons and (cons (hd V798) (cons (shen.embed-and (tl V798)) ())))) (true (shen.sys-error shen.embed-and))))
|
166
|
+
|
167
|
+
(defun shen.err-condition (V799) (cons true (cons (cons shen.f_error (cons V799 ())) ())))
|
168
|
+
|
169
|
+
(defun shen.sys-error (V800) (simple-error (cn "system function " (shen.app V800 ": unexpected argument
|
170
|
+
" shen.a))))
|
171
|
+
|
1
172
|
|
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
173
|
|