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.
Files changed (55) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +5 -0
  3. data/Gemfile +2 -2
  4. data/HISTORY.md +12 -0
  5. data/README.md +10 -7
  6. data/Rakefile +92 -0
  7. data/bin/srrepl +2 -2
  8. data/k_lambda_spec/primitives/arithmetic_spec.rb +175 -0
  9. data/k_lambda_spec/primitives/assignments_spec.rb +44 -0
  10. data/k_lambda_spec/primitives/generic_functions_spec.rb +115 -2
  11. data/k_lambda_spec/primitives/lists_spec.rb +40 -0
  12. data/k_lambda_spec/primitives/strings_spec.rb +77 -0
  13. data/k_lambda_spec/primitives/symbols_spec.rb +24 -0
  14. data/k_lambda_spec/primitives/vectors_spec.rb +92 -0
  15. data/k_lambda_spec/support/shared_examples.rb +93 -2
  16. data/k_lambda_spec/tail_recursion_spec.rb +30 -0
  17. data/lib/kl/compiler.rb +19 -33
  18. data/lib/kl/environment.rb +1 -0
  19. data/lib/kl/primitives/assignments.rb +1 -0
  20. data/lib/kl/primitives/generic_functions.rb +7 -0
  21. data/lib/kl/primitives/lists.rb +2 -0
  22. data/lib/kl/primitives/strings.rb +13 -5
  23. data/lib/kl/primitives/symbols.rb +1 -0
  24. data/lib/kl/primitives/vectors.rb +5 -0
  25. data/lib/shen_ruby/version.rb +1 -1
  26. data/shen-ruby.gemspec +1 -1
  27. data/shen/lib/shen_ruby/shen.rb +5 -6
  28. data/shen/release/benchmarks/benchmarks.shen +0 -4
  29. data/shen/release/benchmarks/interpreter.shen +2 -2
  30. data/shen/release/benchmarks/plato.jpg +0 -0
  31. data/shen/release/k_lambda/core.kl +171 -1000
  32. data/shen/release/k_lambda/declarations.kl +90 -992
  33. data/shen/release/k_lambda/load.kl +69 -81
  34. data/shen/release/k_lambda/macros.kl +113 -478
  35. data/shen/release/k_lambda/prolog.kl +250 -1307
  36. data/shen/release/k_lambda/reader.kl +115 -996
  37. data/shen/release/k_lambda/sequent.kl +154 -554
  38. data/shen/release/k_lambda/sys.kl +246 -562
  39. data/shen/release/k_lambda/t-star.kl +114 -3643
  40. data/shen/release/k_lambda/toplevel.kl +136 -221
  41. data/shen/release/k_lambda/track.kl +101 -206
  42. data/shen/release/k_lambda/types.kl +143 -298
  43. data/shen/release/k_lambda/writer.kl +93 -106
  44. data/shen/release/k_lambda/yacc.kl +77 -252
  45. data/shen/release/test_programs/README.shen +1 -1
  46. data/shen/release/test_programs/classes-typed.shen +1 -1
  47. data/shen/release/test_programs/interpreter.shen +2 -2
  48. data/shen/release/test_programs/metaprog.shen +2 -2
  49. data/shen/release/test_programs/prolog.shen +79 -0
  50. data/shen/release/test_programs/structures-typed.shen +2 -2
  51. data/shen/release/test_programs/tests.shen +19 -80
  52. data/shen/release/test_programs/yacc.shen +11 -15
  53. metadata +14 -6
  54. data/Gemfile.lock +0 -20
  55. data/shen/release/benchmarks/br.shen +0 -13
