shen-ruby 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/HISTORY.md +10 -0
- data/README.md +19 -17
- data/lib/kl/primitives/streams.rb +7 -17
- data/lib/shen_ruby/version.rb +1 -1
- data/shen/README.txt +1 -1
- data/shen/release/k_lambda/core.kl +56 -56
- data/shen/release/k_lambda/declarations.kl +8 -8
- data/shen/release/k_lambda/load.kl +15 -15
- data/shen/release/k_lambda/macros.kl +30 -28
- data/shen/release/k_lambda/prolog.kl +97 -97
- data/shen/release/k_lambda/reader.kl +91 -69
- data/shen/release/k_lambda/sequent.kl +53 -53
- data/shen/release/k_lambda/sys.kl +92 -108
- data/shen/release/k_lambda/t-star.kl +50 -55
- data/shen/release/k_lambda/toplevel.kl +23 -23
- data/shen/release/k_lambda/types.kl +2 -2
- data/shen/release/k_lambda/writer.kl +28 -22
- data/shen/release/test_programs/interpreter.shen +4 -6
- data/shen/release/test_programs/proof_assistant.shen +3 -3
- data/shen/release/test_programs/whist.shen +2 -2
- data/shen-ruby.gemspec +2 -2
- metadata +9 -13
@@ -47,38 +47,38 @@
|
|
47
47
|
* explains this license in full. *
|
48
48
|
* *
|
49
49
|
*****************************************************************************************
|
50
|
-
"(defun load (
|
50
|
+
"(defun load (V827) (let Load (let Start (get-time run) (let Result (shen.load-help (value shen.*tc*) (read-file V827)) (let Finish (get-time run) (let Time (- Finish Start) (let Message (shen.prhush (cn "
|
51
51
|
run time: " (cn (str Time) " secs
|
52
52
|
")) (stoutput)) Result))))) (let Infs (if (value shen.*tc*) (shen.prhush (cn "
|
53
53
|
typechecked in " (shen.app (inferences) " inferences
|
54
54
|
" shen.a)) (stoutput)) shen.skip) loaded)))
|
55
55
|
|
56
|
-
(defun shen.load-help (
|
57
|
-
" shen.s) (stoutput)))
|
56
|
+
(defun shen.load-help (V832 V833) (cond ((= false V832) (map (lambda X (shen.prhush (shen.app (shen.eval-without-macros X) "
|
57
|
+
" shen.s) (stoutput))) V833)) (true (let RemoveSynonyms (mapcan shen.remove-synonyms V833) (let Table (mapcan shen.typetable RemoveSynonyms) (let Assume (map shen.assumetype Table) (trap-error (map shen.typecheck-and-load RemoveSynonyms) (lambda E (shen.unwind-types E Table)))))))))
|
58
58
|
|
59
|
-
(defun shen.remove-synonyms (
|
59
|
+
(defun shen.remove-synonyms (V834) (cond ((and (cons? V834) (= shen.synonyms-help (hd V834))) (do (eval V834) ())) (true (cons V834 ()))))
|
60
60
|
|
61
|
-
(defun shen.typecheck-and-load (
|
61
|
+
(defun shen.typecheck-and-load (V835) (do (nl 1) (shen.typecheck-and-evaluate V835 (gensym A))))
|
62
62
|
|
63
|
-
(defun shen.typetable (
|
64
|
-
" shen.a)) (cons (cons (hd (tl
|
63
|
+
(defun shen.typetable (V844) (cond ((and (cons? V844) (and (= define (hd V844)) (cons? (tl V844)))) (let Sig (compile shen.<sig+rest> (tl (tl V844)) ()) (if (= Sig (fail)) (simple-error (shen.app (hd (tl V844)) " lacks a proper signature.
|
64
|
+
" shen.a)) (cons (cons (hd (tl V844)) Sig) ())))) ((and (cons? V844) (and (= defcc (hd V844)) (and (cons? (tl V844)) (and (cons? (tl (tl V844))) (and (= { (hd (tl (tl V844)))) (and (cons? (tl (tl (tl V844)))) (and (cons? (hd (tl (tl (tl V844))))) (and (= list (hd (hd (tl (tl (tl V844)))))) (and (cons? (tl (hd (tl (tl (tl V844)))))) (and (= () (tl (tl (hd (tl (tl (tl V844))))))) (and (cons? (tl (tl (tl (tl V844))))) (and (= ==> (hd (tl (tl (tl (tl V844)))))) (and (cons? (tl (tl (tl (tl (tl V844)))))) (and (cons? (tl (tl (tl (tl (tl (tl V844))))))) (= } (hd (tl (tl (tl (tl (tl (tl V844)))))))))))))))))))))) (cons (cons (hd (tl V844)) (cons (hd (tl (tl (tl V844)))) (cons ==> (cons (hd (tl (tl (tl (tl (tl V844)))))) ())))) ())) ((and (cons? V844) (and (= defcc (hd V844)) (cons? (tl V844)))) (simple-error (shen.app (hd (tl V844)) " lacks a proper signature.
|
65
65
|
" shen.a))) (true ())))
|
66
66
|
|
67
|
-
(defun shen.assumetype (
|
67
|
+
(defun shen.assumetype (V845) (cond ((cons? V845) (declare (hd V845) (tl V845))) (true (shen.sys-error shen.assumetype))))
|
68
68
|
|
69
|
-
(defun shen.unwind-types (
|
69
|
+
(defun shen.unwind-types (V850 V851) (cond ((= () V851) (simple-error (error-to-string V850))) ((and (cons? V851) (cons? (hd V851))) (do (shen.remtype (hd (hd V851))) (shen.unwind-types V850 (tl V851)))) (true (shen.sys-error shen.unwind-types))))
|
70
70
|
|
71
|
-
(defun shen.remtype (
|
71
|
+
(defun shen.remtype (V852) (set shen.*signedfuncs* (shen.removetype V852 (value shen.*signedfuncs*))))
|
72
72
|
|
73
|
-
(defun shen.removetype (
|
73
|
+
(defun shen.removetype (V857 V858) (cond ((= () V858) ()) ((and (cons? V858) (and (cons? (hd V858)) (= (hd (hd V858)) V857))) (shen.removetype (hd (hd V858)) (tl V858))) ((cons? V858) (cons (hd V858) (shen.removetype V857 (tl V858)))) (true (shen.sys-error shen.removetype))))
|
74
74
|
|
75
|
-
(defun shen.<sig+rest> (
|
75
|
+
(defun shen.<sig+rest> (V864) (let Result (let Parse_shen.<signature> (shen.<signature> V864) (if (not (= (fail) Parse_shen.<signature>)) (let Parse_<!> (<!> Parse_shen.<signature>) (if (not (= (fail) Parse_<!>)) (shen.pair (hd Parse_<!>) (shen.hdtl Parse_shen.<signature>)) (fail))) (fail))) (if (= Result (fail)) (fail) Result)))
|
76
76
|
|
77
|
-
(defun write-to-file (
|
77
|
+
(defun write-to-file (V865 V866) (let Stream (open file V865 out) (let String (if (string? V866) (shen.app V866 "
|
78
78
|
|
79
|
-
" shen.a) (shen.app
|
79
|
+
" shen.a) (shen.app V866 "
|
80
80
|
|
81
|
-
" shen.s)) (let Write (pr String Stream) (let Close (close Stream)
|
81
|
+
" shen.s)) (let Write (pr String Stream) (let Close (close Stream) V866)))))
|
82
82
|
|
83
83
|
|
84
84
|
|
@@ -47,29 +47,31 @@
|
|
47
47
|
* explains this license in full. *
|
48
48
|
* *
|
49
49
|
*****************************************************************************************
|
50
|
-
"(defun macroexpand (
|
50
|
+
"(defun macroexpand (V868) (let Y (shen.compose (value *macros*) V868) (if (= V868 Y) V868 (shen.walk (lambda V867 (macroexpand V867)) Y))))
|
51
51
|
|
52
|
-
(set *macros* (cons shen.timer-macro (cons shen.cases-macro (cons shen.abs-macro (cons shen.put/get-macro (cons shen.compile-macro (cons shen.datatype-macro (cons shen.let-macro (cons shen.assoc-macro (cons shen.make-string-macro (cons shen.output-macro (cons shen.error-macro (cons shen.prolog-macro (cons shen.synonyms-macro (cons shen.nl-macro (cons shen.@s-macro (cons shen.defprolog-macro (cons shen.function-macro ()))))))))))))))))))
|
52
|
+
(set *macros* (cons shen.timer-macro (cons shen.cases-macro (cons shen.abs-macro (cons shen.put/get-macro (cons shen.compile-macro (cons shen.datatype-macro (cons shen.let-macro (cons shen.assoc-macro (cons shen.make-string-macro (cons shen.output-macro (cons shen.input-macro (cons shen.error-macro (cons shen.prolog-macro (cons shen.synonyms-macro (cons shen.nl-macro (cons shen.@s-macro (cons shen.defprolog-macro (cons shen.function-macro ())))))))))))))))))))
|
53
53
|
|
54
|
-
(defun shen.error-macro (
|
54
|
+
(defun shen.error-macro (V869) (cond ((and (cons? V869) (and (= error (hd V869)) (cons? (tl V869)))) (cons simple-error (cons (shen.mkstr (hd (tl V869)) (tl (tl V869))) ()))) (true V869)))
|
55
55
|
|
56
|
-
(defun shen.output-macro (
|
56
|
+
(defun shen.output-macro (V870) (cond ((and (cons? V870) (and (= output (hd V870)) (cons? (tl V870)))) (cons shen.prhush (cons (shen.mkstr (hd (tl V870)) (tl (tl V870))) (cons (cons stoutput ()) ())))) ((and (cons? V870) (and (= pr (hd V870)) (and (cons? (tl V870)) (= () (tl (tl V870)))))) (cons pr (cons (hd (tl V870)) (cons (cons stoutput ()) ())))) (true V870)))
|
57
57
|
|
58
|
-
(defun shen.make-string-macro (
|
58
|
+
(defun shen.make-string-macro (V871) (cond ((and (cons? V871) (and (= make-string (hd V871)) (cons? (tl V871)))) (shen.mkstr (hd (tl V871)) (tl (tl V871)))) (true V871)))
|
59
59
|
|
60
|
-
(defun shen.
|
60
|
+
(defun shen.input-macro (V872) (cond ((and (cons? V872) (and (= lineread (hd V872)) (= () (tl V872)))) (cons lineread (cons (cons stinput ()) ()))) ((and (cons? V872) (and (= input (hd V872)) (= () (tl V872)))) (cons input (cons (cons stinput ()) ()))) ((and (cons? V872) (and (= read (hd V872)) (= () (tl V872)))) (cons read (cons (cons stinput ()) ()))) ((and (cons? V872) (and (= input+ (hd V872)) (and (cons? (tl V872)) (= () (tl (tl V872)))))) (cons input+ (cons (hd (tl V872)) (cons (cons stinput ()) ())))) ((and (cons? V872) (and (= read+ (hd V872)) (and (cons? (tl V872)) (= () (tl (tl V872)))))) (cons read+ (cons (hd (tl V872)) (cons (cons stinput ()) ())))) (true V872)))
|
61
61
|
|
62
|
-
(defun shen.
|
62
|
+
(defun shen.compose (V873 V874) (cond ((= () V873) V874) ((cons? V873) (shen.compose (tl V873) ((hd V873) V874))) (true (shen.sys-error shen.compose))))
|
63
63
|
|
64
|
-
(defun shen.
|
64
|
+
(defun shen.compile-macro (V875) (cond ((and (cons? V875) (and (= compile (hd V875)) (and (cons? (tl V875)) (and (cons? (tl (tl V875))) (= () (tl (tl (tl V875)))))))) (cons compile (cons (hd (tl V875)) (cons (hd (tl (tl V875))) (cons (cons lambda (cons E (cons (cons if (cons (cons cons? (cons E ())) (cons (cons error (cons "parse error here: ~S~%" (cons E ()))) (cons (cons error (cons "parse error~%" ())) ())))) ()))) ()))))) (true V875)))
|
65
65
|
|
66
|
-
(defun shen.
|
66
|
+
(defun shen.prolog-macro (V876) (cond ((and (cons? V876) (= prolog? (hd V876))) (cons shen.intprolog (cons (shen.prolog-form (tl V876)) ()))) (true V876)))
|
67
67
|
|
68
|
-
(defun shen.
|
68
|
+
(defun shen.defprolog-macro (V877) (cond ((and (cons? V877) (and (= defprolog (hd V877)) (cons? (tl V877)))) (compile shen.<defprolog> (tl V877) (lambda Y (shen.prolog-error (hd (tl V877)) Y)))) (true V877)))
|
69
69
|
|
70
|
-
(defun shen.
|
70
|
+
(defun shen.prolog-form (V878) (shen.cons_form (map shen.cons_form V878)))
|
71
71
|
|
72
|
-
(defun shen.intern-type (
|
72
|
+
(defun shen.datatype-macro (V879) (cond ((and (cons? V879) (and (= datatype (hd V879)) (cons? (tl V879)))) (cons shen.process-datatype (cons (shen.intern-type (hd (tl V879))) (cons (cons compile (cons (cons function (cons shen.<datatype-rules> ())) (cons (shen.rcons_form (tl (tl V879))) (cons (cons function (cons shen.datatype-error ())) ())))) ())))) (true V879)))
|
73
|
+
|
74
|
+
(defun shen.intern-type (V880) (intern (cn "type#" (str V880))))
|
73
75
|
|
74
76
|
"(defcc <defmacro>
|
75
77
|
<name> <macrorules> := [define <name> | <macrorules>];)
|
@@ -87,36 +89,36 @@
|
|
87
89
|
(defcc <macroaction>
|
88
90
|
<action> := [[walk [function macroexpand] <action>]];)"
|
89
91
|
|
90
|
-
(defun shen.@s-macro (
|
92
|
+
(defun shen.@s-macro (V881) (cond ((and (cons? V881) (and (= @s (hd V881)) (and (cons? (tl V881)) (and (cons? (tl (tl V881))) (cons? (tl (tl (tl V881)))))))) (cons @s (cons (hd (tl V881)) (cons (shen.@s-macro (cons @s (tl (tl V881)))) ())))) ((and (cons? V881) (and (= @s (hd V881)) (and (cons? (tl V881)) (and (cons? (tl (tl V881))) (and (= () (tl (tl (tl V881)))) (string? (hd (tl V881)))))))) (let E (explode (hd (tl V881))) (if (> (length E) 1) (shen.@s-macro (cons @s (append E (tl (tl V881))))) V881))) (true V881)))
|
91
93
|
|
92
|
-
(defun shen.synonyms-macro (
|
94
|
+
(defun shen.synonyms-macro (V882) (cond ((and (cons? V882) (= synonyms (hd V882))) (cons shen.synonyms-help (cons (shen.rcons_form (tl V882)) ()))) (true V882)))
|
93
95
|
|
94
|
-
(defun shen.nl-macro (
|
96
|
+
(defun shen.nl-macro (V883) (cond ((and (cons? V883) (and (= nl (hd V883)) (= () (tl V883)))) (cons nl (cons 1 ()))) (true V883)))
|
95
97
|
|
96
|
-
(defun shen.assoc-macro (
|
98
|
+
(defun shen.assoc-macro (V884) (cond ((and (cons? V884) (and (cons? (tl V884)) (and (cons? (tl (tl V884))) (and (cons? (tl (tl (tl V884)))) (element? (hd V884) (cons @p (cons @v (cons append (cons and (cons or (cons + (cons * (cons do ()))))))))))))) (cons (hd V884) (cons (hd (tl V884)) (cons (shen.assoc-macro (cons (hd V884) (tl (tl V884)))) ())))) (true V884)))
|
97
99
|
|
98
|
-
(defun shen.let-macro (
|
100
|
+
(defun shen.let-macro (V885) (cond ((and (cons? V885) (and (= let (hd V885)) (and (cons? (tl V885)) (and (cons? (tl (tl V885))) (and (cons? (tl (tl (tl V885)))) (cons? (tl (tl (tl (tl V885)))))))))) (cons let (cons (hd (tl V885)) (cons (hd (tl (tl V885))) (cons (shen.let-macro (cons let (tl (tl (tl V885))))) ()))))) (true V885)))
|
99
101
|
|
100
|
-
(defun shen.abs-macro (
|
102
|
+
(defun shen.abs-macro (V886) (cond ((and (cons? V886) (and (= /. (hd V886)) (and (cons? (tl V886)) (and (cons? (tl (tl V886))) (cons? (tl (tl (tl V886)))))))) (cons lambda (cons (hd (tl V886)) (cons (shen.abs-macro (cons /. (tl (tl V886)))) ())))) ((and (cons? V886) (and (= /. (hd V886)) (and (cons? (tl V886)) (and (cons? (tl (tl V886))) (= () (tl (tl (tl V886)))))))) (cons lambda (tl V886))) (true V886)))
|
101
103
|
|
102
|
-
(defun shen.cases-macro (
|
103
|
-
")) (true
|
104
|
+
(defun shen.cases-macro (V889) (cond ((and (cons? V889) (and (= cases (hd V889)) (and (cons? (tl V889)) (and (= true (hd (tl V889))) (cons? (tl (tl V889))))))) (hd (tl (tl V889)))) ((and (cons? V889) (and (= cases (hd V889)) (and (cons? (tl V889)) (and (cons? (tl (tl V889))) (= () (tl (tl (tl V889)))))))) (cons if (cons (hd (tl V889)) (cons (hd (tl (tl V889))) (cons (cons simple-error (cons "error: cases exhausted" ())) ()))))) ((and (cons? V889) (and (= cases (hd V889)) (and (cons? (tl V889)) (cons? (tl (tl V889)))))) (cons if (cons (hd (tl V889)) (cons (hd (tl (tl V889))) (cons (shen.cases-macro (cons cases (tl (tl (tl V889))))) ()))))) ((and (cons? V889) (and (= cases (hd V889)) (and (cons? (tl V889)) (= () (tl (tl V889)))))) (simple-error "error: odd number of case elements
|
105
|
+
")) (true V889)))
|
104
106
|
|
105
|
-
(defun shen.timer-macro (
|
107
|
+
(defun shen.timer-macro (V890) (cond ((and (cons? V890) (and (= time (hd V890)) (and (cons? (tl V890)) (= () (tl (tl V890)))))) (shen.let-macro (cons let (cons Start (cons (cons get-time (cons run ())) (cons Result (cons (hd (tl V890)) (cons Finish (cons (cons get-time (cons run ())) (cons Time (cons (cons - (cons Finish (cons Start ()))) (cons Message (cons (cons shen.prhush (cons (cons cn (cons "
|
106
108
|
run time: " (cons (cons cn (cons (cons str (cons Time ())) (cons " secs
|
107
|
-
" ()))) ()))) (cons (cons stoutput ()) ()))) (cons Result ())))))))))))))) (true
|
109
|
+
" ()))) ()))) (cons (cons stoutput ()) ()))) (cons Result ())))))))))))))) (true V890)))
|
108
110
|
|
109
|
-
(defun shen.tuple-up (
|
111
|
+
(defun shen.tuple-up (V891) (cond ((cons? V891) (cons @p (cons (hd V891) (cons (shen.tuple-up (tl V891)) ())))) (true V891)))
|
110
112
|
|
111
|
-
(defun shen.put/get-macro (
|
113
|
+
(defun shen.put/get-macro (V892) (cond ((and (cons? V892) (and (= put (hd V892)) (and (cons? (tl V892)) (and (cons? (tl (tl V892))) (and (cons? (tl (tl (tl V892)))) (= () (tl (tl (tl (tl V892)))))))))) (cons put (cons (hd (tl V892)) (cons (hd (tl (tl V892))) (cons (hd (tl (tl (tl V892)))) (cons (cons value (cons *property-vector* ())) ())))))) ((and (cons? V892) (and (= get (hd V892)) (and (cons? (tl V892)) (and (cons? (tl (tl V892))) (= () (tl (tl (tl V892)))))))) (cons get (cons (hd (tl V892)) (cons (hd (tl (tl V892))) (cons (cons value (cons *property-vector* ())) ()))))) (true V892)))
|
112
114
|
|
113
|
-
(defun shen.function-macro (
|
115
|
+
(defun shen.function-macro (V893) (cond ((and (cons? V893) (and (= function (hd V893)) (and (cons? (tl V893)) (= () (tl (tl V893)))))) (shen.function-abstraction (hd (tl V893)) (arity (hd (tl V893))))) (true V893)))
|
114
116
|
|
115
|
-
(defun shen.function-abstraction (V895
|
117
|
+
(defun shen.function-abstraction (V894 V895) (cond ((= 0 V895) (cons freeze (cons V894 ()))) ((= -1 V895) V894) (true (shen.function-abstraction-help V894 V895 ()))))
|
116
118
|
|
117
|
-
(defun shen.function-abstraction-help (V897 V898
|
119
|
+
(defun shen.function-abstraction-help (V896 V897 V898) (cond ((= 0 V897) (cons V896 V898)) (true (let X (gensym V) (cons /. (cons X (cons (shen.function-abstraction-help V896 (- V897 1) (append V898 (cons X ()))) ())))))))
|
118
120
|
|
119
|
-
(defun undefmacro (
|
121
|
+
(defun undefmacro (V899) (do (set *macros* (remove V899 (value *macros*))) V899))
|
120
122
|
|
121
123
|
|
122
124
|
|