shen-ruby 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +5 -0
  3. data/README.md +8 -12
  4. data/Rakefile +4 -9
  5. data/bin/shen_test_suite.rb +0 -1
  6. data/bin/srrepl +2 -4
  7. data/lib/shen_ruby/shen.rb +98 -0
  8. data/lib/shen_ruby/version.rb +1 -1
  9. data/shen-ruby.gemspec +3 -3
  10. data/shen/README.txt +9 -13
  11. data/shen/release/BSD +24 -0
  12. data/shen/release/klambda/core.kl +157 -0
  13. data/shen/release/klambda/declarations.kl +109 -0
  14. data/shen/release/klambda/load.kl +59 -0
  15. data/shen/release/klambda/macros.kl +91 -0
  16. data/shen/release/klambda/prolog.kl +228 -0
  17. data/shen/release/klambda/reader.kl +198 -0
  18. data/shen/release/klambda/sequent.kl +142 -0
  19. data/shen/release/klambda/sys.kl +253 -0
  20. data/shen/release/klambda/t-star.kl +123 -0
  21. data/shen/release/klambda/toplevel.kl +110 -0
  22. data/shen/release/klambda/track.kl +79 -0
  23. data/shen/release/{k_lambda → klambda}/types.kl +41 -63
  24. data/shen/release/klambda/writer.kl +81 -0
  25. data/shen/release/klambda/yacc.kl +87 -0
  26. data/shen/release/license.pdf +0 -0
  27. data/shen/release/test_programs/Chap13/problems.txt +26 -26
  28. data/shen/release/test_programs/README.shen +52 -52
  29. data/shen/release/test_programs/TinyLispFunctions.txt +15 -15
  30. data/shen/release/test_programs/TinyTypes.shen +55 -55
  31. data/shen/release/test_programs/binary.shen +24 -24
  32. data/shen/release/test_programs/bubble_version_1.shen +28 -28
  33. data/shen/release/test_programs/bubble_version_2.shen +22 -22
  34. data/shen/release/test_programs/calculator.shen +21 -21
  35. data/shen/release/test_programs/cartprod.shen +23 -23
  36. data/shen/release/test_programs/change.shen +25 -25
  37. data/shen/release/test_programs/classes-defaults.shen +94 -94
  38. data/shen/release/test_programs/classes-inheritance.shen +100 -100
  39. data/shen/release/test_programs/classes-typed.shen +74 -74
  40. data/shen/release/test_programs/classes-untyped.shen +46 -46
  41. data/shen/release/test_programs/depth_.shen +14 -14
  42. data/shen/release/test_programs/einstein.shen +34 -34
  43. data/shen/release/test_programs/fruit_machine.shen +46 -46
  44. data/shen/release/test_programs/interpreter.shen +217 -217
  45. data/shen/release/test_programs/metaprog.shen +85 -85
  46. data/shen/release/test_programs/minim.shen +192 -192
  47. data/shen/release/test_programs/mutual.shen +11 -11
  48. data/shen/release/test_programs/n_queens.shen +45 -45
  49. data/shen/release/test_programs/newton_version_1.shen +33 -33
  50. data/shen/release/test_programs/newton_version_2.shen +24 -24
  51. data/shen/release/test_programs/parse.prl +14 -14
  52. data/shen/release/test_programs/parser.shen +51 -51
  53. data/shen/release/test_programs/powerset.shen +10 -10
  54. data/shen/release/test_programs/prime.shen +10 -10
  55. data/shen/release/test_programs/prolog.shen +78 -78
  56. data/shen/release/test_programs/proof_assistant.shen +80 -80
  57. data/shen/release/test_programs/proplog_version_1.shen +25 -25
  58. data/shen/release/test_programs/proplog_version_2.shen +27 -27
  59. data/shen/release/test_programs/qmachine.shen +66 -66
  60. data/shen/release/test_programs/red-black.shen +54 -54
  61. data/shen/release/test_programs/search.shen +55 -55
  62. data/shen/release/test_programs/semantic_net.shen +44 -44
  63. data/shen/release/test_programs/spreadsheet.shen +34 -34
  64. data/shen/release/test_programs/stack.shen +27 -27
  65. data/shen/release/test_programs/streams.shen +20 -20
  66. data/shen/release/test_programs/strings.shen +57 -57
  67. data/shen/release/test_programs/structures-typed.shen +71 -71
  68. data/shen/release/test_programs/structures-untyped.shen +41 -41
  69. data/shen/release/test_programs/tests.shen +232 -232
  70. data/shen/release/test_programs/types.shen +11 -11
  71. data/shen/release/test_programs/whist.shen +239 -239
  72. data/shen/release/test_programs/yacc.shen +132 -132
  73. metadata +21 -35
  74. data/shen/lib/shen_ruby/shen.rb +0 -160
  75. data/shen/license.txt +0 -34
  76. data/shen/release/benchmarks/N_queens.shen +0 -45
  77. data/shen/release/benchmarks/README.shen +0 -14
  78. data/shen/release/benchmarks/benchmarks.shen +0 -52
  79. data/shen/release/benchmarks/bigprog +0 -2173
  80. data/shen/release/benchmarks/einstein.shen +0 -33
  81. data/shen/release/benchmarks/heatwave.gif +0 -0
  82. data/shen/release/benchmarks/interpreter.shen +0 -219
  83. data/shen/release/benchmarks/jnk.shen +0 -194
  84. data/shen/release/benchmarks/picture.jpg +0 -0
  85. data/shen/release/benchmarks/plato.jpg +0 -0
  86. data/shen/release/benchmarks/powerset.shen +0 -10
  87. data/shen/release/benchmarks/prime.shen +0 -10
  88. data/shen/release/benchmarks/short.shen +0 -129
  89. data/shen/release/benchmarks/text.txt +0 -68
  90. data/shen/release/k_lambda/core.kl +0 -181
  91. data/shen/release/k_lambda/declarations.kl +0 -131
  92. data/shen/release/k_lambda/load.kl +0 -84
  93. data/shen/release/k_lambda/macros.kl +0 -112
  94. data/shen/release/k_lambda/prolog.kl +0 -252
  95. data/shen/release/k_lambda/reader.kl +0 -222
  96. data/shen/release/k_lambda/sequent.kl +0 -166
  97. data/shen/release/k_lambda/sys.kl +0 -271
  98. data/shen/release/k_lambda/t-star.kl +0 -139
  99. data/shen/release/k_lambda/toplevel.kl +0 -135
  100. data/shen/release/k_lambda/track.kl +0 -103
  101. data/shen/release/k_lambda/writer.kl +0 -105
  102. data/shen/release/k_lambda/yacc.kl +0 -113