@@ -1,108 +1,95 @@
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 print (V2173) (let String (shen.insert V2173 "~S") (let Print (pr String (stoutput)) V2173)))
51
+
52
+ (defun shen.mkstr (V2174 V2175) (cond ((string? V2174) (shen.mkstr-l (shen.proc-nl V2174) V2175)) (true (shen.mkstr-r (cons shen.proc-nl (cons V2174 ())) V2175))))
53
+
54
+ (defun shen.mkstr-l (V2176 V2177) (cond ((= () V2177) V2176) ((cons? V2177) (shen.mkstr-l (shen.insert-l (hd V2177) V2176) (tl V2177))) (true (shen.sys-error shen.mkstr-l))))
55
+
56
+ (defun shen.insert-l (V2180 V2181) (cond ((= "" V2181) "") ((and (shen.+string? V2181) (and (= "~" (pos V2181 0)) (and (shen.+string? (tlstr V2181)) (= "A" (pos (tlstr V2181) 0))))) (cons shen.app (cons V2180 (cons (tlstr (tlstr V2181)) (cons shen.a ()))))) ((and (shen.+string? V2181) (and (= "~" (pos V2181 0)) (and (shen.+string? (tlstr V2181)) (= "R" (pos (tlstr V2181) 0))))) (cons shen.app (cons V2180 (cons (tlstr (tlstr V2181)) (cons shen.r ()))))) ((and (shen.+string? V2181) (and (= "~" (pos V2181 0)) (and (shen.+string? (tlstr V2181)) (= "S" (pos (tlstr V2181) 0))))) (cons shen.app (cons V2180 (cons (tlstr (tlstr V2181)) (cons shen.s ()))))) ((shen.+string? V2181) (shen.factor-cn (cons cn (cons (pos V2181 0) (cons (shen.insert-l V2180 (tlstr V2181)) ()))))) ((and (cons? V2181) (and (= cn (hd V2181)) (and (cons? (tl V2181)) (and (cons? (tl (tl V2181))) (= () (tl (tl (tl V2181)))))))) (cons cn (cons (hd (tl V2181)) (cons (shen.insert-l V2180 (hd (tl (tl V2181)))) ())))) ((and (cons? V2181) (and (= shen.app (hd V2181)) (and (cons? (tl V2181)) (and (cons? (tl (tl V2181))) (and (cons? (tl (tl (tl V2181)))) (= () (tl (tl (tl (tl V2181)))))))))) (cons shen.app (cons (hd (tl V2181)) (cons (shen.insert-l V2180 (hd (tl (tl V2181)))) (tl (tl (tl V2181))))))) (true (shen.sys-error shen.insert-l))))
57
+
58
+ (defun shen.factor-cn (V2182) (cond ((and (cons? V2182) (and (= cn (hd V2182)) (and (cons? (tl V2182)) (and (cons? (tl (tl V2182))) (and (cons? (hd (tl (tl V2182)))) (and (= cn (hd (hd (tl (tl V2182))))) (and (cons? (tl (hd (tl (tl V2182))))) (and (cons? (tl (tl (hd (tl (tl V2182)))))) (and (= () (tl (tl (tl (hd (tl (tl V2182))))))) (and (= () (tl (tl (tl V2182)))) (and (string? (hd (tl V2182))) (string? (hd (tl (hd (tl (tl V2182))))))))))))))))) (cons cn (cons (cn (hd (tl V2182)) (hd (tl (hd (tl (tl V2182)))))) (tl (tl (hd (tl (tl V2182)))))))) (true V2182)))
59
+
60
+ (defun shen.proc-nl (V2183) (cond ((= "" V2183) "") ((and (shen.+string? V2183) (and (= "~" (pos V2183 0)) (and (shen.+string? (tlstr V2183)) (= "%" (pos (tlstr V2183) 0))))) (cn (n->string 10) (shen.proc-nl (tlstr (tlstr V2183))))) ((shen.+string? V2183) (cn (pos V2183 0) (shen.proc-nl (tlstr V2183)))) (true (shen.sys-error shen.proc-nl))))
61
+
62
+ (defun shen.mkstr-r (V2184 V2185) (cond ((= () V2185) V2184) ((cons? V2185) (shen.mkstr-r (cons shen.insert (cons (hd V2185) (cons V2184 ()))) (tl V2185))) (true (shen.sys-error shen.mkstr-r))))
63
+
64
+ (defun shen.insert (V2188 V2189) (cond ((= "" V2189) "") ((and (shen.+string? V2189) (and (= "~" (pos V2189 0)) (and (shen.+string? (tlstr V2189)) (= "A" (pos (tlstr V2189) 0))))) (shen.app V2188 (tlstr (tlstr V2189)) shen.a)) ((and (shen.+string? V2189) (and (= "~" (pos V2189 0)) (and (shen.+string? (tlstr V2189)) (= "R" (pos (tlstr V2189) 0))))) (shen.app V2188 (tlstr (tlstr V2189)) shen.r)) ((and (shen.+string? V2189) (and (= "~" (pos V2189 0)) (and (shen.+string? (tlstr V2189)) (= "S" (pos (tlstr V2189) 0))))) (shen.app V2188 (tlstr (tlstr V2189)) shen.s)) ((shen.+string? V2189) (cn (pos V2189 0) (shen.insert V2188 (tlstr V2189)))) (true (shen.sys-error shen.insert))))
65
+
66
+ (defun shen.app (V2190 V2191 V2192) (cn (shen.arg->str V2190 V2192) V2191))
67
+
68
+ (defun shen.arg->str (V2198 V2199) (cond ((= V2198 (fail)) "...") ((shen.list? V2198) (shen.list->str V2198 V2199)) ((string? V2198) (shen.str->str V2198 V2199)) ((absvector? V2198) (shen.vector->str V2198 V2199)) (true (shen.atom->str V2198))))
69
+
70
+ (defun shen.list->str (V2200 V2201) (cond ((= shen.r V2201) (@s "(" (@s (shen.iter-list V2200 shen.r (shen.maxseq)) ")"))) (true (@s "[" (@s (shen.iter-list V2200 V2201 (shen.maxseq)) "]")))))
71
+
72
+ (defun shen.maxseq () (value *maximum-print-sequence-size*))
73
+
74
+ (defun shen.iter-list (V2212 V2213 V2214) (cond ((= () V2212) "") ((= 0 V2214) "... etc") ((and (cons? V2212) (= () (tl V2212))) (shen.arg->str (hd V2212) V2213)) ((cons? V2212) (@s (shen.arg->str (hd V2212) V2213) (@s " " (shen.iter-list (tl V2212) V2213 (- V2214 1))))) (true (@s " " (@s "|" (@s " " (shen.arg->str V2212 V2213)))))))
75
+
76
+ (defun shen.str->str (V2219 V2220) (cond ((= shen.a V2220) V2219) (true (@s (n->string 34) (@s V2219 (n->string 34))))))
77
+
78
+ (defun shen.vector->str (V2221 V2222) (if (shen.print-vector? V2221) ((<-address V2221 0) V2221) (if (vector? V2221) (@s "<" (@s (shen.iter-vector V2221 1 V2222 (shen.maxseq)) ">")) (@s "<" (@s "<" (@s (shen.iter-vector V2221 0 V2222 (shen.maxseq)) ">>"))))))
79
+
80
+ (defun shen.print-vector? (V2223) (let Zero (<-address V2223 0) (if (= Zero shen.tuple) true (if (= Zero shen.pvar) true (if (not (number? Zero)) (shen.fbound? Zero) false)))))
81
+
82
+ (defun shen.fbound? (V2224) (trap-error (do (ps V2224) true) (lambda E false)))
83
+
84
+ (defun shen.tuple (V2225) (cn "(@p " (shen.app (<-address V2225 1) (cn " " (shen.app (<-address V2225 2) ")" shen.s)) shen.s)))
85
+
86
+ (defun shen.iter-vector (V2232 V2233 V2234 V2235) (cond ((= 0 V2235) "... etc") (true (let Item (trap-error (<-address V2232 V2233) (lambda E shen.out-of-bounds)) (let Next (trap-error (<-address V2232 (+ V2233 1)) (lambda E shen.out-of-bounds)) (if (= Item shen.out-of-bounds) "" (if (= Next shen.out-of-bounds) (shen.arg->str Item V2234) (@s (shen.arg->str Item V2234) (@s " " (shen.iter-vector V2232 (+ V2233 1) V2234 (- V2235 1)))))))))))
87
+
88
+ (defun shen.atom->str (V2236) (trap-error (str V2236) (lambda E (shen.funexstring))))
89
+
90
+ (defun shen.funexstring () (@s "" (@s "f" (@s "u" (@s "n" (@s "e" (@s (shen.arg->str (gensym (intern "x")) shen.a) "")))))))
91
+
92
+ (defun shen.list? (V2237) (or (empty? V2237) (cons? V2237)))
93
+
1
94
 
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 print (V1081)
19
- (do
20
- (pr (shen-ms-h (cons "~" (cons "S" ())) (@p V1081 shen-skip))
21
- (shen-stoutput 0))
22
- V1081))
23
-
24
- (defun format (V1082 V1083 V1084)
25
- (cond ((= true V1082) (intoutput V1083 (@p V1084 ())))
26
- ((= false V1082) (intmake-string V1083 (@p V1084 ())))
27
- (true (pr (shen-ms-h (explode V1083) V1084) V1082))))
28
-
29
- (defun intoutput (V1085 V1086)
30
- (pr (shen-ms-h (shen-explode-string V1085) V1086) (shen-stoutput 0)))
31
-
32
- (defun interror (V1087 V1088)
33
- (simple-error (shen-ms-h (shen-explode-string V1087) V1088)))
34
-
35
- (defun intmake-string (V1089 V1090)
36
- (shen-ms-h (shen-explode-string V1089) V1090))
37
-
38
- (defun shen-ms-h (V1093 V1094)
39
- (cond ((= () V1093) "")
40
- ((and (cons? V1093)
41
- (and (= "~" (hd V1093))
42
- (and (cons? (tl V1093)) (= "%" (hd (tl V1093))))))
43
- (cn (n->string 10) (shen-ms-h (tl (tl V1093)) V1094)))
44
- ((and (cons? V1093)
45
- (and (= "~" (hd V1093))
46
- (and (cons? (tl V1093))
47
- (and (tuple? V1094)
48
- (element? (hd (tl V1093)) (cons "A" (cons "S" (cons "R" ()))))))))
49
- (cn (shen-ob->str (hd (tl V1093)) (fst V1094))
50
- (shen-ms-h (tl (tl V1093)) (snd V1094))))
51
- ((cons? V1093) (cn (hd V1093) (shen-ms-h (tl V1093) V1094)))
52
- (true (shen-sys-error shen-ms-h))))
53
-
54
- (defun shen-ob->str (V1098 V1099)
55
- (cond ((= V1099 (fail)) "...")
56
- ((= () V1099) (if (= V1098 "R") "()" "[]"))
57
- ((= V1099 (vector 0)) "<>")
58
- ((cons? V1099)
59
- (shen-cn-all
60
- (append (if (= V1098 "R") (cons "(" ()) (cons "[" ()))
61
- (append (cons (shen-ob->str V1098 (hd V1099)) ())
62
- (append
63
- (shen-xmapcan (value *maximum-print-sequence-size*)
64
- (lambda Z (cons " " (cons (shen-ob->str V1098 Z) ()))) (tl V1099))
65
- (if (= V1098 "R") (cons ")" ()) (cons "]" ())))))))
66
- ((vector? V1099)
67
- (let L (shen-vector->list V1099 1)
68
- (let E
69
- (tlstr
70
- (shen-cn-all
71
- (shen-xmapcan (- (value *maximum-print-sequence-size*) 1)
72
- (lambda Z
73
- (cons " " (cons (shen-ob->str V1098 Z) ())))
74
- L)))
75
- (let V (cn "<" (cn E ">")) V))))
76
- ((and (not (string? V1099)) (absvector? V1099))
77
- (trap-error (shen-ob->str "A" ((<-address V1099 0) V1099))
78
- (lambda Ignore
79
- (let L (shen-vector->list V1099 0)
80
- (let E
81
- (tlstr
82
- (shen-cn-all
83
- (shen-xmapcan (- (value *maximum-print-sequence-size*) 1)
84
- (lambda Z (cons " " (cons (shen-ob->str V1098 Z) ()))) L)))
85
- (let V (cn "<" (cn E ">")) V))))))
86
- (true (if (and (= V1098 "A") (string? V1099)) V1099 (str V1099)))))
87
-
88
- (defun shen-tuple (V1101)
89
- (intmake-string "(@p ~S ~S)" (@p (fst V1101) (@p (snd V1101) ()))))
90
-
91
- (defun shen-cn-all (V1102)
92
- (cond ((= () V1102) "")
93
- ((cons? V1102) (cn (hd V1102) (shen-cn-all (tl V1102))))
94
- (true (shen-sys-error shen-cn-all))))
95
-
96
- (defun shen-xmapcan (V1115 V1116 V1117)
97
- (cond ((= () V1117) ()) ((= 0 V1115) (cons "... etc" ()))
98
- ((cons? V1117)
99
- (append (V1116 (hd V1117)) (shen-xmapcan (- V1115 1) V1116 (tl V1117))))
100
- (true (cons " |" (V1116 V1117)))))
101
-
102
- (defun shen-vector->list (V1118 V1119) (shen-vector->listh V1118 V1119 ()))
103
-
104
- (defun shen-vector->listh (V1120 V1121 V1122)
105
- (let Y (trap-error (<-address V1120 V1121) (lambda E shen-out-of-range))
106
- (if (= Y shen-out-of-range) (reverse V1122)
107
- (shen-vector->listh V1120 (+ V1121 1) (cons Y V1122)))))
108
95
 
