shen-ruby 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +5 -0
- data/README.md +10 -10
- data/lib/kl/absvector.rb +1 -1
- data/lib/shen_ruby/version.rb +1 -1
- data/shen-ruby.gemspec +1 -1
- data/shen/release/k_lambda/core.kl +3 -3
- data/shen/release/k_lambda/reader.kl +63 -62
- data/shen/release/k_lambda/sequent.kl +51 -51
- data/shen/release/k_lambda/sys.kl +102 -102
- data/shen/release/k_lambda/t-star.kl +53 -57
- data/shen/release/k_lambda/toplevel.kl +23 -23
- data/shen/release/k_lambda/track.kl +25 -25
- data/shen/release/k_lambda/types.kl +6 -6
- data/shen/release/k_lambda/writer.kl +20 -20
- data/shen/release/k_lambda/yacc.kl +26 -26
- metadata +3 -3
@@ -51,9 +51,9 @@
|
|
51
51
|
|
52
52
|
(defun shen.loop () (do (shen.initialise_environment) (do (shen.prompt) (do (trap-error (shen.read-evaluate-print) (lambda E (pr (error-to-string E) (stoutput)))) (shen.loop)))))
|
53
53
|
|
54
|
-
(defun version (
|
54
|
+
(defun version (V2244) (set *version* V2244))
|
55
55
|
|
56
|
-
(version "version 9")
|
56
|
+
(version "version 9.1")
|
57
57
|
|
58
58
|
(defun shen.credits () (do (pr "
|
59
59
|
Shen 2010, copyright (C) 2010 Mark Tarver
|
@@ -64,27 +64,27 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
|
|
64
64
|
|
65
65
|
(defun shen.initialise_environment () (shen.multiple-set (cons shen.*call* (cons 0 (cons shen.*infs* (cons 0 (cons shen.*process-counter* (cons 0 (cons shen.*catch* (cons 0 ()))))))))))
|
66
66
|
|
67
|
-
(defun shen.multiple-set (
|
67
|
+
(defun shen.multiple-set (V2245) (cond ((= () V2245) ()) ((and (cons? V2245) (cons? (tl V2245))) (do (set (hd V2245) (hd (tl V2245))) (shen.multiple-set (tl (tl V2245))))) (true (shen.sys-error shen.multiple-set))))
|
68
68
|
|
69
|
-
(defun destroy (
|
69
|
+
(defun destroy (V2246) (declare V2246 ()))
|
70
70
|
|
71
71
|
(set shen.*history* ())
|
72
72
|
|
73
73
|
(defun shen.read-evaluate-print () (let Lineread (shen.toplineread) (let History (value shen.*history*) (let NewLineread (shen.retrieve-from-history-if-needed Lineread History) (let NewHistory (shen.update_history NewLineread History) (let Parsed (fst NewLineread) (shen.toplevel Parsed)))))))
|
74
74
|
|
75
|
-
(defun shen.retrieve-from-history-if-needed (
|
75
|
+
(defun shen.retrieve-from-history-if-needed (V2256 V2257) (cond ((and (tuple? V2256) (and (cons? (snd V2256)) (and (cons? (tl (snd V2256))) (and (= () (tl (tl (snd V2256)))) (and (cons? V2257) (and (= (hd (snd V2256)) (shen.exclamation)) (= (hd (tl (snd V2256))) (shen.exclamation)))))))) (let PastPrint (shen.prbytes (snd (hd V2257))) (hd V2257))) ((and (tuple? V2256) (and (cons? (snd V2256)) (= (hd (snd V2256)) (shen.exclamation)))) (let Key? (shen.make-key (tl (snd V2256)) V2257) (let Find (head (shen.find-past-inputs Key? V2257)) (let PastPrint (shen.prbytes (snd Find)) Find)))) ((and (tuple? V2256) (and (cons? (snd V2256)) (and (= () (tl (snd V2256))) (= (hd (snd V2256)) (shen.percent))))) (do (shen.print-past-inputs (lambda X true) (reverse V2257) 0) (abort))) ((and (tuple? V2256) (and (cons? (snd V2256)) (= (hd (snd V2256)) (shen.percent)))) (let Key? (shen.make-key (tl (snd V2256)) V2257) (let Pastprint (shen.print-past-inputs Key? (reverse V2257) 0) (abort)))) (true V2256)))
|
76
76
|
|
77
77
|
(defun shen.percent () 37)
|
78
78
|
|
79
79
|
(defun shen.exclamation () 33)
|
80
80
|
|
81
|
-
(defun shen.prbytes (
|
81
|
+
(defun shen.prbytes (V2258) (do (map (lambda Byte (pr (n->string Byte) (stoutput))) V2258) (nl 1)))
|
82
82
|
|
83
|
-
(defun shen.update_history (
|
83
|
+
(defun shen.update_history (V2259 V2260) (set shen.*history* (cons V2259 V2260)))
|
84
84
|
|
85
85
|
(defun shen.toplineread () (shen.toplineread_loop (read-byte (stinput)) ()))
|
86
86
|
|
87
|
-
(defun shen.toplineread_loop (
|
87
|
+
(defun shen.toplineread_loop (V2262 V2263) (cond ((= V2262 (shen.hat)) (simple-error "line read aborted")) ((element? V2262 (cons (shen.newline) (cons (shen.carriage-return) ()))) (let Line (compile shen.<st_input> V2263 (lambda E shen.nextline)) (if (or (= Line shen.nextline) (empty? Line)) (shen.toplineread_loop (read-byte (stinput)) (append V2263 (cons V2262 ()))) (@p Line V2263)))) (true (shen.toplineread_loop (read-byte (stinput)) (append V2263 (cons V2262 ()))))))
|
88
88
|
|
89
89
|
(defun shen.hat () 94)
|
90
90
|
|
@@ -92,7 +92,7 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
|
|
92
92
|
|
93
93
|
(defun shen.carriage-return () 13)
|
94
94
|
|
95
|
-
(defun tc (
|
95
|
+
(defun tc (V2268) (cond ((= + V2268) (set shen.*tc* true)) ((= - V2268) (set shen.*tc* false)) (true (simple-error "tc expects a + or -"))))
|
96
96
|
|
97
97
|
(defun shen.prompt () (if (value shen.*tc*) (pr (cn "
|
98
98
|
|
@@ -100,16 +100,16 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
|
|
100
100
|
|
101
101
|
(" (shen.app (length (value shen.*history*)) "-) " shen.a)) (stoutput))))
|
102
102
|
|
103
|
-
(defun shen.toplevel (
|
103
|
+
(defun shen.toplevel (V2269) (shen.toplevel_evaluate V2269 (value shen.*tc*)))
|
104
104
|
|
105
|
-
(defun shen.find-past-inputs (
|
105
|
+
(defun shen.find-past-inputs (V2270 V2271) (let F (shen.find V2270 V2271) (if (empty? F) (simple-error "input not found
|
106
106
|
") F)))
|
107
107
|
|
108
|
-
(defun shen.make-key (
|
108
|
+
(defun shen.make-key (V2272 V2273) (let Atom (hd (compile shen.<st_input> V2272 (lambda E (if (cons? E) (simple-error (cn "parse error here: " (shen.app E "
|
109
109
|
" shen.s))) (simple-error "parse error
|
110
|
-
"))))) (if (integer? Atom) (lambda X (= X (nth (+ Atom 1) (reverse
|
110
|
+
"))))) (if (integer? Atom) (lambda X (= X (nth (+ Atom 1) (reverse V2273)))) (lambda X (shen.prefix? V2272 (shen.trim-gubbins (snd X)))))))
|
111
111
|
|
112
|
-
(defun shen.trim-gubbins (
|
112
|
+
(defun shen.trim-gubbins (V2274) (cond ((and (cons? V2274) (= (hd V2274) (shen.space))) (shen.trim-gubbins (tl V2274))) ((and (cons? V2274) (= (hd V2274) (shen.newline))) (shen.trim-gubbins (tl V2274))) ((and (cons? V2274) (= (hd V2274) (shen.carriage-return))) (shen.trim-gubbins (tl V2274))) ((and (cons? V2274) (= (hd V2274) (shen.tab))) (shen.trim-gubbins (tl V2274))) ((and (cons? V2274) (= (hd V2274) (shen.left-round))) (shen.trim-gubbins (tl V2274))) (true V2274)))
|
113
113
|
|
114
114
|
(defun shen.space () 32)
|
115
115
|
|
@@ -117,22 +117,22 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
|
|
117
117
|
|
118
118
|
(defun shen.left-round () 40)
|
119
119
|
|
120
|
-
(defun shen.find (
|
120
|
+
(defun shen.find (V2281 V2282) (cond ((= () V2282) ()) ((and (cons? V2282) (V2281 (hd V2282))) (cons (hd V2282) (shen.find V2281 (tl V2282)))) ((cons? V2282) (shen.find V2281 (tl V2282))) (true (shen.sys-error shen.find))))
|
121
121
|
|
122
|
-
(defun shen.prefix? (
|
122
|
+
(defun shen.prefix? (V2293 V2294) (cond ((= () V2293) true) ((and (cons? V2293) (and (cons? V2294) (= (hd V2294) (hd V2293)))) (shen.prefix? (tl V2293) (tl V2294))) (true false)))
|
123
123
|
|
124
|
-
(defun shen.print-past-inputs (
|
124
|
+
(defun shen.print-past-inputs (V2304 V2305 V2306) (cond ((= () V2305) _) ((and (cons? V2305) (not (V2304 (hd V2305)))) (shen.print-past-inputs V2304 (tl V2305) (+ V2306 1))) ((and (cons? V2305) (tuple? (hd V2305))) (do (pr (shen.app V2306 ". " shen.a) (stoutput)) (do (shen.prbytes (snd (hd V2305))) (shen.print-past-inputs V2304 (tl V2305) (+ V2306 1))))) (true (shen.sys-error shen.print-past-inputs))))
|
125
125
|
|
126
|
-
(defun shen.toplevel_evaluate (
|
126
|
+
(defun shen.toplevel_evaluate (V2307 V2308) (cond ((and (cons? V2307) (and (cons? (tl V2307)) (and (= : (hd (tl V2307))) (and (cons? (tl (tl V2307))) (and (= () (tl (tl (tl V2307)))) (= true V2308)))))) (shen.typecheck-and-evaluate (hd V2307) (hd (tl (tl V2307))))) ((and (cons? V2307) (cons? (tl V2307))) (do (shen.toplevel_evaluate (cons (hd V2307) ()) V2308) (do (nl 1) (shen.toplevel_evaluate (tl V2307) V2308)))) ((and (cons? V2307) (and (= () (tl V2307)) (= true V2308))) (shen.typecheck-and-evaluate (hd V2307) (gensym A))) ((and (cons? V2307) (and (= () (tl V2307)) (= false V2308))) (let Eval (shen.eval-without-macros (hd V2307)) (print Eval))) (true (shen.sys-error shen.toplevel_evaluate))))
|
127
127
|
|
128
|
-
(defun shen.typecheck-and-evaluate (
|
129
|
-
") (let Eval (shen.eval-without-macros
|
128
|
+
(defun shen.typecheck-and-evaluate (V2309 V2310) (let Typecheck (shen.typecheck V2309 V2310) (if (= Typecheck false) (simple-error "type error
|
129
|
+
") (let Eval (shen.eval-without-macros V2309) (let Type (shen.pretty-type Typecheck) (pr (shen.app Eval (cn " : " (shen.app Type "" shen.r)) shen.s) (stoutput)))))))
|
130
130
|
|
131
|
-
(defun shen.pretty-type (
|
131
|
+
(defun shen.pretty-type (V2311) (shen.mult_subst (value shen.*alphabet*) (shen.extract-pvars V2311) V2311))
|
132
132
|
|
133
|
-
(defun shen.extract-pvars (
|
133
|
+
(defun shen.extract-pvars (V2316) (cond ((shen.pvar? V2316) (cons V2316 ())) ((cons? V2316) (union (shen.extract-pvars (hd V2316)) (shen.extract-pvars (tl V2316)))) (true ())))
|
134
134
|
|
135
|
-
(defun shen.mult_subst (
|
135
|
+
(defun shen.mult_subst (V2321 V2322 V2323) (cond ((= () V2321) V2323) ((= () V2322) V2323) ((and (cons? V2321) (cons? V2322)) (shen.mult_subst (tl V2321) (tl V2322) (subst (hd V2321) (hd V2322) V2323))) (true (shen.sys-error shen.mult_subst))))
|
136
136
|
|
137
137
|
|
138
138
|
|
@@ -47,57 +47,57 @@
|
|
47
47
|
* explains this license in full. *
|
48
48
|
* *
|
49
49
|
*****************************************************************************************
|
50
|
-
"(defun shen.f_error (
|
51
|
-
" shen.a)) (stoutput)) (do (if (and (not (shen.tracked?
|
50
|
+
"(defun shen.f_error (V2032) (do (pr (cn "partial function " (shen.app V2032 ";
|
51
|
+
" shen.a)) (stoutput)) (do (if (and (not (shen.tracked? V2032)) (y-or-n? (cn "track " (shen.app V2032 "? " shen.a)))) (shen.track-function (ps V2032)) shen.ok) (simple-error "aborted"))))
|
52
52
|
|
53
|
-
(defun shen.tracked? (
|
53
|
+
(defun shen.tracked? (V2033) (element? V2033 (value shen.*tracking*)))
|
54
54
|
|
55
|
-
(defun track (
|
55
|
+
(defun track (V2034) (let Source (ps V2034) (shen.track-function Source)))
|
56
56
|
|
57
|
-
(defun shen.track-function (
|
57
|
+
(defun shen.track-function (V2035) (cond ((and (cons? V2035) (and (= defun (hd V2035)) (and (cons? (tl V2035)) (and (cons? (tl (tl V2035))) (and (cons? (tl (tl (tl V2035)))) (= () (tl (tl (tl (tl V2035)))))))))) (let KL (cons defun (cons (hd (tl V2035)) (cons (hd (tl (tl V2035))) (cons (shen.insert-tracking-code (hd (tl V2035)) (hd (tl (tl V2035))) (hd (tl (tl (tl V2035))))) ())))) (let Ob (eval KL) (let Tr (set shen.*tracking* (cons Ob (value shen.*tracking*))) Ob)))) (true (shen.sys-error shen.track-function))))
|
58
58
|
|
59
|
-
(defun shen.insert-tracking-code (
|
59
|
+
(defun shen.insert-tracking-code (V2036 V2037 V2038) (cons do (cons (cons set (cons shen.*call* (cons (cons + (cons (cons value (cons shen.*call* ())) (cons 1 ()))) ()))) (cons (cons do (cons (cons shen.input-track (cons (cons value (cons shen.*call* ())) (cons V2036 (cons (shen.cons_form V2037) ())))) (cons (cons do (cons (cons shen.terpri-or-read-char ()) (cons (cons let (cons Result (cons V2038 (cons (cons do (cons (cons shen.output-track (cons (cons value (cons shen.*call* ())) (cons V2036 (cons Result ())))) (cons (cons do (cons (cons set (cons shen.*call* (cons (cons - (cons (cons value (cons shen.*call* ())) (cons 1 ()))) ()))) (cons (cons do (cons (cons shen.terpri-or-read-char ()) (cons Result ()))) ()))) ()))) ())))) ()))) ()))) ()))))
|
60
60
|
|
61
61
|
(set shen.*step* false)
|
62
62
|
|
63
|
-
(defun step (
|
63
|
+
(defun step (V2043) (cond ((= + V2043) (set shen.*step* true)) ((= - V2043) (set shen.*step* false)) (true (simple-error "step expects a + or a -.
|
64
64
|
"))))
|
65
65
|
|
66
|
-
(defun spy (
|
66
|
+
(defun spy (V2048) (cond ((= + V2048) (set shen.*spy* true)) ((= - V2048) (set shen.*spy* false)) (true (simple-error "spy expects a + or a -.
|
67
67
|
"))))
|
68
68
|
|
69
69
|
(defun shen.terpri-or-read-char () (if (value shen.*step*) (shen.check-byte (read-byte (value *stinput*))) (nl 1)))
|
70
70
|
|
71
|
-
(defun shen.check-byte (
|
71
|
+
(defun shen.check-byte (V2053) (cond ((= V2053 (shen.hat)) (simple-error "aborted")) (true true)))
|
72
72
|
|
73
|
-
(defun shen.input-track (
|
74
|
-
" (shen.app (shen.spaces
|
75
|
-
" (shen.app (shen.spaces
|
73
|
+
(defun shen.input-track (V2054 V2055 V2056) (do (pr (cn "
|
74
|
+
" (shen.app (shen.spaces V2054) (cn "<" (shen.app V2054 (cn "> Inputs to " (shen.app V2055 (cn "
|
75
|
+
" (shen.app (shen.spaces V2054) "" shen.a)) shen.a)) shen.a)) shen.a)) (stoutput)) (shen.recursively-print V2056)))
|
76
76
|
|
77
|
-
(defun shen.recursively-print (
|
77
|
+
(defun shen.recursively-print (V2057) (cond ((= () V2057) (pr " ==>" (stoutput))) ((cons? V2057) (do (print (hd V2057)) (do (pr ", " (stoutput)) (shen.recursively-print (tl V2057))))) (true (shen.sys-error shen.recursively-print))))
|
78
78
|
|
79
|
-
(defun shen.spaces (
|
79
|
+
(defun shen.spaces (V2058) (cond ((= 0 V2058) "") (true (cn " " (shen.spaces (- V2058 1))))))
|
80
80
|
|
81
|
-
(defun shen.output-track (
|
82
|
-
" (shen.app (shen.spaces
|
83
|
-
" (shen.app (shen.spaces
|
81
|
+
(defun shen.output-track (V2059 V2060 V2061) (pr (cn "
|
82
|
+
" (shen.app (shen.spaces V2059) (cn "<" (shen.app V2059 (cn "> Output from " (shen.app V2060 (cn "
|
83
|
+
" (shen.app (shen.spaces V2059) (cn "==> " (shen.app V2061 "" shen.s)) shen.a)) shen.a)) shen.a)) shen.a)) (stoutput)))
|
84
84
|
|
85
|
-
(defun untrack (
|
85
|
+
(defun untrack (V2062) (eval (ps V2062)))
|
86
86
|
|
87
|
-
(defun profile (
|
87
|
+
(defun profile (V2063) (shen.profile-help (ps V2063)))
|
88
88
|
|
89
|
-
(defun shen.profile-help (
|
89
|
+
(defun shen.profile-help (V2068) (cond ((and (cons? V2068) (and (= defun (hd V2068)) (and (cons? (tl V2068)) (and (cons? (tl (tl V2068))) (and (cons? (tl (tl (tl V2068)))) (= () (tl (tl (tl (tl V2068)))))))))) (let G (gensym shen.f) (let Profile (cons defun (cons (hd (tl V2068)) (cons (hd (tl (tl V2068))) (cons (shen.profile-func (hd (tl V2068)) (hd (tl (tl V2068))) (cons G (hd (tl (tl V2068))))) ())))) (let Def (cons defun (cons G (cons (hd (tl (tl V2068))) (cons (subst G (hd (tl V2068)) (hd (tl (tl (tl V2068))))) ())))) (let CompileProfile (shen.eval-without-macros Profile) (let CompileG (shen.eval-without-macros Def) (hd (tl V2068)))))))) (true (simple-error "Cannot profile.
|
90
90
|
"))))
|
91
91
|
|
92
|
-
(defun unprofile (
|
92
|
+
(defun unprofile (V2069) (untrack V2069))
|
93
93
|
|
94
|
-
(defun shen.profile-func (
|
94
|
+
(defun shen.profile-func (V2070 V2071 V2072) (cons let (cons Start (cons (cons get-time (cons run ())) (cons (cons let (cons Result (cons V2072 (cons (cons let (cons Finish (cons (cons - (cons (cons get-time (cons run ())) (cons Start ()))) (cons (cons let (cons Record (cons (cons shen.put-profile (cons V2070 (cons (cons + (cons (cons shen.get-profile (cons V2070 ())) (cons Finish ()))) ()))) (cons Result ())))) ())))) ())))) ())))))
|
95
95
|
|
96
|
-
(defun profile-results (
|
96
|
+
(defun profile-results (V2073) (let Results (shen.get-profile V2073) (let Initialise (shen.put-profile V2073 0) (@p V2073 Results))))
|
97
97
|
|
98
|
-
(defun shen.get-profile (
|
98
|
+
(defun shen.get-profile (V2074) (trap-error (get V2074 profile (value *property-vector*)) (lambda E 0)))
|
99
99
|
|
100
|
-
(defun shen.put-profile (
|
100
|
+
(defun shen.put-profile (V2075 V2076) (put V2075 profile V2076 (value *property-vector*)))
|
101
101
|
|
102
102
|
|
103
103
|
|
@@ -47,18 +47,18 @@
|
|
47
47
|
* explains this license in full. *
|
48
48
|
* *
|
49
49
|
*****************************************************************************************
|
50
|
-
"(defun declare (
|
50
|
+
"(defun declare (V2077 V2078) (let Record (set shen.*signedfuncs* (adjoin V2077 (value shen.*signedfuncs*))) (let Variancy (trap-error (shen.variancy-test V2077 V2078) (lambda E shen.skip)) (let Type (shen.rcons_form (shen.demodulate V2078)) (let F* (concat shen.type-signature-of- V2077) (let Parameters (shen.parameters 1) (let Clause (cons (cons F* (cons X ())) (cons :- (cons (cons (cons unify! (cons X (cons Type ()))) ()) ()))) (let AUM_instruction (shen.aum Clause Parameters) (let Code (shen.aum_to_shen AUM_instruction) (let ShenDef (cons define (cons F* (append Parameters (append (cons ProcessN (cons Continuation ())) (cons -> (cons Code ())))))) (let Eval (shen.eval-without-macros ShenDef) V2077)))))))))))
|
51
51
|
|
52
|
-
(defun shen.
|
52
|
+
(defun shen.demodulate (V2079) (fix shen.demodh V2079))
|
53
53
|
|
54
|
-
(defun shen.
|
54
|
+
(defun shen.demodh (V2080) (cond ((cons? V2080) (map shen.demodh V2080)) (true (shen.demod-atom V2080))))
|
55
55
|
|
56
|
-
(defun shen.
|
56
|
+
(defun shen.demod-atom (V2081) (let Val (assoc V2081 (value shen.*synonyms*)) (if (empty? Val) V2081 (tl Val))))
|
57
57
|
|
58
|
-
(defun shen.variancy-test (
|
58
|
+
(defun shen.variancy-test (V2082 V2083) (let TypeF (shen.typecheck V2082 B) (let Check (if (= symbol TypeF) shen.skip (if (shen.variant? TypeF V2083) shen.skip (pr (cn "warning: changing the type of " (shen.app V2082 " may create errors
|
59
59
|
" shen.a)) (stoutput)))) shen.skip)))
|
60
60
|
|
61
|
-
(defun shen.variant? (
|
61
|
+
(defun shen.variant? (V2092 V2093) (cond ((= V2093 V2092) true) ((and (cons? V2092) (and (cons? V2093) (= (hd V2093) (hd V2092)))) (shen.variant? (tl V2092) (tl V2093))) ((and (cons? V2092) (and (cons? V2093) (and (shen.pvar? (hd V2092)) (variable? (hd V2093))))) (shen.variant? (subst shen.a (hd V2092) (tl V2092)) (subst shen.a (hd V2093) (tl V2093)))) ((and (cons? V2092) (and (cons? (hd V2092)) (and (cons? V2093) (cons? (hd V2093))))) (shen.variant? (append (hd V2092) (tl V2092)) (append (hd V2093) (tl V2093)))) (true false)))
|
62
62
|
|
63
63
|
(declare absvector? (cons A (cons --> (cons boolean ()))))
|
64
64
|
|
@@ -47,49 +47,49 @@
|
|
47
47
|
* explains this license in full. *
|
48
48
|
* *
|
49
49
|
*****************************************************************************************
|
50
|
-
"(defun print (
|
50
|
+
"(defun print (V2179) (let String (shen.insert V2179 "~S") (let Print (pr String (stoutput)) V2179)))
|
51
51
|
|
52
|
-
(defun shen.mkstr (
|
52
|
+
(defun shen.mkstr (V2180 V2181) (cond ((string? V2180) (shen.mkstr-l (shen.proc-nl V2180) V2181)) (true (shen.mkstr-r (cons shen.proc-nl (cons V2180 ())) V2181))))
|
53
53
|
|
54
|
-
(defun shen.mkstr-l (
|
54
|
+
(defun shen.mkstr-l (V2182 V2183) (cond ((= () V2183) V2182) ((cons? V2183) (shen.mkstr-l (shen.insert-l (hd V2183) V2182) (tl V2183))) (true (shen.sys-error shen.mkstr-l))))
|
55
55
|
|
56
|
-
(defun shen.insert-l (
|
56
|
+
(defun shen.insert-l (V2186 V2187) (cond ((= "" V2187) "") ((and (shen.+string? V2187) (and (= "~" (pos V2187 0)) (and (shen.+string? (tlstr V2187)) (= "A" (pos (tlstr V2187) 0))))) (cons shen.app (cons V2186 (cons (tlstr (tlstr V2187)) (cons shen.a ()))))) ((and (shen.+string? V2187) (and (= "~" (pos V2187 0)) (and (shen.+string? (tlstr V2187)) (= "R" (pos (tlstr V2187) 0))))) (cons shen.app (cons V2186 (cons (tlstr (tlstr V2187)) (cons shen.r ()))))) ((and (shen.+string? V2187) (and (= "~" (pos V2187 0)) (and (shen.+string? (tlstr V2187)) (= "S" (pos (tlstr V2187) 0))))) (cons shen.app (cons V2186 (cons (tlstr (tlstr V2187)) (cons shen.s ()))))) ((shen.+string? V2187) (shen.factor-cn (cons cn (cons (pos V2187 0) (cons (shen.insert-l V2186 (tlstr V2187)) ()))))) ((and (cons? V2187) (and (= cn (hd V2187)) (and (cons? (tl V2187)) (and (cons? (tl (tl V2187))) (= () (tl (tl (tl V2187)))))))) (cons cn (cons (hd (tl V2187)) (cons (shen.insert-l V2186 (hd (tl (tl V2187)))) ())))) ((and (cons? V2187) (and (= shen.app (hd V2187)) (and (cons? (tl V2187)) (and (cons? (tl (tl V2187))) (and (cons? (tl (tl (tl V2187)))) (= () (tl (tl (tl (tl V2187)))))))))) (cons shen.app (cons (hd (tl V2187)) (cons (shen.insert-l V2186 (hd (tl (tl V2187)))) (tl (tl (tl V2187))))))) (true (shen.sys-error shen.insert-l))))
|
57
57
|
|
58
|
-
(defun shen.factor-cn (
|
58
|
+
(defun shen.factor-cn (V2188) (cond ((and (cons? V2188) (and (= cn (hd V2188)) (and (cons? (tl V2188)) (and (cons? (tl (tl V2188))) (and (cons? (hd (tl (tl V2188)))) (and (= cn (hd (hd (tl (tl V2188))))) (and (cons? (tl (hd (tl (tl V2188))))) (and (cons? (tl (tl (hd (tl (tl V2188)))))) (and (= () (tl (tl (tl (hd (tl (tl V2188))))))) (and (= () (tl (tl (tl V2188)))) (and (string? (hd (tl V2188))) (string? (hd (tl (hd (tl (tl V2188))))))))))))))))) (cons cn (cons (cn (hd (tl V2188)) (hd (tl (hd (tl (tl V2188)))))) (tl (tl (hd (tl (tl V2188)))))))) (true V2188)))
|
59
59
|
|
60
|
-
(defun shen.proc-nl (
|
60
|
+
(defun shen.proc-nl (V2189) (cond ((= "" V2189) "") ((and (shen.+string? V2189) (and (= "~" (pos V2189 0)) (and (shen.+string? (tlstr V2189)) (= "%" (pos (tlstr V2189) 0))))) (cn (n->string 10) (shen.proc-nl (tlstr (tlstr V2189))))) ((shen.+string? V2189) (cn (pos V2189 0) (shen.proc-nl (tlstr V2189)))) (true (shen.sys-error shen.proc-nl))))
|
61
61
|
|
62
|
-
(defun shen.mkstr-r (
|
62
|
+
(defun shen.mkstr-r (V2190 V2191) (cond ((= () V2191) V2190) ((cons? V2191) (shen.mkstr-r (cons shen.insert (cons (hd V2191) (cons V2190 ()))) (tl V2191))) (true (shen.sys-error shen.mkstr-r))))
|
63
63
|
|
64
|
-
(defun shen.insert (
|
64
|
+
(defun shen.insert (V2194 V2195) (cond ((= "" V2195) "") ((and (shen.+string? V2195) (and (= "~" (pos V2195 0)) (and (shen.+string? (tlstr V2195)) (= "A" (pos (tlstr V2195) 0))))) (shen.app V2194 (tlstr (tlstr V2195)) shen.a)) ((and (shen.+string? V2195) (and (= "~" (pos V2195 0)) (and (shen.+string? (tlstr V2195)) (= "R" (pos (tlstr V2195) 0))))) (shen.app V2194 (tlstr (tlstr V2195)) shen.r)) ((and (shen.+string? V2195) (and (= "~" (pos V2195 0)) (and (shen.+string? (tlstr V2195)) (= "S" (pos (tlstr V2195) 0))))) (shen.app V2194 (tlstr (tlstr V2195)) shen.s)) ((shen.+string? V2195) (cn (pos V2195 0) (shen.insert V2194 (tlstr V2195)))) (true (shen.sys-error shen.insert))))
|
65
65
|
|
66
|
-
(defun shen.app (
|
66
|
+
(defun shen.app (V2196 V2197 V2198) (cn (shen.arg->str V2196 V2198) V2197))
|
67
67
|
|
68
|
-
(defun shen.arg->str (
|
68
|
+
(defun shen.arg->str (V2204 V2205) (cond ((= V2204 (fail)) "...") ((shen.list? V2204) (shen.list->str V2204 V2205)) ((string? V2204) (shen.str->str V2204 V2205)) ((absvector? V2204) (shen.vector->str V2204 V2205)) (true (shen.atom->str V2204))))
|
69
69
|
|
70
|
-
(defun shen.list->str (
|
70
|
+
(defun shen.list->str (V2206 V2207) (cond ((= shen.r V2207) (@s "(" (@s (shen.iter-list V2206 shen.r (shen.maxseq)) ")"))) (true (@s "[" (@s (shen.iter-list V2206 V2207 (shen.maxseq)) "]")))))
|
71
71
|
|
72
72
|
(defun shen.maxseq () (value *maximum-print-sequence-size*))
|
73
73
|
|
74
|
-
(defun shen.iter-list (
|
74
|
+
(defun shen.iter-list (V2218 V2219 V2220) (cond ((= () V2218) "") ((= 0 V2220) "... etc") ((and (cons? V2218) (= () (tl V2218))) (shen.arg->str (hd V2218) V2219)) ((cons? V2218) (@s (shen.arg->str (hd V2218) V2219) (@s " " (shen.iter-list (tl V2218) V2219 (- V2220 1))))) (true (@s " " (@s "|" (@s " " (shen.arg->str V2218 V2219)))))))
|
75
75
|
|
76
|
-
(defun shen.str->str (
|
76
|
+
(defun shen.str->str (V2225 V2226) (cond ((= shen.a V2226) V2225) (true (@s (n->string 34) (@s V2225 (n->string 34))))))
|
77
77
|
|
78
|
-
(defun shen.vector->str (
|
78
|
+
(defun shen.vector->str (V2227 V2228) (if (shen.print-vector? V2227) ((<-address V2227 0) V2227) (if (vector? V2227) (@s "<" (@s (shen.iter-vector V2227 1 V2228 (shen.maxseq)) ">")) (@s "<" (@s "<" (@s (shen.iter-vector V2227 0 V2228 (shen.maxseq)) ">>"))))))
|
79
79
|
|
80
|
-
(defun shen.print-vector? (
|
80
|
+
(defun shen.print-vector? (V2229) (let Zero (<-address V2229 0) (if (= Zero shen.tuple) true (if (= Zero shen.pvar) true (if (not (number? Zero)) (shen.fbound? Zero) false)))))
|
81
81
|
|
82
|
-
(defun shen.fbound? (
|
82
|
+
(defun shen.fbound? (V2230) (trap-error (do (ps V2230) true) (lambda E false)))
|
83
83
|
|
84
|
-
(defun shen.tuple (
|
84
|
+
(defun shen.tuple (V2231) (cn "(@p " (shen.app (<-address V2231 1) (cn " " (shen.app (<-address V2231 2) ")" shen.s)) shen.s)))
|
85
85
|
|
86
|
-
(defun shen.iter-vector (
|
86
|
+
(defun shen.iter-vector (V2238 V2239 V2240 V2241) (cond ((= 0 V2241) "... etc") (true (let Item (trap-error (<-address V2238 V2239) (lambda E shen.out-of-bounds)) (let Next (trap-error (<-address V2238 (+ V2239 1)) (lambda E shen.out-of-bounds)) (if (= Item shen.out-of-bounds) "" (if (= Next shen.out-of-bounds) (shen.arg->str Item V2240) (@s (shen.arg->str Item V2240) (@s " " (shen.iter-vector V2238 (+ V2239 1) V2240 (- V2241 1)))))))))))
|
87
87
|
|
88
|
-
(defun shen.atom->str (
|
88
|
+
(defun shen.atom->str (V2242) (trap-error (str V2242) (lambda E (shen.funexstring))))
|
89
89
|
|
90
90
|
(defun shen.funexstring () (@s "" (@s "f" (@s "u" (@s "n" (@s "e" (@s (shen.arg->str (gensym (intern "x")) shen.a) "")))))))
|
91
91
|
|
92
|
-
(defun shen.list? (
|
92
|
+
(defun shen.list? (V2243) (or (empty? V2243) (cons? V2243)))
|
93
93
|
|
94
94
|
|
95
95
|
|
@@ -47,59 +47,59 @@
|
|
47
47
|
* explains this license in full. *
|
48
48
|
* *
|
49
49
|
*****************************************************************************************
|
50
|
-
"(defun shen.yacc (
|
50
|
+
"(defun shen.yacc (V2096) (cond ((and (cons? V2096) (and (= defcc (hd V2096)) (and (cons? (tl V2096)) (and (cons? (tl (tl V2096))) (and (= { (hd (tl (tl V2096)))) (and (cons? (tl (tl (tl V2096)))) (and (cons? (tl (tl (tl (tl V2096))))) (and (= ==> (hd (tl (tl (tl (tl V2096)))))) (and (cons? (tl (tl (tl (tl (tl V2096)))))) (and (cons? (tl (tl (tl (tl (tl (tl V2096))))))) (= } (hd (tl (tl (tl (tl (tl (tl V2096)))))))))))))))))) (shen.yacc (cons defcc (cons (hd (tl V2096)) (tl (tl (tl (tl (tl (tl (tl V2096))))))))))) ((and (cons? V2096) (and (= defcc (hd V2096)) (cons? (tl V2096)))) (shen.yacc->shen (hd (tl V2096)) (tl (tl V2096)))) (true (shen.sys-error shen.yacc))))
|
51
51
|
|
52
|
-
(defun shen.yacc->shen (
|
52
|
+
(defun shen.yacc->shen (V2097 V2098) (cons define (cons V2097 (shen.yacc_cases (map shen.cc_body (shen.split_cc_rules V2098 ()))))))
|
53
53
|
|
54
|
-
(defun shen.yacc_cases (
|
54
|
+
(defun shen.yacc_cases (V2099) (append (mapcan (lambda Case (cons Stream (cons <- (cons Case ())))) V2099) (cons _ (cons -> (cons (cons fail ()) ())))))
|
55
55
|
|
56
|
-
(defun shen.first_n (
|
56
|
+
(defun shen.first_n (V2104 V2105) (cond ((= 0 V2104) ()) ((= () V2105) ()) ((cons? V2105) (cons (hd V2105) (shen.first_n (- V2104 1) (tl V2105)))) (true (shen.sys-error shen.first_n))))
|
57
57
|
|
58
|
-
(defun shen.split_cc_rules (
|
58
|
+
(defun shen.split_cc_rules (V2106 V2107) (cond ((and (= () V2106) (= () V2107)) ()) ((= () V2106) (cons (shen.split_cc_rule (reverse V2107) ()) ())) ((and (cons? V2106) (= ; (hd V2106))) (cons (shen.split_cc_rule (reverse V2107) ()) (shen.split_cc_rules (tl V2106) ()))) ((cons? V2106) (shen.split_cc_rules (tl V2106) (cons (hd V2106) V2107))) (true (shen.sys-error shen.split_cc_rules))))
|
59
59
|
|
60
|
-
(defun shen.split_cc_rule (
|
61
|
-
" (stoutput)) (shen.split_cc_rule (cons := (cons (shen.default_semantics (reverse
|
60
|
+
(defun shen.split_cc_rule (V2108 V2109) (cond ((and (cons? V2108) (and (= := (hd V2108)) (and (cons? (tl V2108)) (= () (tl (tl V2108)))))) (cons (reverse V2109) (tl V2108))) ((and (cons? V2108) (and (= := (hd V2108)) (and (cons? (tl V2108)) (and (cons? (tl (tl V2108))) (and (= where (hd (tl (tl V2108)))) (and (cons? (tl (tl (tl V2108)))) (= () (tl (tl (tl (tl V2108))))))))))) (cons (reverse V2109) (cons (cons where (cons (hd (tl (tl (tl V2108)))) (cons (hd (tl V2108)) ()))) ()))) ((= () V2108) (do (pr "warning: " (stoutput)) (do (map (lambda X (pr (shen.app X " " shen.a) (stoutput))) (reverse V2109)) (do (pr "has no semantics.
|
61
|
+
" (stoutput)) (shen.split_cc_rule (cons := (cons (shen.default_semantics (reverse V2109)) ())) V2109))))) ((cons? V2108) (shen.split_cc_rule (tl V2108) (cons (hd V2108) V2109))) (true (shen.sys-error shen.split_cc_rule))))
|
62
62
|
|
63
|
-
(defun shen.default_semantics (
|
63
|
+
(defun shen.default_semantics (V2110) (cond ((= () V2110) ()) ((and (cons? V2110) (shen.grammar_symbol? (hd V2110))) (cons append (cons (hd V2110) (cons (shen.default_semantics (tl V2110)) ())))) ((cons? V2110) (cons cons (cons (hd V2110) (cons (shen.default_semantics (tl V2110)) ())))) (true (shen.sys-error shen.default_semantics))))
|
64
64
|
|
65
|
-
(defun shen.cc_body (
|
65
|
+
(defun shen.cc_body (V2111) (cond ((and (cons? V2111) (and (cons? (tl V2111)) (= () (tl (tl V2111))))) (shen.syntax (hd V2111) Stream (hd (tl V2111)))) (true (shen.sys-error shen.cc_body))))
|
66
66
|
|
67
|
-
(defun shen.syntax (
|
67
|
+
(defun shen.syntax (V2112 V2113 V2114) (cond ((and (= () V2112) (and (cons? V2114) (and (= where (hd V2114)) (and (cons? (tl V2114)) (and (cons? (tl (tl V2114))) (= () (tl (tl (tl V2114))))))))) (cons if (cons (shen.semantics (hd (tl V2114))) (cons (cons shen.pair (cons (cons hd (cons V2113 ())) (cons (shen.semantics (hd (tl (tl V2114)))) ()))) (cons (cons fail ()) ()))))) ((= () V2112) (cons shen.pair (cons (cons hd (cons V2113 ())) (cons (shen.semantics V2114) ())))) ((cons? V2112) (if (shen.grammar_symbol? (hd V2112)) (shen.recursive_descent V2112 V2113 V2114) (if (variable? (hd V2112)) (shen.variable-match V2112 V2113 V2114) (if (shen.terminal? (hd V2112)) (shen.check_stream V2112 V2113 V2114) (if (shen.jump_stream? (hd V2112)) (shen.jump_stream V2112 V2113 V2114) (if (shen.list_stream? (hd V2112)) (shen.list_stream (shen.decons (hd V2112)) (tl V2112) V2113 V2114) (simple-error (shen.app (hd V2112) " is not legal syntax
|
68
68
|
" shen.a)))))))) (true (shen.sys-error shen.syntax))))
|
69
69
|
|
70
|
-
(defun shen.list_stream? (
|
70
|
+
(defun shen.list_stream? (V2123) (cond ((cons? V2123) true) (true false)))
|
71
71
|
|
72
|
-
(defun shen.decons (
|
72
|
+
(defun shen.decons (V2124) (cond ((and (cons? V2124) (and (= cons (hd V2124)) (and (cons? (tl V2124)) (and (cons? (tl (tl V2124))) (= () (tl (tl (tl V2124)))))))) (cons (hd (tl V2124)) (shen.decons (hd (tl (tl V2124)))))) (true V2124)))
|
73
73
|
|
74
|
-
(defun shen.list_stream (
|
74
|
+
(defun shen.list_stream (V2125 V2126 V2127 V2128) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V2127 ())) ())) (cons (cons cons? (cons (cons hd (cons (cons hd (cons V2127 ())) ())) ())) ()))) (let Action (cons shen.snd-or-fail (cons (shen.syntax V2125 (cons shen.pair (cons (cons hd (cons (cons hd (cons V2127 ())) ())) (cons (cons shen.hdtl (cons V2127 ())) ()))) (cons shen.leave! (cons (shen.syntax V2126 (cons shen.pair (cons (cons tl (cons (cons hd (cons V2127 ())) ())) (cons (cons shen.hdtl (cons V2127 ())) ()))) V2128) ()))) ())) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ()))))))))
|
75
75
|
|
76
|
-
(defun shen.snd-or-fail (
|
76
|
+
(defun shen.snd-or-fail (V2135) (cond ((and (cons? V2135) (and (cons? (tl V2135)) (= () (tl (tl V2135))))) (hd (tl V2135))) (true (fail))))
|
77
77
|
|
78
|
-
(defun shen.grammar_symbol? (
|
78
|
+
(defun shen.grammar_symbol? (V2136) (and (symbol? V2136) (let Cs (explode V2136) (and (= (hd Cs) "<") (= (hd (reverse Cs)) ">")))))
|
79
79
|
|
80
|
-
(defun shen.recursive_descent (
|
80
|
+
(defun shen.recursive_descent (V2137 V2138 V2139) (cond ((cons? V2137) (let Test (cons (hd V2137) (cons V2138 ())) (let Action (shen.syntax (tl V2137) (concat Parse_ (hd V2137)) V2139) (let Else (cons fail ()) (cons let (cons (concat Parse_ (hd V2137)) (cons Test (cons (cons if (cons (cons not (cons (cons = (cons (cons fail ()) (cons (concat Parse_ (hd V2137)) ()))) ())) (cons Action (cons Else ())))) ())))))))) (true (shen.sys-error shen.recursive_descent))))
|
81
81
|
|
82
|
-
(defun shen.variable-match (
|
82
|
+
(defun shen.variable-match (V2140 V2141 V2142) (cond ((cons? V2140) (let Test (cons cons? (cons (cons hd (cons V2141 ())) ())) (let Action (cons let (cons (concat Parse_ (hd V2140)) (cons (cons hd (cons (cons hd (cons V2141 ())) ())) (cons (shen.syntax (tl V2140) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2141 ())) ())) (cons (cons shen.hdtl (cons V2141 ())) ()))) V2142) ())))) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.sys-error shen.variable-match))))
|
83
83
|
|
84
|
-
(defun shen.terminal? (
|
84
|
+
(defun shen.terminal? (V2151) (cond ((cons? V2151) false) ((variable? V2151) false) (true true)))
|
85
85
|
|
86
|
-
(defun shen.jump_stream? (
|
86
|
+
(defun shen.jump_stream? (V2156) (cond ((= V2156 _) true) (true false)))
|
87
87
|
|
88
|
-
(defun shen.check_stream (
|
88
|
+
(defun shen.check_stream (V2157 V2158 V2159) (cond ((cons? V2157) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V2158 ())) ())) (cons (cons = (cons (hd V2157) (cons (cons hd (cons (cons hd (cons V2158 ())) ())) ()))) ()))) (let Action (shen.syntax (tl V2157) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2158 ())) ())) (cons (cons shen.hdtl (cons V2158 ())) ()))) V2159) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.sys-error shen.check_stream))))
|
89
89
|
|
90
|
-
(defun shen.jump_stream (
|
90
|
+
(defun shen.jump_stream (V2160 V2161 V2162) (cond ((cons? V2160) (let Test (cons cons? (cons (cons hd (cons V2161 ())) ())) (let Action (shen.syntax (tl V2160) (cons shen.pair (cons (cons tl (cons (cons hd (cons V2161 ())) ())) (cons (cons shen.hdtl (cons V2161 ())) ()))) V2162) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.sys-error shen.jump_stream))))
|
91
91
|
|
92
|
-
(defun shen.semantics (
|
92
|
+
(defun shen.semantics (V2163) (cond ((and (cons? V2163) (and (= shen.leave! (hd V2163)) (and (cons? (tl V2163)) (= () (tl (tl V2163)))))) (hd (tl V2163))) ((= () V2163) ()) ((shen.grammar_symbol? V2163) (cons shen.hdtl (cons (concat Parse_ V2163) ()))) ((variable? V2163) (concat Parse_ V2163)) ((cons? V2163) (map shen.semantics V2163)) (true V2163)))
|
93
93
|
|
94
94
|
(defun fail () shen.fail!)
|
95
95
|
|
96
|
-
(defun shen.pair (
|
96
|
+
(defun shen.pair (V2164 V2165) (cons V2164 (cons V2165 ())))
|
97
97
|
|
98
|
-
(defun shen.hdtl (
|
98
|
+
(defun shen.hdtl (V2166) (hd (tl V2166)))
|
99
99
|
|
100
|
-
(defun <!> (
|
100
|
+
(defun <!> (V2173) (cond ((and (cons? V2173) (and (cons? (tl V2173)) (= () (tl (tl V2173))))) (cons () (cons (hd V2173) ()))) (true (fail))))
|
101
101
|
|
102
|
-
(defun <e> (
|
102
|
+
(defun <e> (V2178) (cond ((and (cons? V2178) (and (cons? (tl V2178)) (= () (tl (tl V2178))))) (cons (hd V2178) (cons () ()))) (true (shen.sys-error <e>))))
|
103
103
|
|
104
104
|
|
105
105
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shen-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '2.12'
|
31
31
|
description: ShenRuby is a port of the Shen programming language to Ruby. It currently
|
32
|
-
supports Shen version 9.
|
32
|
+
supports Shen version 9.1.
|
33
33
|
email:
|
34
34
|
- greg@sourcematters.org
|
35
35
|
executables:
|