@@ -0,0 +1,81 @@
1
+ "Copyright (c) 2015, Mark Tarver
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ 3. The name of Mark Tarver may not be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
25
+
26
+ (defun pr (V2338 V2339) (trap-error (shen.prh V2338 V2339 0) (lambda E V2338)))
27
+
28
+ (defun shen.prh (V2340 V2341 V2342) (shen.prh V2340 V2341 (shen.write-char-and-inc V2340 V2341 V2342)))
29
+
30
+ (defun shen.write-char-and-inc (V2343 V2344 V2345) (do (write-byte (string->n (pos V2343 V2345)) V2344) (+ V2345 1)))
31
+
32
+ (defun print (V2346) (let String (shen.insert V2346 "~S") (let Print (shen.prhush String (stoutput)) V2346)))
33
+
34
+ (defun shen.prhush (V2347 V2348) (if (value *hush*) V2347 (pr V2347 V2348)))
35
+
36
+ (defun shen.mkstr (V2349 V2350) (cond ((string? V2349) (shen.mkstr-l (shen.proc-nl V2349) V2350)) (true (shen.mkstr-r (cons shen.proc-nl (cons V2349 ())) V2350))))
37
+
38
+ (defun shen.mkstr-l (V2351 V2352) (cond ((= () V2352) V2351) ((cons? V2352) (shen.mkstr-l (shen.insert-l (hd V2352) V2351) (tl V2352))) (true (shen.f_error shen.mkstr-l))))
39
+
40
+ (defun shen.insert-l (V2355 V2356) (cond ((= "" V2356) "") ((and (shen.+string? V2356) (and (= "~" (pos V2356 0)) (and (shen.+string? (tlstr V2356)) (= "A" (pos (tlstr V2356) 0))))) (cons shen.app (cons V2355 (cons (tlstr (tlstr V2356)) (cons shen.a ()))))) ((and (shen.+string? V2356) (and (= "~" (pos V2356 0)) (and (shen.+string? (tlstr V2356)) (= "R" (pos (tlstr V2356) 0))))) (cons shen.app (cons V2355 (cons (tlstr (tlstr V2356)) (cons shen.r ()))))) ((and (shen.+string? V2356) (and (= "~" (pos V2356 0)) (and (shen.+string? (tlstr V2356)) (= "S" (pos (tlstr V2356) 0))))) (cons shen.app (cons V2355 (cons (tlstr (tlstr V2356)) (cons shen.s ()))))) ((shen.+string? V2356) (shen.factor-cn (cons cn (cons (pos V2356 0) (cons (shen.insert-l V2355 (tlstr V2356)) ()))))) ((and (cons? V2356) (and (= cn (hd V2356)) (and (cons? (tl V2356)) (and (cons? (tl (tl V2356))) (= () (tl (tl (tl V2356)))))))) (cons cn (cons (hd (tl V2356)) (cons (shen.insert-l V2355 (hd (tl (tl V2356)))) ())))) ((and (cons? V2356) (and (= shen.app (hd V2356)) (and (cons? (tl V2356)) (and (cons? (tl (tl V2356))) (and (cons? (tl (tl (tl V2356)))) (= () (tl (tl (tl (tl V2356)))))))))) (cons shen.app (cons (hd (tl V2356)) (cons (shen.insert-l V2355 (hd (tl (tl V2356)))) (tl (tl (tl V2356))))))) (true (shen.f_error shen.insert-l))))
41
+
42
+ (defun shen.factor-cn (V2357) (cond ((and (cons? V2357) (and (= cn (hd V2357)) (and (cons? (tl V2357)) (and (cons? (tl (tl V2357))) (and (cons? (hd (tl (tl V2357)))) (and (= cn (hd (hd (tl (tl V2357))))) (and (cons? (tl (hd (tl (tl V2357))))) (and (cons? (tl (tl (hd (tl (tl V2357)))))) (and (= () (tl (tl (tl (hd (tl (tl V2357))))))) (and (= () (tl (tl (tl V2357)))) (and (string? (hd (tl V2357))) (string? (hd (tl (hd (tl (tl V2357))))))))))))))))) (cons cn (cons (cn (hd (tl V2357)) (hd (tl (hd (tl (tl V2357)))))) (tl (tl (hd (tl (tl V2357)))))))) (true V2357)))
43
+
44
+ (defun shen.proc-nl (V2358) (cond ((= "" V2358) "") ((and (shen.+string? V2358) (and (= "~" (pos V2358 0)) (and (shen.+string? (tlstr V2358)) (= "%" (pos (tlstr V2358) 0))))) (cn (n->string 10) (shen.proc-nl (tlstr (tlstr V2358))))) ((shen.+string? V2358) (cn (pos V2358 0) (shen.proc-nl (tlstr V2358)))) (true (shen.f_error shen.proc-nl))))
45
+
46
+ (defun shen.mkstr-r (V2359 V2360) (cond ((= () V2360) V2359) ((cons? V2360) (shen.mkstr-r (cons shen.insert (cons (hd V2360) (cons V2359 ()))) (tl V2360))) (true (shen.f_error shen.mkstr-r))))
47
+
48
+ (defun shen.insert (V2361 V2362) (shen.insert-h V2361 V2362 ""))
49
+
50
+ (defun shen.insert-h (V2365 V2366 V2367) (cond ((= "" V2366) V2367) ((and (shen.+string? V2366) (and (= "~" (pos V2366 0)) (and (shen.+string? (tlstr V2366)) (= "A" (pos (tlstr V2366) 0))))) (cn V2367 (shen.app V2365 (tlstr (tlstr V2366)) shen.a))) ((and (shen.+string? V2366) (and (= "~" (pos V2366 0)) (and (shen.+string? (tlstr V2366)) (= "R" (pos (tlstr V2366) 0))))) (cn V2367 (shen.app V2365 (tlstr (tlstr V2366)) shen.r))) ((and (shen.+string? V2366) (and (= "~" (pos V2366 0)) (and (shen.+string? (tlstr V2366)) (= "S" (pos (tlstr V2366) 0))))) (cn V2367 (shen.app V2365 (tlstr (tlstr V2366)) shen.s))) ((shen.+string? V2366) (shen.insert-h V2365 (tlstr V2366) (cn V2367 (pos V2366 0)))) (true (shen.f_error shen.insert-h))))
51
+
52
+ (defun shen.app (V2368 V2369 V2370) (cn (shen.arg->str V2368 V2370) V2369))
53
+
54
+ (defun shen.arg->str (V2376 V2377) (cond ((= V2376 (fail)) "...") ((shen.list? V2376) (shen.list->str V2376 V2377)) ((string? V2376) (shen.str->str V2376 V2377)) ((absvector? V2376) (shen.vector->str V2376 V2377)) (true (shen.atom->str V2376))))
55
+
56
+ (defun shen.list->str (V2378 V2379) (cond ((= shen.r V2379) (@s "(" (@s (shen.iter-list V2378 shen.r (shen.maxseq)) ")"))) (true (@s "[" (@s (shen.iter-list V2378 V2379 (shen.maxseq)) "]")))))
57
+
58
+ (defun shen.maxseq () (value *maximum-print-sequence-size*))
59
+
60
+ (defun shen.iter-list (V2390 V2391 V2392) (cond ((= () V2390) "") ((= 0 V2392) "... etc") ((and (cons? V2390) (= () (tl V2390))) (shen.arg->str (hd V2390) V2391)) ((cons? V2390) (@s (shen.arg->str (hd V2390) V2391) (@s " " (shen.iter-list (tl V2390) V2391 (- V2392 1))))) (true (@s "|" (@s " " (shen.arg->str V2390 V2391))))))
61
+
62
+ (defun shen.str->str (V2397 V2398) (cond ((= shen.a V2398) V2397) (true (@s (n->string 34) (@s V2397 (n->string 34))))))
63
+
64
+ (defun shen.vector->str (V2399 V2400) (if (shen.print-vector? V2399) ((<-address V2399 0) V2399) (if (vector? V2399) (@s "<" (@s (shen.iter-vector V2399 1 V2400 (shen.maxseq)) ">")) (@s "<" (@s "<" (@s (shen.iter-vector V2399 0 V2400 (shen.maxseq)) ">>"))))))
65
+
66
+ (defun shen.print-vector? (V2401) (let Zero (<-address V2401 0) (if (= Zero shen.tuple) true (if (= Zero shen.pvar) true (if (not (number? Zero)) (shen.fbound? Zero) false)))))
67
+
68
+ (defun shen.fbound? (V2402) (trap-error (do (ps V2402) true) (lambda E false)))
69
+
70
+ (defun shen.tuple (V2403) (cn "(@p " (shen.app (<-address V2403 1) (cn " " (shen.app (<-address V2403 2) ")" shen.s)) shen.s)))
71
+
72
+ (defun shen.iter-vector (V2410 V2411 V2412 V2413) (cond ((= 0 V2413) "... etc") (true (let Item (trap-error (<-address V2410 V2411) (lambda E shen.out-of-bounds)) (let Next (trap-error (<-address V2410 (+ V2411 1)) (lambda E shen.out-of-bounds)) (if (= Item shen.out-of-bounds) "" (if (= Next shen.out-of-bounds) (shen.arg->str Item V2412) (@s (shen.arg->str Item V2412) (@s " " (shen.iter-vector V2410 (+ V2411 1) V2412 (- V2413 1)))))))))))
73
+
74
+ (defun shen.atom->str (V2414) (trap-error (str V2414) (lambda E (shen.funexstring))))
75
+
76
+ (defun shen.funexstring () (@s "" (@s "f" (@s "u" (@s "n" (@s "e" (@s (shen.arg->str (gensym (intern "x")) shen.a) "")))))))
77
+
78
+ (defun shen.list? (V2415) (or (empty? V2415) (cons? V2415)))
79
+
80
+
81
+
@@ -0,0 +1,87 @@
1
+ "Copyright (c) 2015, Mark Tarver
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ 3. The name of Mark Tarver may not be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY
16
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
25
+
26
+ (defun shen.yacc (V2416) (cond ((and (cons? V2416) (and (= defcc (hd V2416)) (cons? (tl V2416)))) (shen.yacc->shen (hd (tl V2416)) (tl (tl V2416)))) (true (shen.f_error shen.yacc))))
27
+
28
+ (defun shen.yacc->shen (V2417 V2418) (let CCRules (shen.split_cc_rules true V2418 ()) (let CCBody (map shen.cc_body CCRules) (let YaccCases (shen.yacc_cases CCBody) (cons define (cons V2417 (cons Stream (cons -> (cons (shen.kill-code YaccCases) ())))))))))
29
+
30
+ (defun shen.kill-code (V2419) (cond ((> (occurrences kill V2419) 0) (cons trap-error (cons V2419 (cons (cons lambda (cons E (cons (cons shen.analyse-kill (cons E ())) ()))) ())))) (true V2419)))
31
+
32
+ (defun kill () (simple-error "yacc kill"))
33
+
34
+ (defun shen.analyse-kill (V2420) (let String (error-to-string V2420) (if (= String "yacc kill") (fail) V2420)))
35
+
36
+ (defun shen.split_cc_rules (V2423 V2424 V2425) (cond ((and (= () V2424) (= () V2425)) ()) ((= () V2424) (cons (shen.split_cc_rule V2423 (reverse V2425) ()) ())) ((and (cons? V2424) (= ; (hd V2424))) (cons (shen.split_cc_rule V2423 (reverse V2425) ()) (shen.split_cc_rules V2423 (tl V2424) ()))) ((cons? V2424) (shen.split_cc_rules V2423 (tl V2424) (cons (hd V2424) V2425))) (true (shen.f_error shen.split_cc_rules))))
37
+
38
+ (defun shen.split_cc_rule (V2430 V2431 V2432) (cond ((and (cons? V2431) (and (= := (hd V2431)) (and (cons? (tl V2431)) (= () (tl (tl V2431)))))) (cons (reverse V2432) (tl V2431))) ((and (cons? V2431) (and (= := (hd V2431)) (and (cons? (tl V2431)) (and (cons? (tl (tl V2431))) (and (= where (hd (tl (tl V2431)))) (and (cons? (tl (tl (tl V2431)))) (= () (tl (tl (tl (tl V2431))))))))))) (cons (reverse V2432) (cons (cons where (cons (hd (tl (tl (tl V2431)))) (cons (hd (tl V2431)) ()))) ()))) ((= () V2431) (do (shen.semantic-completion-warning V2430 V2432) (shen.split_cc_rule V2430 (cons := (cons (shen.default_semantics (reverse V2432)) ())) V2432))) ((cons? V2431) (shen.split_cc_rule V2430 (tl V2431) (cons (hd V2431) V2432))) (true (shen.f_error shen.split_cc_rule))))
39
+
40
+ (defun shen.semantic-completion-warning (V2441 V2442) (cond ((= true V2441) (do (shen.prhush "warning: " (stoutput)) (do (map (lambda X (shen.prhush (shen.app X " " shen.a) (stoutput))) (reverse V2442)) (shen.prhush "has no semantics.
41
+ " (stoutput))))) (true shen.skip)))
42
+
43
+ (defun shen.default_semantics (V2443) (cond ((= () V2443) ()) ((and (cons? V2443) (and (= () (tl V2443)) (shen.grammar_symbol? (hd V2443)))) (hd V2443)) ((and (cons? V2443) (shen.grammar_symbol? (hd V2443))) (cons append (cons (hd V2443) (cons (shen.default_semantics (tl V2443)) ())))) ((cons? V2443) (cons cons (cons (hd V2443) (cons (shen.default_semantics (tl V2443)) ())))) (true (shen.f_error shen.default_semantics))))
44
+
45
+ (defun shen.grammar_symbol? (V2444) (and (symbol? V2444) (let Cs (shen.strip-pathname (explode V2444)) (and (= (hd Cs) "<") (= (hd (reverse Cs)) ">")))))
46
+
47
+ (defun shen.yacc_cases (V2445) (cond ((and (cons? V2445) (= () (tl V2445))) (hd V2445)) ((cons? V2445) (let P YaccParse (cons let (cons P (cons (hd V2445) (cons (cons if (cons (cons = (cons P (cons (cons fail ()) ()))) (cons (shen.yacc_cases (tl V2445)) (cons P ())))) ())))))) (true (shen.f_error shen.yacc_cases))))
48
+
49
+ (defun shen.cc_body (V2446) (cond ((and (cons? V2446) (and (cons? (tl V2446)) (= () (tl (tl V2446))))) (shen.syntax (hd V2446) Stream (hd (tl V2446)))) (true (shen.f_error shen.cc_body))))
50
+
51
+ (defun shen.syntax (V2447 V2448 V2449) (cond ((and (= () V2447) (and (cons? V2449) (and (= where (hd V2449)) (and (cons? (tl V2449)) (and (cons? (tl (tl V2449))) (= () (tl (tl (tl V2449))))))))) (cons if (cons (shen.semantics (hd (tl V2449))) (cons (cons shen.pair (cons (cons hd (cons V2448 ())) (cons (shen.semantics (hd (tl (tl V2449)))) ()))) (cons (cons fail ()) ()))))) ((= () V2447) (cons shen.pair (cons (cons hd (cons V2448 ())) (cons (shen.semantics V2449) ())))) ((cons? V2447) (if (shen.grammar_symbol? (hd V2447)) (shen.recursive_descent V2447 V2448 V2449) (if (variable? (hd V2447)) (shen.variable-match V2447 V2448 V2449) (if (shen.jump_stream? (hd V2447)) (shen.jump_stream V2447 V2448 V2449) (if (shen.terminal? (hd V2447)) (shen.check_stream V2447 V2448 V2449) (if (cons? (hd V2447)) (shen.list-stream (shen.decons (hd V2447)) (tl V2447) V2448 V2449) (simple-error (shen.app (hd V2447) " is not legal syntax
52
+ " shen.a)))))))) (true (shen.f_error shen.syntax))))
53
+
54
+ (defun shen.list-stream (V2450 V2451 V2452 V2453) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V2452 ())) ())) (cons (cons cons? (cons (cons hd (cons (cons hd (cons V2452 ())) ())) ())) ()))) (let Placeholder (gensym shen.place) (let RunOn (shen.syntax V2451 (cons shen.pair (cons (cons tl (cons (cons hd (cons V2452 ())) ())) (cons (cons hd (cons (cons tl (cons V2452 ())) ())) ()))) V2453) (let Action (shen.insert-runon RunOn Placeholder (shen.syntax V2450 (cons shen.pair (cons (cons hd (cons (cons hd (cons V2452 ())) ())) (cons (cons hd (cons (cons tl (cons V2452 ())) ())) ()))) Placeholder)) (cons if (cons Test (cons Action (cons (cons fail ()) ())))))))))
55
+
56
+ (defun shen.decons (V2454) (cond ((and (cons? V2454) (and (= cons (hd V2454)) (and (cons? (tl V2454)) (and (cons? (tl (tl V2454))) (and (= () (hd (tl (tl V2454)))) (= () (tl (tl (tl V2454))))))))) (cons (hd (tl V2454)) ())) ((and (cons? V2454) (and (= cons (hd V2454)) (and (cons? (tl V2454)) (and (cons? (tl (tl V2454))) (= () (tl (tl (tl V2454)))))))) (cons (hd (tl V2454)) (shen.decons (hd (tl (tl V2454)))))) (true V2454)))
57
+
58
+ (defun shen.insert-runon (V2466 V2467 V2468) (cond ((and (cons? V2468) (and (= shen.pair (hd V2468)) (and (cons? (tl V2468)) (and (cons? (tl (tl V2468))) (and (= () (tl (tl (tl V2468)))) (= (hd (tl (tl V2468))) V2467)))))) V2466) ((cons? V2468) (map (lambda Z (shen.insert-runon V2466 V2467 Z)) V2468)) (true V2468)))
59
+
60
+ (defun shen.strip-pathname (V2473) (cond ((not (element? "." V2473)) V2473) ((cons? V2473) (shen.strip-pathname (tl V2473))) (true (shen.f_error shen.strip-pathname))))
61
+
62
+ (defun shen.recursive_descent (V2474 V2475 V2476) (cond ((cons? V2474) (let Test (cons (hd V2474) (cons V2475 ())) (let Action (shen.syntax (tl V2474) (concat Parse_ (hd V2474)) V2476) (let Else (cons fail ()) (cons let (cons (concat Parse_ (hd V2474)) (cons Test (cons (cons if (cons (cons not (cons (cons = (cons (cons fail ()) (cons (concat Parse_ (hd V2474)) ()))) ())) (cons Action (cons Else ())))) ())))))))) (true (shen.f_error shen.recursive_descent))))
63
+
64
+ (defun shen.variable-match (V2477 V2478 V2479) (cond ((cons? V2477) (let Test (cons cons? (cons (cons hd (cons V2478 ())) ())) (let Action (cons let (cons (concat Parse_ (hd V2477)) (cons (cons hd (cons (cons hd (cons V2478 ())) ())) (cons (shen.syntax (tl V2477) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2478 ())) ())) (cons (cons shen.hdtl (cons V2478 ())) ()))) V2479) ())))) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.f_error shen.variable-match))))
65
+
66
+ (defun shen.terminal? (V2488) (cond ((cons? V2488) false) ((variable? V2488) false) (true true)))
67
+
68
+ (defun shen.jump_stream? (V2493) (cond ((= V2493 _) true) (true false)))
69
+
70
+ (defun shen.check_stream (V2494 V2495 V2496) (cond ((cons? V2494) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V2495 ())) ())) (cons (cons = (cons (hd V2494) (cons (cons hd (cons (cons hd (cons V2495 ())) ())) ()))) ()))) (let Action (shen.syntax (tl V2494) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2495 ())) ())) (cons (cons shen.hdtl (cons V2495 ())) ()))) V2496) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.f_error shen.check_stream))))
71
+
72
+ (defun shen.jump_stream (V2497 V2498 V2499) (cond ((cons? V2497) (let Test (cons cons? (cons (cons hd (cons V2498 ())) ())) (let Action (shen.syntax (tl V2497) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2498 ())) ())) (cons (cons shen.hdtl (cons V2498 ())) ()))) V2499) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.f_error shen.jump_stream))))
73
+
74
+ (defun shen.semantics (V2500) (cond ((= () V2500) ()) ((shen.grammar_symbol? V2500) (cons shen.hdtl (cons (concat Parse_ V2500) ()))) ((variable? V2500) (concat Parse_ V2500)) ((cons? V2500) (map shen.semantics V2500)) (true V2500)))
75
+
76
+ (defun shen.snd-or-fail (V2507) (cond ((and (cons? V2507) (and (cons? (tl V2507)) (= () (tl (tl V2507))))) (hd (tl V2507))) (true (fail))))
77
+
78
+ (defun fail () shen.fail!)(defun shen.pair (V2508 V2509) (cons V2508 (cons V2509 ())))
79
+
80
+ (defun shen.hdtl (V2510) (hd (tl V2510)))
81
+
82
+ (defun shen.<!> (V2517) (cond ((and (cons? V2517) (and (cons? (tl V2517)) (= () (tl (tl V2517))))) (cons () (cons (hd V2517) ()))) (true (fail))))
83
+
84
+ (defun <e> (V2522) (cond ((and (cons? V2522) (and (cons? (tl V2522)) (= () (tl (tl V2522))))) (cons (hd V2522) (cons () ()))) (true (shen.f_error <e>))))
85
+
86
+
87
+
Binary file
@@ -1,26 +1,26 @@
1
-
2
- [[[y-combinator [/. ADD [/. X [/. Y [if [= X 0] Y [[ADD [-- X]] [++ Y]]]]]]] 2] 3]
3
-
4
-
5
- [[[y-combinator [/. ADD [/. X [/. Y [if [= X 0] Y [[ADD [-- X]] [++ Y]]]]]]] 33] 4]
6
-
7
- [[[/. [@p X Y] X]
8
- [y-combinator [/. T
9
- [@p [/. A [cases [[/. 1 false] A]
10
- [[/. X [[[/. [@p X Y] Y] T] [-- X]]] A]]]
11
- [/. A [cases [[/. 1 true] A]
12
- [[/. X [[[/. [@p X Y] X] T] [-- X]]] A]]]]]]] 6]
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
1
+
2
+ [[[y-combinator [/. ADD [/. X [/. Y [if [= X 0] Y [[ADD [-- X]] [++ Y]]]]]]] 2] 3]
3
+
4
+
5
+ [[[y-combinator [/. ADD [/. X [/. Y [if [= X 0] Y [[ADD [-- X]] [++ Y]]]]]]] 33] 4]
6
+
7
+ [[[/. [@p X Y] X]
8
+ [y-combinator [/. T
9
+ [@p [/. A [cases [[/. 1 false] A]
10
+ [[/. X [[[/. [@p X Y] Y] T] [-- X]]] A]]]
11
+ [/. A [cases [[/. 1 true] A]
12
+ [[/. X [[[/. [@p X Y] X] T] [-- X]]] A]]]]]]] 6]
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
@@ -1,53 +1,53 @@
1
- \*
2
-
3
- This is the test harness for Shen. Assuming your port to Blub is in the directory Platforms/Blub; do the
4
- following.
5
-
6
- (cd "../../Test Programs")
7
- (load "README.shen")
8
- (load "tests.shen")
9
-
10
- *\
11
-
12
- (package test-harness [report reset ok passed failed]
13
-
14
- (define reset
15
- -> (set *passed* (set *failed* 0)))
16
-
17
- (defmacro exec-macro
18
- [exec Name Expr Prediction] -> [trap-error [let (protect Output) [output "~%~A: ~R = ~S" Name (rcons Expr) Prediction]
19
- (protect Result) [time Expr]
20
- [if [= (protect Result) Prediction] [passed] [failed (protect Result)]]]
21
- [/. (protect E) [err (protect E)]]])
22
-
23
- (define rcons
24
- [X | Y] -> [cons (rcons X) (rcons Y)]
25
- X -> X)
26
-
27
- (define passed
28
- -> (do (trap-error (set *passed* (+ 1 (value *passed*))) (/. E (set *passed* 1)))
29
- (print passed)))
30
-
31
- (define failed
32
- Result -> (let Fail+ (trap-error (set *failed* (+ 1 (value *failed*))) (/. E (set *failed* 1)))
33
- ShowResult (output "~S returned~%" Result)
34
- (if (y-or-n? "failed; continue?") ok (error "kill"))))
35
-
36
- (define err
37
- E -> (error "") where (= (error-to-string E) "kill")
38
- E -> (do (trap-error (set *failed* (+ 1 (value *failed*))) (/. E (set *failed* 1)))
39
- (output "~%failed with error ~A~%" (error-to-string E))))
40
-
41
- (defmacro report-results-macro
42
- [report Name | Tests] -> (let NewTests (create-tests Name Tests)
43
- [do | NewTests]))
44
-
45
- (define create-tests
46
- Name [] -> [[results] ok]
47
- Name [Test Prediction | Tests] -> [[exec Name Test Prediction] | (create-tests Name Tests)])
48
-
49
- (define results
50
- -> (let Passed (trap-error (value *passed*) (/. E 0))
51
- Failed (trap-error (value *failed*) (/. E 0))
52
- Percent (* (/ Passed (+ Passed Failed)) 100)
1
+ \* Standard Test Suite 1.0
2
+
3
+ This is the test harness for Shen. Assuming your port to Blub is in the directory Platforms/Blub; do the
4
+ following.
5
+
6
+ (cd "../../Test Programs")
7
+ (load "README.shen")
8
+ (load "tests.shen")
9
+
10
+ *\
11
+
12
+ (package test-harness [report reset ok passed failed]
13
+
14
+ (define reset
15
+ -> (set *passed* (set *failed* 0)))
16
+
17
+ (defmacro exec-macro
18
+ [exec Name Expr Prediction] -> [trap-error [let (protect Output) [output "~%~A: ~R = ~S" Name (rcons Expr) Prediction]
19
+ (protect Result) [time Expr]
20
+ [if [= (protect Result) Prediction] [passed] [failed (protect Result)]]]
21
+ [/. (protect E) [err (protect E)]]])
22
+
23
+ (define rcons
24
+ [X | Y] -> [cons (rcons X) (rcons Y)]
25
+ X -> X)
26
+
27
+ (define passed
28
+ -> (do (trap-error (set *passed* (+ 1 (value *passed*))) (/. E (set *passed* 1)))
29
+ (print passed)))
30
+
31
+ (define failed
32
+ Result -> (let Fail+ (trap-error (set *failed* (+ 1 (value *failed*))) (/. E (set *failed* 1)))
33
+ ShowResult (output "~S returned~%" Result)
34
+ (if (y-or-n? "failed; continue?") ok (error "kill"))))
35
+
36
+ (define err
37
+ E -> (error "") where (= (error-to-string E) "kill")
38
+ E -> (do (trap-error (set *failed* (+ 1 (value *failed*))) (/. E (set *failed* 1)))
39
+ (output "~%failed with error ~A~%" (error-to-string E))))
40
+
41
+ (defmacro report-results-macro
42
+ [report Name | Tests] -> (let NewTests (create-tests Name Tests)
43
+ [do | NewTests]))
44
+
45
+ (define create-tests
46
+ Name [] -> [[results] ok]
47
+ Name [Test Prediction | Tests] -> [[exec Name Test Prediction] | (create-tests Name Tests)])
48
+
49
+ (define results
50
+ -> (let Passed (trap-error (value *passed*) (/. E 0))
51
+ Failed (trap-error (value *failed*) (/. E 0))
52
+ Percent (* (/ Passed (+ Passed Failed)) 100)
53
53
  (output "~%passed ... ~A~%failed ...~A~%pass rate ...~A%~%~%" Passed Failed Percent))) )
@@ -1,16 +1,16 @@
1
- (defun plus (x y)
2
- (lispif (equal x 0)
3
- y
4
- (plus (prec x) (succ y))))
5
-
6
- (defun member (x y)
7
- (lispif (equal y (empty!))
8
- (empty!)
9
- (lispif (equal x (car y))
10
- y
11
- (member x (cdr y)))))
12
-
13
- (defun join (x y)
14
- (lispif (equal x (empty!))
15
- y
1
+ (defun plus (x y)
2
+ (lispif (equal x 0)
3
+ y
4
+ (plus (prec x) (succ y))))
5
+
6
+ (defun member (x y)
7
+ (lispif (equal y (empty!))
8
+ (empty!)
9
+ (lispif (equal x (car y))
10
+ y
11
+ (member x (cdr y)))))
12
+
13
+ (defun join (x y)
14
+ (lispif (equal x (empty!))
15
+ y
16
16
  (lispcons (car x) (join (cdr x) y))))
@@ -1,55 +1,55 @@
1
- (specialise defun)
2
- (specialise lambda')
3
-
4
- (datatype tiny_lisp_type_theory
5
-
6
- let Lambda (mk_lambda Xs Body)
7
- F : A >> Lambda : A;
8
- __________________
9
- (defun F Xs Body) : A;
10
-
11
- let X* (gensym &&x)
12
- let Y* (subst X* X Y)
13
- X* : A >> Y* : B;
14
- _____________________
15
- (lambda' (X) Y) : (A --> B);
16
-
17
- F : (A --> B); X : A;
18
- ________________
19
- (F X) : B;
20
-
21
- ____________________________
22
- lispif : (bool --> (A --> (A --> A)));
23
-
24
- ________________________
25
- equal : (A --> (A --> bool));
26
-
27
- ___________________________
28
- lispcons : (A --> ((list A) --> (list A)));
29
-
30
- ______________
31
- car : ((list A) --> A);
32
-
33
- _______________
34
- cdr : ((list A) --> (list A));
35
-
36
- if (element? F [succ prec])
37
- ____________________
38
- F : (number --> number);
39
-
40
- ___________
41
- (tee!) : bool;
42
-
43
- ____________
44
- (empty!) : (list A);
45
-
46
- ________
47
- (empty!) : bool;
48
-
49
- if (symbol? X)
50
- ____________
51
- (quote X) : symbol;)
52
-
53
- (define mk_lambda
54
- [X] Body -> [lambda' [X] Body]
55
- [X | Y] Body -> [lambda' [X] (mk_lambda Y Body)])
1
+ (specialise defun)
2
+ (specialise lambda')
3
+
4
+ (datatype tiny_lisp_type_theory
5
+
6
+ let Lambda (mk_lambda Xs Body)
7
+ F : A >> Lambda : A;
8
+ __________________
9
+ (defun F Xs Body) : A;
10
+
11
+ let X* (gensym &&x)
12
+ let Y* (subst X* X Y)
13
+ X* : A >> Y* : B;
14
+ _____________________
15
+ (lambda' (X) Y) : (A --> B);
16
+
17
+ F : (A --> B); X : A;
18
+ ________________
19
+ (F X) : B;
20
+
21
+ ____________________________
22
+ lispif : (bool --> (A --> (A --> A)));
23
+
24
+ ________________________
25
+ equal : (A --> (A --> bool));
26
+
27
+ ___________________________
28
+ lispcons : (A --> ((list A) --> (list A)));
29
+
30
+ ______________
31
+ car : ((list A) --> A);
32
+
33
+ _______________
34
+ cdr : ((list A) --> (list A));
35
+
36
+ if (element? F [succ prec])
37
+ ____________________
38
+ F : (number --> number);
39
+
40
+ ___________
41
+ (tee!) : bool;
42
+
43
+ ____________
44
+ (empty!) : (list A);
45
+
46
+ ________
47
+ (empty!) : bool;
48
+
49
+ if (symbol? X)
50
+ ____________
51
+ (quote X) : symbol;)
52
+
53
+ (define mk_lambda
54
+ [X] Body -> [lambda' [X] Body]
55
+ [X | Y] Body -> [lambda' [X] (mk_lambda Y Body)])