@@ -1,280 +1,105 @@
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.yacc (V2090) (cond ((and (cons? V2090) (and (= defcc (hd V2090)) (and (cons? (tl V2090)) (and (cons? (tl (tl V2090))) (and (= { (hd (tl (tl V2090)))) (and (cons? (tl (tl (tl V2090)))) (and (cons? (tl (tl (tl (tl V2090))))) (and (= ==> (hd (tl (tl (tl (tl V2090)))))) (and (cons? (tl (tl (tl (tl (tl V2090)))))) (and (cons? (tl (tl (tl (tl (tl (tl V2090))))))) (= } (hd (tl (tl (tl (tl (tl (tl V2090)))))))))))))))))) (shen.yacc (cons defcc (cons (hd (tl V2090)) (tl (tl (tl (tl (tl (tl (tl V2090))))))))))) ((and (cons? V2090) (and (= defcc (hd V2090)) (cons? (tl V2090)))) (shen.yacc->shen (hd (tl V2090)) (tl (tl V2090)))) (true (shen.sys-error shen.yacc))))
1
51
 
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.
52
+ (defun shen.yacc->shen (V2091 V2092) (cons define (cons V2091 (shen.yacc_cases (map shen.cc_body (shen.split_cc_rules V2092 ()))))))
15
53
 
16
- For an explication of this license see http://www.lambdassociates.org/News/june11/license.htm which explains this license in full."
54
+ (defun shen.yacc_cases (V2093) (append (mapcan (lambda Case (cons Stream (cons <- (cons Case ())))) V2093) (cons _ (cons -> (cons (cons fail ()) ())))))
17
55
 
18
- (defun shen-yacc (V293)
19
- (cond
20
- ((and (cons? V293) (and (= defcc (hd V293)) (cons? (tl V293))))
21
- (shen-yacc->shen (hd (tl V293)) (tl (tl V293))
22
- (shen-extract-segvars (tl (tl V293)))))
23
- (true (shen-sys-error shen-yacc))))
56
+ (defun shen.first_n (V2098 V2099) (cond ((= 0 V2098) ()) ((= () V2099) ()) ((cons? V2099) (cons (hd V2099) (shen.first_n (- V2098 1) (tl V2099)))) (true (shen.sys-error shen.first_n))))
24
57
 
25
- (defun shen-extract-segvars (V298)
26
- (cond ((shen-segvar? V298) (cons V298 ()))
27
- ((cons? V298)
28
- (union (shen-extract-segvars (hd V298)) (shen-extract-segvars (tl V298))))
29
- (true ())))
58
+ (defun shen.split_cc_rules (V2100 V2101) (cond ((and (= () V2100) (= () V2101)) ()) ((= () V2100) (cons (shen.split_cc_rule (reverse V2101) ()) ())) ((and (cons? V2100) (= ; (hd V2100))) (cons (shen.split_cc_rule (reverse V2101) ()) (shen.split_cc_rules (tl V2100) ()))) ((cons? V2100) (shen.split_cc_rules (tl V2100) (cons (hd V2100) V2101))) (true (shen.sys-error shen.split_cc_rules))))
30
59
 
31
- (defun shen-yacc->shen (V299 V300 V301)
32
- (let Main
33
- (cons define
34
- (cons V299
35
- (shen-yacc_cases
36
- (map (lambda V302 (shen-cc_body V302)) (shen-split_cc_rules V300 ())))))
37
- (if (empty? V301) Main
38
- (cons package
39
- (cons null
40
- (cons () (cons Main (map (lambda V303 (shen-segdef V303)) V301))))))))
60
+ (defun shen.split_cc_rule (V2102 V2103) (cond ((and (cons? V2102) (and (= := (hd V2102)) (and (cons? (tl V2102)) (= () (tl (tl V2102)))))) (cons (reverse V2103) (tl V2102))) ((and (cons? V2102) (and (= := (hd V2102)) (and (cons? (tl V2102)) (and (cons? (tl (tl V2102))) (and (= where (hd (tl (tl V2102)))) (and (cons? (tl (tl (tl V2102)))) (= () (tl (tl (tl (tl V2102))))))))))) (cons (reverse V2103) (cons (cons where (cons (hd (tl (tl (tl V2102)))) (cons (hd (tl V2102)) ()))) ()))) ((= () V2102) (do (pr "warning: " (stoutput)) (do (map (lambda X (pr (shen.app X " " shen.a) (stoutput))) (reverse V2103)) (do (pr "has no semantics.
61
+ " (stoutput)) (shen.split_cc_rule (cons := (cons (shen.default_semantics (reverse V2103)) ())) V2103))))) ((cons? V2102) (shen.split_cc_rule (tl V2102) (cons (hd V2102) V2103))) (true (shen.sys-error shen.split_cc_rule))))
41
62
 
42
- (defun shen-segdef (V304)
43
- (cons define
44
- (cons V304
45
- (cons (cons @p (cons In (cons Out ())))
46
- (cons Continuation
47
- (cons ->
48
- (cons
49
- (cons let
50
- (cons Continue
51
- (cons
52
- (cons Continuation
53
- (cons (cons reverse (cons Out ()))
54
- (cons (cons @p (cons In (cons () ()))) ())))
55
- (cons
56
- (cons if
57
- (cons
58
- (cons and
59
- (cons (cons = (cons Continue (cons (cons fail ()) ())))
60
- (cons (cons cons? (cons In ())) ())))
61
- (cons
62
- (cons V304
63
- (cons
64
- (cons @p
65
- (cons (cons tl (cons In ()))
66
- (cons
67
- (cons cons (cons (cons hd (cons In ())) (cons Out ())))
68
- ())))
69
- (cons Continuation ())))
70
- (cons Continue ()))))
71
- ()))))
72
- ())))))))
63
+ (defun shen.default_semantics (V2104) (cond ((= () V2104) ()) ((and (cons? V2104) (shen.grammar_symbol? (hd V2104))) (cons append (cons (hd V2104) (cons (shen.default_semantics (tl V2104)) ())))) ((cons? V2104) (cons cons (cons (hd V2104) (cons (shen.default_semantics (tl V2104)) ())))) (true (shen.sys-error shen.default_semantics))))
73
64
 
74
- (defun shen-yacc_cases (V305)
75
- (append (mapcan (lambda Case (cons Stream (cons <- (cons Case ())))) V305)
76
- (cons _ (cons -> (cons (cons fail ()) ())))))
65
+ (defun shen.cc_body (V2105) (cond ((and (cons? V2105) (and (cons? (tl V2105)) (= () (tl (tl V2105))))) (shen.syntax (hd V2105) Stream (hd (tl V2105)))) (true (shen.sys-error shen.cc_body))))
77
66
 
78
- (defun shen-first_n (V310 V311)
79
- (cond ((= 0 V310) ()) ((= () V311) ())
80
- ((cons? V311) (cons (hd V311) (shen-first_n (- V310 1) (tl V311))))
81
- (true (shen-sys-error shen-first_n))))
67
+ (defun shen.syntax (V2106 V2107 V2108) (cond ((and (= () V2106) (and (cons? V2108) (and (= where (hd V2108)) (and (cons? (tl V2108)) (and (cons? (tl (tl V2108))) (= () (tl (tl (tl V2108))))))))) (cons if (cons (shen.semantics (hd (tl V2108))) (cons (cons shen.pair (cons (cons hd (cons V2107 ())) (cons (shen.semantics (hd (tl (tl V2108)))) ()))) (cons (cons fail ()) ()))))) ((= () V2106) (cons shen.pair (cons (cons hd (cons V2107 ())) (cons (shen.semantics V2108) ())))) ((cons? V2106) (if (shen.grammar_symbol? (hd V2106)) (shen.recursive_descent V2106 V2107 V2108) (if (variable? (hd V2106)) (shen.variable-match V2106 V2107 V2108) (if (shen.terminal? (hd V2106)) (shen.check_stream V2106 V2107 V2108) (if (shen.jump_stream? (hd V2106)) (shen.jump_stream V2106 V2107 V2108) (if (shen.list_stream? (hd V2106)) (shen.list_stream (shen.decons (hd V2106)) (tl V2106) V2107 V2108) (simple-error (shen.app (hd V2106) " is not legal syntax
68
+ " shen.a)))))))) (true (shen.sys-error shen.syntax))))
82
69
 
83
- (defun shen-split_cc_rules (V312 V313)
84
- (cond ((and (= () V312) (= () V313)) ())
85
- ((= () V312) (cons (shen-split_cc_rule (reverse V313) ()) ()))
86
- ((and (cons? V312) (= ; (hd V312)))
87
- (cons (shen-split_cc_rule (reverse V313) ())
88
- (shen-split_cc_rules (tl V312) ())))
89
- ((cons? V312) (shen-split_cc_rules (tl V312) (cons (hd V312) V313)))
90
- (true (shen-sys-error shen-split_cc_rules))))
70
+ (defun shen.list_stream? (V2117) (cond ((cons? V2117) true) (true false)))
91
71
 
92
- (defun shen-split_cc_rule (V314 V315)
93
- (cond
94
- ((and (cons? V314)
95
- (and (= := (hd V314))
96
- (and (cons? (tl V314)) (= () (tl (tl V314))))))
97
- (cons (reverse V315) (tl V314)))
98
- ((and (cons? V314) (= := (hd V314)))
99
- (cons (reverse V315) (cons (shen-cons_form (tl V314)) ())))
100
- ((= () V314)
101
- (do (intoutput "warning: " ())
102
- (do (map (lambda X (intoutput "~A " (@p X ()))) (reverse V315))
103
- (do (intoutput "has no semantics.~%" ())
104
- (shen-split_cc_rule
105
- (cons := (cons (shen-default_semantics (reverse V315)) ())) V315)))))
106
- ((cons? V314) (shen-split_cc_rule (tl V314) (cons (hd V314) V315)))
107
- (true (shen-sys-error shen-split_cc_rule))))
72
+ (defun shen.decons (V2118) (cond ((and (cons? V2118) (and (= cons (hd V2118)) (and (cons? (tl V2118)) (and (cons? (tl (tl V2118))) (= () (tl (tl (tl V2118)))))))) (cons (hd (tl V2118)) (shen.decons (hd (tl (tl V2118)))))) (true V2118)))
108
73
 
109
- (defun shen-default_semantics (V316)
110
- (cond ((= () V316) ())
111
- ((and (cons? V316) (shen-grammar_symbol? (hd V316)))
112
- (let PS (cons snd (cons (concat Parse_ (hd V316)) ()))
113
- (if (empty? (tl V316)) PS
114
- (cons append (cons PS (cons (shen-default_semantics (tl V316)) ()))))))
115
- ((cons? V316)
116
- (cons cons (cons (hd V316) (cons (shen-default_semantics (tl V316)) ()))))
117
- (true (shen-sys-error shen-default_semantics))))
74
+ (defun shen.list_stream (V2119 V2120 V2121 V2122) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V2121 ())) ())) (cons (cons cons? (cons (cons hd (cons (cons hd (cons V2121 ())) ())) ())) ()))) (let Action (cons shen.snd-or-fail (cons (shen.syntax V2119 (cons shen.pair (cons (cons hd (cons (cons hd (cons V2121 ())) ())) (cons (cons shen.hdtl (cons V2121 ())) ()))) (cons shen.leave! (cons (shen.syntax V2120 (cons shen.pair (cons (cons tl (cons (cons hd (cons V2121 ())) ())) (cons (cons shen.hdtl (cons V2121 ())) ()))) V2122) ()))) ())) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ()))))))))
118
75
 
119
- (defun shen-cc_body (V317)
120
- (cond
121
- ((and (cons? V317) (and (cons? (tl V317)) (= () (tl (tl V317)))))
122
- (shen-syntax (hd V317) Stream (hd (tl V317))))
123
- (true (shen-sys-error shen-cc_body))))
76
+ (defun shen.snd-or-fail (V2129) (cond ((and (cons? V2129) (and (cons? (tl V2129)) (= () (tl (tl V2129))))) (hd (tl V2129))) (true (fail))))
124
77
 
125
- (defun shen-syntax (V318 V319 V320)
126
- (cond
127
- ((= () V318)
128
- (cons shen-reassemble
129
- (cons (cons fst (cons V319 ())) (cons (shen-semantics V320) ()))))
130
- ((cons? V318)
131
- (if (shen-grammar_symbol? (hd V318)) (shen-recursive_descent V318 V319 V320)
132
- (if (shen-segvar? (hd V318)) (shen-segment-match V318 V319 V320)
133
- (if (shen-terminal? (hd V318)) (shen-check_stream V318 V319 V320)
134
- (if (shen-jump_stream? (hd V318)) (shen-jump_stream V318 V319 V320)
135
- (if (shen-list_stream? (hd V318))
136
- (shen-list_stream (shen-decons (hd V318)) (tl V318) V319 V320)
137
- (interror "~A is not legal syntax~%" (@p (hd V318) ()))))))))
138
- (true (shen-sys-error shen-syntax))))
78
+ (defun shen.grammar_symbol? (V2130) (and (symbol? V2130) (let Cs (explode V2130) (and (= (hd Cs) "<") (= (hd (reverse Cs)) ">")))))
139
79
 
140
- (defun shen-list_stream? (V329) (cond ((cons? V329) true) (true false)))
80
+ (defun shen.recursive_descent (V2131 V2132 V2133) (cond ((cons? V2131) (let Test (cons (hd V2131) (cons V2132 ())) (let Action (shen.syntax (tl V2131) (concat Parse_ (hd V2131)) V2133) (let Else (cons fail ()) (cons let (cons (concat Parse_ (hd V2131)) (cons Test (cons (cons if (cons (cons not (cons (cons = (cons (cons fail ()) (cons (concat Parse_ (hd V2131)) ()))) ())) (cons Action (cons Else ())))) ())))))))) (true (shen.sys-error shen.recursive_descent))))
141
81
 
142
- (defun shen-decons (V330)
143
- (cond
144
- ((and (cons? V330)
145
- (and (= cons (hd V330))
146
- (and (cons? (tl V330))
147
- (and (cons? (tl (tl V330))) (= () (tl (tl (tl V330))))))))
148
- (cons (hd (tl V330)) (shen-decons (hd (tl (tl V330))))))
149
- (true V330)))
82
+ (defun shen.variable-match (V2134 V2135 V2136) (cond ((cons? V2134) (let Test (cons cons? (cons (cons hd (cons V2135 ())) ())) (let Action (cons let (cons (concat Parse_ (hd V2134)) (cons (cons hd (cons (cons hd (cons V2135 ())) ())) (cons (shen.syntax (tl V2134) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2135 ())) ())) (cons (cons shen.hdtl (cons V2135 ())) ()))) V2136) ())))) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.sys-error shen.variable-match))))
150
83
 
151
- (defun shen-list_stream (V331 V332 V333 V334)
152
- (let Test
153
- (cons and
154
- (cons (cons cons? (cons (cons fst (cons V333 ())) ()))
155
- (cons
156
- (cons cons? (cons (cons hd (cons (cons fst (cons V333 ())) ())) ()))
157
- ())))
158
- (let Action
159
- (cons shen-snd-or-fail
160
- (cons
161
- (shen-syntax V331
162
- (cons shen-reassemble
163
- (cons (cons hd (cons (cons fst (cons V333 ())) ()))
164
- (cons (cons snd (cons V333 ())) ())))
165
- (cons shen-leave!
166
- (cons
167
- (shen-syntax V332
168
- (cons shen-reassemble
169
- (cons (cons tl (cons (cons fst (cons V333 ())) ()))
170
- (cons (cons snd (cons V333 ())) ())))
171
- V334)
172
- ())))
173
- ()))
174
- (let Else (cons fail ())
175
- (cons if (cons Test (cons Action (cons Else ()))))))))
84
+ (defun shen.terminal? (V2145) (cond ((cons? V2145) false) ((variable? V2145) false) (true true)))
176
85
 
177
- (defun shen-snd-or-fail (V341) (cond ((tuple? V341) (snd V341)) (true (fail))))
86
+ (defun shen.jump_stream? (V2150) (cond ((= V2150 _) true) (true false)))
178
87
 
179
- (defun shen-grammar_symbol? (V342)
180
- (and (symbol? V342)
181
- (let Cs (explode V342)
182
- (and (= (hd Cs) "<") (= (hd (reverse Cs)) ">")))))
88
+ (defun shen.check_stream (V2151 V2152 V2153) (cond ((cons? V2151) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V2152 ())) ())) (cons (cons = (cons (hd V2151) (cons (cons hd (cons (cons hd (cons V2152 ())) ())) ()))) ()))) (let Action (shen.syntax (tl V2151) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2152 ())) ())) (cons (cons shen.hdtl (cons V2152 ())) ()))) V2153) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.sys-error shen.check_stream))))
183
89
 
184
- (defun shen-recursive_descent (V343 V344 V345)
185
- (cond
186
- ((cons? V343)
187
- (let Test (cons (hd V343) (cons V344 ()))
188
- (let Action (shen-syntax (tl V343) (concat Parse_ (hd V343)) V345)
189
- (let Else (cons fail ())
190
- (cons let
191
- (cons (concat Parse_ (hd V343))
192
- (cons Test
193
- (cons
194
- (cons if
195
- (cons
196
- (cons not
197
- (cons
198
- (cons =
199
- (cons (cons fail ()) (cons (concat Parse_ (hd V343)) ())))
200
- ()))
201
- (cons Action (cons Else ()))))
202
- ()))))))))
203
- (true (shen-sys-error shen-recursive_descent))))
90
+ (defun shen.jump_stream (V2154 V2155 V2156) (cond ((cons? V2154) (let Test (cons cons? (cons (cons hd (cons V2155 ())) ())) (let Action (shen.syntax (tl V2154) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2155 ())) ())) (cons (cons shen.hdtl (cons V2155 ())) ()))) V2156) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.sys-error shen.jump_stream))))
204
91
 
205
- (defun shen-segvar? (V346) (and (symbol? V346) (= (hd (explode V346)) "?")))
92
+ (defun shen.semantics (V2157) (cond ((and (cons? V2157) (and (= shen.leave! (hd V2157)) (and (cons? (tl V2157)) (= () (tl (tl V2157)))))) (hd (tl V2157))) ((= () V2157) ()) ((shen.grammar_symbol? V2157) (cons shen.hdtl (cons (concat Parse_ V2157) ()))) ((variable? V2157) (concat Parse_ V2157)) ((cons? V2157) (map shen.semantics V2157)) (true V2157)))
206
93
 
207
- (defun shen-segment-match (V347 V348 V349)
208
- (cond
209
- ((cons? V347)
210
- (let Continuation
211
- (cons lambda
212
- (cons (hd V347)
213
- (cons
214
- (cons lambda
215
- (cons Restart (cons (shen-syntax (tl V347) Restart V349) ())))
216
- ())))
217
- (cons (hd V347) (cons V348 (cons Continuation ())))))
218
- (true (shen-sys-error shen-segment-match))))
94
+ (defun fail () shen.fail!)
219
95
 
220
- (defun shen-terminal? (V358)
221
- (cond ((cons? V358) false) ((= -*- V358) false) (true true)))
96
+ (defun shen.pair (V2158 V2159) (cons V2158 (cons V2159 ())))
222
97
 
223
- (defun shen-jump_stream? (V363) (cond ((= -*- V363) true) (true false)))
98
+ (defun shen.hdtl (V2160) (hd (tl V2160)))
224
99
 
225
- (defun shen-check_stream (V364 V365 V366)
226
- (cond
227
- ((cons? V364)
228
- (let Test
229
- (cons and
230
- (cons (cons cons? (cons (cons fst (cons V365 ())) ()))
231
- (cons
232
- (cons =
233
- (cons (hd V364)
234
- (cons (cons hd (cons (cons fst (cons V365 ())) ())) ())))
235
- ())))
236
- (let Action
237
- (shen-syntax (tl V364)
238
- (cons shen-reassemble
239
- (cons (cons tl (cons (cons fst (cons V365 ())) ()))
240
- (cons (cons snd (cons V365 ())) ())))
241
- V366)
242
- (let Else (cons fail ())
243
- (cons if (cons Test (cons Action (cons Else ()))))))))
244
- (true (shen-sys-error shen-check_stream))))
100
+ (defun <!> (V2167) (cond ((and (cons? V2167) (and (cons? (tl V2167)) (= () (tl (tl V2167))))) (cons () (cons (hd V2167) ()))) (true (fail))))
245
101
 
246
- (defun shen-reassemble (V368 V369)
247
- (cond ((= V369 (fail)) V369) (true (@p V368 V369))))
102
+ (defun <e> (V2172) (cond ((and (cons? V2172) (and (cons? (tl V2172)) (= () (tl (tl V2172))))) (cons (hd V2172) (cons () ()))) (true (shen.sys-error <e>))))
248
103
 
249
- (defun shen-jump_stream (V370 V371 V372)
250
- (cond
251
- ((cons? V370)
252
- (let Test (cons cons? (cons (cons fst (cons V371 ())) ()))
253
- (let Action
254
- (shen-syntax (tl V370)
255
- (cons shen-reassemble
256
- (cons (cons tl (cons (cons fst (cons V371 ())) ()))
257
- (cons (cons snd (cons V371 ())) ())))
258
- V372)
259
- (let Else (cons fail ())
260
- (cons if (cons Test (cons Action (cons Else ()))))))))
261
- (true (shen-sys-error shen-jump_stream))))
262
104
 
263
- (defun shen-semantics (V373)
264
- (cond
265
- ((and (cons? V373)
266
- (and (= shen-leave! (hd V373))
267
- (and (cons? (tl V373)) (= () (tl (tl V373))))))
268
- (hd (tl V373)))
269
- ((= () V373) ())
270
- ((shen-grammar_symbol? V373) (cons snd (cons (concat Parse_ V373) ())))
271
- ((= -o- V373) (cons snd (cons Stream ())))
272
- ((= -*- V373) (cons hd (cons (cons fst (cons Stream ())) ())))
273
- ((= -s- V373) (cons fst (cons Stream ())))
274
- ((cons? V373) (map (lambda V374 (shen-semantics V374)) V373)) (true V373)))
275
-
276
- (defun fail () shen-fail!)
277
-
278
- (defun <!> (V379)
279
- (cond ((tuple? V379) (@p () (fst V379))) (true (shen-sys-error <!>))))
280
105