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.
@@ -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 (V2280) (set *version* V2280))
54
+ (defun version (V2288) (set *version* V2288))
55
55
 
56
- (version "version 12")
56
+ (version "version 13")
57
57
 
58
58
  (defun shen.credits () (do (shen.prhush "
59
59
  Shen 2010, copyright (C) 2010 Mark Tarver
@@ -65,27 +65,27 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
65
65
 
66
66
  (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 ()))))))))))
67
67
 
68
- (defun shen.multiple-set (V2281) (cond ((= () V2281) ()) ((and (cons? V2281) (cons? (tl V2281))) (do (set (hd V2281) (hd (tl V2281))) (shen.multiple-set (tl (tl V2281))))) (true (shen.sys-error shen.multiple-set))))
68
+ (defun shen.multiple-set (V2289) (cond ((= () V2289) ()) ((and (cons? V2289) (cons? (tl V2289))) (do (set (hd V2289) (hd (tl V2289))) (shen.multiple-set (tl (tl V2289))))) (true (shen.sys-error shen.multiple-set))))
69
69
 
70
- (defun destroy (V2282) (declare V2282 ()))
70
+ (defun destroy (V2290) (declare V2290 ()))
71
71
 
72
72
  (set shen.*history* ())
73
73
 
74
74
  (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)))))))
75
75
 
76
- (defun shen.retrieve-from-history-if-needed (V2292 V2293) (cond ((and (tuple? V2292) (and (cons? (snd V2292)) (and (cons? (tl (snd V2292))) (and (= () (tl (tl (snd V2292)))) (and (cons? V2293) (and (= (hd (snd V2292)) (shen.exclamation)) (= (hd (tl (snd V2292))) (shen.exclamation)))))))) (let PastPrint (shen.prbytes (snd (hd V2293))) (hd V2293))) ((and (tuple? V2292) (and (cons? (snd V2292)) (= (hd (snd V2292)) (shen.exclamation)))) (let Key? (shen.make-key (tl (snd V2292)) V2293) (let Find (head (shen.find-past-inputs Key? V2293)) (let PastPrint (shen.prbytes (snd Find)) Find)))) ((and (tuple? V2292) (and (cons? (snd V2292)) (and (= () (tl (snd V2292))) (= (hd (snd V2292)) (shen.percent))))) (do (shen.print-past-inputs (lambda X true) (reverse V2293) 0) (abort))) ((and (tuple? V2292) (and (cons? (snd V2292)) (= (hd (snd V2292)) (shen.percent)))) (let Key? (shen.make-key (tl (snd V2292)) V2293) (let Pastprint (shen.print-past-inputs Key? (reverse V2293) 0) (abort)))) (true V2292)))
76
+ (defun shen.retrieve-from-history-if-needed (V2300 V2301) (cond ((and (tuple? V2300) (and (cons? (snd V2300)) (element? (hd (snd V2300)) (cons (shen.space) (cons (shen.newline) ()))))) (shen.retrieve-from-history-if-needed (@p (fst V2300) (tl (snd V2300))) V2301)) ((and (tuple? V2300) (and (cons? (snd V2300)) (and (cons? (tl (snd V2300))) (and (= () (tl (tl (snd V2300)))) (and (cons? V2301) (and (= (hd (snd V2300)) (shen.exclamation)) (= (hd (tl (snd V2300))) (shen.exclamation)))))))) (let PastPrint (shen.prbytes (snd (hd V2301))) (hd V2301))) ((and (tuple? V2300) (and (cons? (snd V2300)) (= (hd (snd V2300)) (shen.exclamation)))) (let Key? (shen.make-key (tl (snd V2300)) V2301) (let Find (head (shen.find-past-inputs Key? V2301)) (let PastPrint (shen.prbytes (snd Find)) Find)))) ((and (tuple? V2300) (and (cons? (snd V2300)) (and (= () (tl (snd V2300))) (= (hd (snd V2300)) (shen.percent))))) (do (shen.print-past-inputs (lambda X true) (reverse V2301) 0) (abort))) ((and (tuple? V2300) (and (cons? (snd V2300)) (= (hd (snd V2300)) (shen.percent)))) (let Key? (shen.make-key (tl (snd V2300)) V2301) (let Pastprint (shen.print-past-inputs Key? (reverse V2301) 0) (abort)))) (true V2300)))
77
77
 
78
78
  (defun shen.percent () 37)
79
79
 
80
80
  (defun shen.exclamation () 33)
81
81
 
82
- (defun shen.prbytes (V2294) (do (map (lambda Byte (pr (n->string Byte) (stoutput))) V2294) (nl 1)))
82
+ (defun shen.prbytes (V2302) (do (map (lambda Byte (pr (n->string Byte) (stoutput))) V2302) (nl 1)))
83
83
 
84
- (defun shen.update_history (V2295 V2296) (set shen.*history* (cons V2295 V2296)))
84
+ (defun shen.update_history (V2303 V2304) (set shen.*history* (cons V2303 V2304)))
85
85
 
86
86
  (defun shen.toplineread () (shen.toplineread_loop (read-byte (stinput)) ()))
87
87
 
88
- (defun shen.toplineread_loop (V2298 V2299) (cond ((= V2298 (shen.hat)) (simple-error "line read aborted")) ((element? V2298 (cons (shen.newline) (cons (shen.carriage-return) ()))) (let Line (compile shen.<st_input> V2299 (lambda E shen.nextline)) (if (or (= Line shen.nextline) (empty? Line)) (shen.toplineread_loop (read-byte (stinput)) (append V2299 (cons V2298 ()))) (@p Line V2299)))) (true (shen.toplineread_loop (read-byte (stinput)) (append V2299 (cons V2298 ()))))))
88
+ (defun shen.toplineread_loop (V2306 V2307) (cond ((= V2306 (shen.hat)) (simple-error "line read aborted")) ((element? V2306 (cons (shen.newline) (cons (shen.carriage-return) ()))) (let Line (compile shen.<st_input> V2307 (lambda E shen.nextline)) (if (or (= Line shen.nextline) (empty? Line)) (shen.toplineread_loop (read-byte (stinput)) (append V2307 (cons V2306 ()))) (@p Line V2307)))) (true (shen.toplineread_loop (read-byte (stinput)) (append V2307 (cons V2306 ()))))))
89
89
 
90
90
  (defun shen.hat () 94)
91
91
 
@@ -93,7 +93,7 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
93
93
 
94
94
  (defun shen.carriage-return () 13)
95
95
 
96
- (defun tc (V2304) (cond ((= + V2304) (set shen.*tc* true)) ((= - V2304) (set shen.*tc* false)) (true (simple-error "tc expects a + or -"))))
96
+ (defun tc (V2312) (cond ((= + V2312) (set shen.*tc* true)) ((= - V2312) (set shen.*tc* false)) (true (simple-error "tc expects a + or -"))))
97
97
 
98
98
  (defun shen.prompt () (if (value shen.*tc*) (shen.prhush (cn "
99
99
 
@@ -101,16 +101,16 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
101
101
 
102
102
  (" (shen.app (length (value shen.*history*)) "-) " shen.a)) (stoutput))))
103
103
 
104
- (defun shen.toplevel (V2305) (shen.toplevel_evaluate V2305 (value shen.*tc*)))
104
+ (defun shen.toplevel (V2313) (shen.toplevel_evaluate V2313 (value shen.*tc*)))
105
105
 
106
- (defun shen.find-past-inputs (V2306 V2307) (let F (shen.find V2306 V2307) (if (empty? F) (simple-error "input not found
106
+ (defun shen.find-past-inputs (V2314 V2315) (let F (shen.find V2314 V2315) (if (empty? F) (simple-error "input not found
107
107
  ") F)))
108
108
 
109
- (defun shen.make-key (V2308 V2309) (let Atom (hd (compile shen.<st_input> V2308 (lambda E (if (cons? E) (simple-error (cn "parse error here: " (shen.app E "
109
+ (defun shen.make-key (V2316 V2317) (let Atom (hd (compile shen.<st_input> V2316 (lambda E (if (cons? E) (simple-error (cn "parse error here: " (shen.app E "
110
110
  " shen.s))) (simple-error "parse error
111
- "))))) (if (integer? Atom) (lambda X (= X (nth (+ Atom 1) (reverse V2309)))) (lambda X (shen.prefix? V2308 (shen.trim-gubbins (snd X)))))))
111
+ "))))) (if (integer? Atom) (lambda X (= X (nth (+ Atom 1) (reverse V2317)))) (lambda X (shen.prefix? V2316 (shen.trim-gubbins (snd X)))))))
112
112
 
113
- (defun shen.trim-gubbins (V2310) (cond ((and (cons? V2310) (= (hd V2310) (shen.space))) (shen.trim-gubbins (tl V2310))) ((and (cons? V2310) (= (hd V2310) (shen.newline))) (shen.trim-gubbins (tl V2310))) ((and (cons? V2310) (= (hd V2310) (shen.carriage-return))) (shen.trim-gubbins (tl V2310))) ((and (cons? V2310) (= (hd V2310) (shen.tab))) (shen.trim-gubbins (tl V2310))) ((and (cons? V2310) (= (hd V2310) (shen.left-round))) (shen.trim-gubbins (tl V2310))) (true V2310)))
113
+ (defun shen.trim-gubbins (V2318) (cond ((and (cons? V2318) (= (hd V2318) (shen.space))) (shen.trim-gubbins (tl V2318))) ((and (cons? V2318) (= (hd V2318) (shen.newline))) (shen.trim-gubbins (tl V2318))) ((and (cons? V2318) (= (hd V2318) (shen.carriage-return))) (shen.trim-gubbins (tl V2318))) ((and (cons? V2318) (= (hd V2318) (shen.tab))) (shen.trim-gubbins (tl V2318))) ((and (cons? V2318) (= (hd V2318) (shen.left-round))) (shen.trim-gubbins (tl V2318))) (true V2318)))
114
114
 
115
115
  (defun shen.space () 32)
116
116
 
@@ -118,22 +118,22 @@ port " (shen.app (value *port*) (cn " ported by " (shen.app (value *porters*) "
118
118
 
119
119
  (defun shen.left-round () 40)
120
120
 
121
- (defun shen.find (V2317 V2318) (cond ((= () V2318) ()) ((and (cons? V2318) (V2317 (hd V2318))) (cons (hd V2318) (shen.find V2317 (tl V2318)))) ((cons? V2318) (shen.find V2317 (tl V2318))) (true (shen.sys-error shen.find))))
121
+ (defun shen.find (V2325 V2326) (cond ((= () V2326) ()) ((and (cons? V2326) (V2325 (hd V2326))) (cons (hd V2326) (shen.find V2325 (tl V2326)))) ((cons? V2326) (shen.find V2325 (tl V2326))) (true (shen.sys-error shen.find))))
122
122
 
123
- (defun shen.prefix? (V2329 V2330) (cond ((= () V2329) true) ((and (cons? V2329) (and (cons? V2330) (= (hd V2330) (hd V2329)))) (shen.prefix? (tl V2329) (tl V2330))) (true false)))
123
+ (defun shen.prefix? (V2337 V2338) (cond ((= () V2337) true) ((and (cons? V2337) (and (cons? V2338) (= (hd V2338) (hd V2337)))) (shen.prefix? (tl V2337) (tl V2338))) (true false)))
124
124
 
125
- (defun shen.print-past-inputs (V2340 V2341 V2342) (cond ((= () V2341) _) ((and (cons? V2341) (not (V2340 (hd V2341)))) (shen.print-past-inputs V2340 (tl V2341) (+ V2342 1))) ((and (cons? V2341) (tuple? (hd V2341))) (do (shen.prhush (shen.app V2342 ". " shen.a) (stoutput)) (do (shen.prbytes (snd (hd V2341))) (shen.print-past-inputs V2340 (tl V2341) (+ V2342 1))))) (true (shen.sys-error shen.print-past-inputs))))
125
+ (defun shen.print-past-inputs (V2348 V2349 V2350) (cond ((= () V2349) _) ((and (cons? V2349) (not (V2348 (hd V2349)))) (shen.print-past-inputs V2348 (tl V2349) (+ V2350 1))) ((and (cons? V2349) (tuple? (hd V2349))) (do (shen.prhush (shen.app V2350 ". " shen.a) (stoutput)) (do (shen.prbytes (snd (hd V2349))) (shen.print-past-inputs V2348 (tl V2349) (+ V2350 1))))) (true (shen.sys-error shen.print-past-inputs))))
126
126
 
127
- (defun shen.toplevel_evaluate (V2343 V2344) (cond ((and (cons? V2343) (and (cons? (tl V2343)) (and (= : (hd (tl V2343))) (and (cons? (tl (tl V2343))) (and (= () (tl (tl (tl V2343)))) (= true V2344)))))) (shen.typecheck-and-evaluate (hd V2343) (hd (tl (tl V2343))))) ((and (cons? V2343) (cons? (tl V2343))) (do (shen.toplevel_evaluate (cons (hd V2343) ()) V2344) (do (nl 1) (shen.toplevel_evaluate (tl V2343) V2344)))) ((and (cons? V2343) (and (= () (tl V2343)) (= true V2344))) (shen.typecheck-and-evaluate (hd V2343) (gensym A))) ((and (cons? V2343) (and (= () (tl V2343)) (= false V2344))) (let Eval (shen.eval-without-macros (hd V2343)) (print Eval))) (true (shen.sys-error shen.toplevel_evaluate))))
127
+ (defun shen.toplevel_evaluate (V2351 V2352) (cond ((and (cons? V2351) (and (cons? (tl V2351)) (and (= : (hd (tl V2351))) (and (cons? (tl (tl V2351))) (and (= () (tl (tl (tl V2351)))) (= true V2352)))))) (shen.typecheck-and-evaluate (hd V2351) (hd (tl (tl V2351))))) ((and (cons? V2351) (cons? (tl V2351))) (do (shen.toplevel_evaluate (cons (hd V2351) ()) V2352) (do (nl 1) (shen.toplevel_evaluate (tl V2351) V2352)))) ((and (cons? V2351) (and (= () (tl V2351)) (= true V2352))) (shen.typecheck-and-evaluate (hd V2351) (gensym A))) ((and (cons? V2351) (and (= () (tl V2351)) (= false V2352))) (let Eval (shen.eval-without-macros (hd V2351)) (print Eval))) (true (shen.sys-error shen.toplevel_evaluate))))
128
128
 
129
- (defun shen.typecheck-and-evaluate (V2345 V2346) (let Typecheck (shen.typecheck V2345 V2346) (if (= Typecheck false) (simple-error "type error
130
- ") (let Eval (shen.eval-without-macros V2345) (let Type (shen.pretty-type Typecheck) (shen.prhush (shen.app Eval (cn " : " (shen.app Type "" shen.r)) shen.s) (stoutput)))))))
129
+ (defun shen.typecheck-and-evaluate (V2353 V2354) (let Typecheck (shen.typecheck V2353 V2354) (if (= Typecheck false) (simple-error "type error
130
+ ") (let Eval (shen.eval-without-macros V2353) (let Type (shen.pretty-type Typecheck) (shen.prhush (shen.app Eval (cn " : " (shen.app Type "" shen.r)) shen.s) (stoutput)))))))
131
131
 
132
- (defun shen.pretty-type (V2347) (shen.mult_subst (value shen.*alphabet*) (shen.extract-pvars V2347) V2347))
132
+ (defun shen.pretty-type (V2355) (shen.mult_subst (value shen.*alphabet*) (shen.extract-pvars V2355) V2355))
133
133
 
134
- (defun shen.extract-pvars (V2352) (cond ((shen.pvar? V2352) (cons V2352 ())) ((cons? V2352) (union (shen.extract-pvars (hd V2352)) (shen.extract-pvars (tl V2352)))) (true ())))
134
+ (defun shen.extract-pvars (V2360) (cond ((shen.pvar? V2360) (cons V2360 ())) ((cons? V2360) (union (shen.extract-pvars (hd V2360)) (shen.extract-pvars (tl V2360)))) (true ())))
135
135
 
136
- (defun shen.mult_subst (V2357 V2358 V2359) (cond ((= () V2357) V2359) ((= () V2358) V2359) ((and (cons? V2357) (cons? V2358)) (shen.mult_subst (tl V2357) (tl V2358) (subst (hd V2357) (hd V2358) V2359))) (true (shen.sys-error shen.mult_subst))))
136
+ (defun shen.mult_subst (V2365 V2366 V2367) (cond ((= () V2365) V2367) ((= () V2366) V2367) ((and (cons? V2365) (cons? V2366)) (shen.mult_subst (tl V2365) (tl V2366) (subst (hd V2365) (hd V2366) V2367))) (true (shen.sys-error shen.mult_subst))))
137
137
 
138
138
 
139
139
 
@@ -114,8 +114,6 @@
114
114
 
115
115
  (declare fix (cons (cons A (cons --> (cons A ()))) (cons --> (cons (cons A (cons --> (cons A ()))) ()))))
116
116
 
117
- (declare format (cons (cons stream (cons out ())) (cons --> (cons (cons string (cons --> (cons (cons A (cons --> (cons string ()))) ()))) ()))))
118
-
119
117
  (declare freeze (cons A (cons --> (cons (cons lazy (cons A ())) ()))))
120
118
 
121
119
  (declare fst (cons (cons A (cons * (cons B ()))) (cons --> (cons A ()))))
@@ -286,6 +284,8 @@
286
284
 
287
285
  (declare write-to-file (cons string (cons --> (cons (cons A (cons --> (cons A ()))) ()))))
288
286
 
287
+ (declare write-byte (cons number (cons --> (cons (cons (cons stream (cons out ())) (cons --> (cons number ()))) ()))))
288
+
289
289
  (declare y-or-n? (cons string (cons --> (cons boolean ()))))
290
290
 
291
291
  (declare > (cons number (cons --> (cons (cons number (cons --> (cons boolean ()))) ()))))
@@ -47,53 +47,59 @@
47
47
  * explains this license in full. *
48
48
  * *
49
49
  *****************************************************************************************
50
- "(defun print (V2210) (let String (shen.insert V2210 "~S") (let Print (shen.prhush String (stoutput)) V2210)))
50
+ "(defun pr (V2210 V2211) (trap-error (shen.prh V2210 V2211 0) (lambda E V2210)))
51
51
 
52
- (defun shen.prhush (V2211 V2212) (if (value *hush*) V2211 (pr V2211 V2212)))
52
+ (defun shen.prh (V2212 V2213 V2214) (shen.prh V2212 V2213 (shen.write-char-and-inc V2212 V2213 V2214)))
53
53
 
54
- (defun shen.mkstr (V2213 V2214) (cond ((string? V2213) (shen.mkstr-l (shen.proc-nl V2213) V2214)) (true (shen.mkstr-r (cons shen.proc-nl (cons V2213 ())) V2214))))
54
+ (defun shen.write-char-and-inc (V2215 V2216 V2217) (do (write-byte (string->n (pos V2215 V2217)) V2216) (+ V2217 1)))
55
55
 
56
- (defun shen.mkstr-l (V2215 V2216) (cond ((= () V2216) V2215) ((cons? V2216) (shen.mkstr-l (shen.insert-l (hd V2216) V2215) (tl V2216))) (true (shen.sys-error shen.mkstr-l))))
56
+ (defun print (V2218) (let String (shen.insert V2218 "~S") (let Print (shen.prhush String (stoutput)) V2218)))
57
57
 
58
- (defun shen.insert-l (V2219 V2220) (cond ((= "" V2220) "") ((and (shen.+string? V2220) (and (= "~" (pos V2220 0)) (and (shen.+string? (tlstr V2220)) (= "A" (pos (tlstr V2220) 0))))) (cons shen.app (cons V2219 (cons (tlstr (tlstr V2220)) (cons shen.a ()))))) ((and (shen.+string? V2220) (and (= "~" (pos V2220 0)) (and (shen.+string? (tlstr V2220)) (= "R" (pos (tlstr V2220) 0))))) (cons shen.app (cons V2219 (cons (tlstr (tlstr V2220)) (cons shen.r ()))))) ((and (shen.+string? V2220) (and (= "~" (pos V2220 0)) (and (shen.+string? (tlstr V2220)) (= "S" (pos (tlstr V2220) 0))))) (cons shen.app (cons V2219 (cons (tlstr (tlstr V2220)) (cons shen.s ()))))) ((shen.+string? V2220) (shen.factor-cn (cons cn (cons (pos V2220 0) (cons (shen.insert-l V2219 (tlstr V2220)) ()))))) ((and (cons? V2220) (and (= cn (hd V2220)) (and (cons? (tl V2220)) (and (cons? (tl (tl V2220))) (= () (tl (tl (tl V2220)))))))) (cons cn (cons (hd (tl V2220)) (cons (shen.insert-l V2219 (hd (tl (tl V2220)))) ())))) ((and (cons? V2220) (and (= shen.app (hd V2220)) (and (cons? (tl V2220)) (and (cons? (tl (tl V2220))) (and (cons? (tl (tl (tl V2220)))) (= () (tl (tl (tl (tl V2220)))))))))) (cons shen.app (cons (hd (tl V2220)) (cons (shen.insert-l V2219 (hd (tl (tl V2220)))) (tl (tl (tl V2220))))))) (true (shen.sys-error shen.insert-l))))
58
+ (defun shen.prhush (V2219 V2220) (if (value *hush*) V2219 (pr V2219 V2220)))
59
59
 
60
- (defun shen.factor-cn (V2221) (cond ((and (cons? V2221) (and (= cn (hd V2221)) (and (cons? (tl V2221)) (and (cons? (tl (tl V2221))) (and (cons? (hd (tl (tl V2221)))) (and (= cn (hd (hd (tl (tl V2221))))) (and (cons? (tl (hd (tl (tl V2221))))) (and (cons? (tl (tl (hd (tl (tl V2221)))))) (and (= () (tl (tl (tl (hd (tl (tl V2221))))))) (and (= () (tl (tl (tl V2221)))) (and (string? (hd (tl V2221))) (string? (hd (tl (hd (tl (tl V2221))))))))))))))))) (cons cn (cons (cn (hd (tl V2221)) (hd (tl (hd (tl (tl V2221)))))) (tl (tl (hd (tl (tl V2221)))))))) (true V2221)))
60
+ (defun shen.mkstr (V2221 V2222) (cond ((string? V2221) (shen.mkstr-l (shen.proc-nl V2221) V2222)) (true (shen.mkstr-r (cons shen.proc-nl (cons V2221 ())) V2222))))
61
61
 
62
- (defun shen.proc-nl (V2222) (cond ((= "" V2222) "") ((and (shen.+string? V2222) (and (= "~" (pos V2222 0)) (and (shen.+string? (tlstr V2222)) (= "%" (pos (tlstr V2222) 0))))) (cn (n->string 10) (shen.proc-nl (tlstr (tlstr V2222))))) ((shen.+string? V2222) (cn (pos V2222 0) (shen.proc-nl (tlstr V2222)))) (true (shen.sys-error shen.proc-nl))))
62
+ (defun shen.mkstr-l (V2223 V2224) (cond ((= () V2224) V2223) ((cons? V2224) (shen.mkstr-l (shen.insert-l (hd V2224) V2223) (tl V2224))) (true (shen.sys-error shen.mkstr-l))))
63
63
 
64
- (defun shen.mkstr-r (V2223 V2224) (cond ((= () V2224) V2223) ((cons? V2224) (shen.mkstr-r (cons shen.insert (cons (hd V2224) (cons V2223 ()))) (tl V2224))) (true (shen.sys-error shen.mkstr-r))))
64
+ (defun shen.insert-l (V2227 V2228) (cond ((= "" V2228) "") ((and (shen.+string? V2228) (and (= "~" (pos V2228 0)) (and (shen.+string? (tlstr V2228)) (= "A" (pos (tlstr V2228) 0))))) (cons shen.app (cons V2227 (cons (tlstr (tlstr V2228)) (cons shen.a ()))))) ((and (shen.+string? V2228) (and (= "~" (pos V2228 0)) (and (shen.+string? (tlstr V2228)) (= "R" (pos (tlstr V2228) 0))))) (cons shen.app (cons V2227 (cons (tlstr (tlstr V2228)) (cons shen.r ()))))) ((and (shen.+string? V2228) (and (= "~" (pos V2228 0)) (and (shen.+string? (tlstr V2228)) (= "S" (pos (tlstr V2228) 0))))) (cons shen.app (cons V2227 (cons (tlstr (tlstr V2228)) (cons shen.s ()))))) ((shen.+string? V2228) (shen.factor-cn (cons cn (cons (pos V2228 0) (cons (shen.insert-l V2227 (tlstr V2228)) ()))))) ((and (cons? V2228) (and (= cn (hd V2228)) (and (cons? (tl V2228)) (and (cons? (tl (tl V2228))) (= () (tl (tl (tl V2228)))))))) (cons cn (cons (hd (tl V2228)) (cons (shen.insert-l V2227 (hd (tl (tl V2228)))) ())))) ((and (cons? V2228) (and (= shen.app (hd V2228)) (and (cons? (tl V2228)) (and (cons? (tl (tl V2228))) (and (cons? (tl (tl (tl V2228)))) (= () (tl (tl (tl (tl V2228)))))))))) (cons shen.app (cons (hd (tl V2228)) (cons (shen.insert-l V2227 (hd (tl (tl V2228)))) (tl (tl (tl V2228))))))) (true (shen.sys-error shen.insert-l))))
65
65
 
66
- (defun shen.insert (V2225 V2226) (shen.insert-h V2225 V2226 ""))
66
+ (defun shen.factor-cn (V2229) (cond ((and (cons? V2229) (and (= cn (hd V2229)) (and (cons? (tl V2229)) (and (cons? (tl (tl V2229))) (and (cons? (hd (tl (tl V2229)))) (and (= cn (hd (hd (tl (tl V2229))))) (and (cons? (tl (hd (tl (tl V2229))))) (and (cons? (tl (tl (hd (tl (tl V2229)))))) (and (= () (tl (tl (tl (hd (tl (tl V2229))))))) (and (= () (tl (tl (tl V2229)))) (and (string? (hd (tl V2229))) (string? (hd (tl (hd (tl (tl V2229))))))))))))))))) (cons cn (cons (cn (hd (tl V2229)) (hd (tl (hd (tl (tl V2229)))))) (tl (tl (hd (tl (tl V2229)))))))) (true V2229)))
67
67
 
68
- (defun shen.insert-h (V2229 V2230 V2231) (cond ((= "" V2230) V2231) ((and (shen.+string? V2230) (and (= "~" (pos V2230 0)) (and (shen.+string? (tlstr V2230)) (= "A" (pos (tlstr V2230) 0))))) (cn V2231 (shen.app V2229 (tlstr (tlstr V2230)) shen.a))) ((and (shen.+string? V2230) (and (= "~" (pos V2230 0)) (and (shen.+string? (tlstr V2230)) (= "R" (pos (tlstr V2230) 0))))) (cn V2231 (shen.app V2229 (tlstr (tlstr V2230)) shen.r))) ((and (shen.+string? V2230) (and (= "~" (pos V2230 0)) (and (shen.+string? (tlstr V2230)) (= "S" (pos (tlstr V2230) 0))))) (cn V2231 (shen.app V2229 (tlstr (tlstr V2230)) shen.s))) ((shen.+string? V2230) (shen.insert-h V2229 (tlstr V2230) (cn V2231 (pos V2230 0)))) (true (shen.sys-error shen.insert-h))))
68
+ (defun shen.proc-nl (V2230) (cond ((= "" V2230) "") ((and (shen.+string? V2230) (and (= "~" (pos V2230 0)) (and (shen.+string? (tlstr V2230)) (= "%" (pos (tlstr V2230) 0))))) (cn (n->string 10) (shen.proc-nl (tlstr (tlstr V2230))))) ((shen.+string? V2230) (cn (pos V2230 0) (shen.proc-nl (tlstr V2230)))) (true (shen.sys-error shen.proc-nl))))
69
69
 
70
- (defun shen.app (V2232 V2233 V2234) (cn (shen.arg->str V2232 V2234) V2233))
70
+ (defun shen.mkstr-r (V2231 V2232) (cond ((= () V2232) V2231) ((cons? V2232) (shen.mkstr-r (cons shen.insert (cons (hd V2232) (cons V2231 ()))) (tl V2232))) (true (shen.sys-error shen.mkstr-r))))
71
71
 
72
- (defun shen.arg->str (V2240 V2241) (cond ((= V2240 (fail)) "...") ((shen.list? V2240) (shen.list->str V2240 V2241)) ((string? V2240) (shen.str->str V2240 V2241)) ((absvector? V2240) (shen.vector->str V2240 V2241)) (true (shen.atom->str V2240))))
72
+ (defun shen.insert (V2233 V2234) (shen.insert-h V2233 V2234 ""))
73
73
 
74
- (defun shen.list->str (V2242 V2243) (cond ((= shen.r V2243) (@s "(" (@s (shen.iter-list V2242 shen.r (shen.maxseq)) ")"))) (true (@s "[" (@s (shen.iter-list V2242 V2243 (shen.maxseq)) "]")))))
74
+ (defun shen.insert-h (V2237 V2238 V2239) (cond ((= "" V2238) V2239) ((and (shen.+string? V2238) (and (= "~" (pos V2238 0)) (and (shen.+string? (tlstr V2238)) (= "A" (pos (tlstr V2238) 0))))) (cn V2239 (shen.app V2237 (tlstr (tlstr V2238)) shen.a))) ((and (shen.+string? V2238) (and (= "~" (pos V2238 0)) (and (shen.+string? (tlstr V2238)) (= "R" (pos (tlstr V2238) 0))))) (cn V2239 (shen.app V2237 (tlstr (tlstr V2238)) shen.r))) ((and (shen.+string? V2238) (and (= "~" (pos V2238 0)) (and (shen.+string? (tlstr V2238)) (= "S" (pos (tlstr V2238) 0))))) (cn V2239 (shen.app V2237 (tlstr (tlstr V2238)) shen.s))) ((shen.+string? V2238) (shen.insert-h V2237 (tlstr V2238) (cn V2239 (pos V2238 0)))) (true (shen.sys-error shen.insert-h))))
75
+
76
+ (defun shen.app (V2240 V2241 V2242) (cn (shen.arg->str V2240 V2242) V2241))
77
+
78
+ (defun shen.arg->str (V2248 V2249) (cond ((= V2248 (fail)) "...") ((shen.list? V2248) (shen.list->str V2248 V2249)) ((string? V2248) (shen.str->str V2248 V2249)) ((absvector? V2248) (shen.vector->str V2248 V2249)) (true (shen.atom->str V2248))))
79
+
80
+ (defun shen.list->str (V2250 V2251) (cond ((= shen.r V2251) (@s "(" (@s (shen.iter-list V2250 shen.r (shen.maxseq)) ")"))) (true (@s "[" (@s (shen.iter-list V2250 V2251 (shen.maxseq)) "]")))))
75
81
 
76
82
  (defun shen.maxseq () (value *maximum-print-sequence-size*))
77
83
 
78
- (defun shen.iter-list (V2254 V2255 V2256) (cond ((= () V2254) "") ((= 0 V2256) "... etc") ((and (cons? V2254) (= () (tl V2254))) (shen.arg->str (hd V2254) V2255)) ((cons? V2254) (@s (shen.arg->str (hd V2254) V2255) (@s " " (shen.iter-list (tl V2254) V2255 (- V2256 1))))) (true (@s "|" (@s " " (shen.arg->str V2254 V2255))))))
84
+ (defun shen.iter-list (V2262 V2263 V2264) (cond ((= () V2262) "") ((= 0 V2264) "... etc") ((and (cons? V2262) (= () (tl V2262))) (shen.arg->str (hd V2262) V2263)) ((cons? V2262) (@s (shen.arg->str (hd V2262) V2263) (@s " " (shen.iter-list (tl V2262) V2263 (- V2264 1))))) (true (@s "|" (@s " " (shen.arg->str V2262 V2263))))))
79
85
 
80
- (defun shen.str->str (V2261 V2262) (cond ((= shen.a V2262) V2261) (true (@s (n->string 34) (@s V2261 (n->string 34))))))
86
+ (defun shen.str->str (V2269 V2270) (cond ((= shen.a V2270) V2269) (true (@s (n->string 34) (@s V2269 (n->string 34))))))
81
87
 
82
- (defun shen.vector->str (V2263 V2264) (if (shen.print-vector? V2263) ((<-address V2263 0) V2263) (if (vector? V2263) (@s "<" (@s (shen.iter-vector V2263 1 V2264 (shen.maxseq)) ">")) (@s "<" (@s "<" (@s (shen.iter-vector V2263 0 V2264 (shen.maxseq)) ">>"))))))
88
+ (defun shen.vector->str (V2271 V2272) (if (shen.print-vector? V2271) ((<-address V2271 0) V2271) (if (vector? V2271) (@s "<" (@s (shen.iter-vector V2271 1 V2272 (shen.maxseq)) ">")) (@s "<" (@s "<" (@s (shen.iter-vector V2271 0 V2272 (shen.maxseq)) ">>"))))))
83
89
 
84
- (defun shen.print-vector? (V2265) (let Zero (<-address V2265 0) (if (= Zero shen.tuple) true (if (= Zero shen.pvar) true (if (not (number? Zero)) (shen.fbound? Zero) false)))))
90
+ (defun shen.print-vector? (V2273) (let Zero (<-address V2273 0) (if (= Zero shen.tuple) true (if (= Zero shen.pvar) true (if (not (number? Zero)) (shen.fbound? Zero) false)))))
85
91
 
86
- (defun shen.fbound? (V2266) (trap-error (do (ps V2266) true) (lambda E false)))
92
+ (defun shen.fbound? (V2274) (trap-error (do (ps V2274) true) (lambda E false)))
87
93
 
88
- (defun shen.tuple (V2267) (cn "(@p " (shen.app (<-address V2267 1) (cn " " (shen.app (<-address V2267 2) ")" shen.s)) shen.s)))
94
+ (defun shen.tuple (V2275) (cn "(@p " (shen.app (<-address V2275 1) (cn " " (shen.app (<-address V2275 2) ")" shen.s)) shen.s)))
89
95
 
90
- (defun shen.iter-vector (V2274 V2275 V2276 V2277) (cond ((= 0 V2277) "... etc") (true (let Item (trap-error (<-address V2274 V2275) (lambda E shen.out-of-bounds)) (let Next (trap-error (<-address V2274 (+ V2275 1)) (lambda E shen.out-of-bounds)) (if (= Item shen.out-of-bounds) "" (if (= Next shen.out-of-bounds) (shen.arg->str Item V2276) (@s (shen.arg->str Item V2276) (@s " " (shen.iter-vector V2274 (+ V2275 1) V2276 (- V2277 1)))))))))))
96
+ (defun shen.iter-vector (V2282 V2283 V2284 V2285) (cond ((= 0 V2285) "... etc") (true (let Item (trap-error (<-address V2282 V2283) (lambda E shen.out-of-bounds)) (let Next (trap-error (<-address V2282 (+ V2283 1)) (lambda E shen.out-of-bounds)) (if (= Item shen.out-of-bounds) "" (if (= Next shen.out-of-bounds) (shen.arg->str Item V2284) (@s (shen.arg->str Item V2284) (@s " " (shen.iter-vector V2282 (+ V2283 1) V2284 (- V2285 1)))))))))))
91
97
 
92
- (defun shen.atom->str (V2278) (trap-error (str V2278) (lambda E (shen.funexstring))))
98
+ (defun shen.atom->str (V2286) (trap-error (str V2286) (lambda E (shen.funexstring))))
93
99
 
94
100
  (defun shen.funexstring () (@s "" (@s "f" (@s "u" (@s "n" (@s "e" (@s (shen.arg->str (gensym (intern "x")) shen.a) "")))))))
95
101
 
96
- (defun shen.list? (V2279) (or (empty? V2279) (cons? V2279)))
102
+ (defun shen.list? (V2287) (or (empty? V2287) (cons? V2287)))
97
103
 
98
104
 
99
105
 
@@ -91,13 +91,13 @@
91
91
  (define l_interpreter
92
92
  {A --> B}
93
93
  _ -> (read_eval_print_loop (output "~%L interpreter ~%~%~%~%l-interp --> ~A~%"
94
- (normal_form (input+ : l_formula)))))
94
+ (normal_form (input+ l_formula)))))
95
95
 
96
96
  (define read_eval_print_loop
97
97
  {string --> A}
98
98
  _ -> (read_eval_print_loop
99
99
  (output "l-interp --> ~A~%"
100
- (normal_form (input+ : l_formula)))))
100
+ (normal_form (input+ l_formula)))))
101
101
 
102
102
  (define normal_form
103
103
  {l_formula --> l_formula}
@@ -163,10 +163,8 @@
163
163
  X -> (- X 1) where (number? X)
164
164
  _ -> "error!")
165
165
 
166
- \* (spy +) *\
167
-
168
166
  (define sub
169
- {[(pattern * l_formula)] --> l_formula --> l_formula}
167
+ {(list (pattern * l_formula)) --> l_formula --> l_formula}
170
168
  [] X -> X
171
169
  [(@p Var Val) | Assoc] X -> (sub Assoc (replace Var Val X)))
172
170
 
@@ -192,7 +190,7 @@
192
190
  _ _ -> [(@p no matching)])
193
191
 
194
192
  (define no_match?
195
- {[(pattern * l_formula)] --> boolean}
193
+ {(list (pattern * l_formula)) --> boolean}
196
194
  [(@p no matching)] -> true
197
195
  _ -> false)
198
196
 
@@ -23,12 +23,12 @@
23
23
  N -> (let More? (y-or-n? "~%Input assumptions? ")
24
24
  (if More?
25
25
  (do (output "~%~A. " N)
26
- [(input+ : wff) | (input-assumptions (+ N 1))])
26
+ [(input+ wff) | (input-assumptions (+ N 1))])
27
27
  [ ])))
28
28
 
29
29
  (define input-conclusion
30
30
  {A --> wff}
31
- _ -> (do (output "~%Enter conclusion: ") (input+ : wff)))
31
+ _ -> (do (output "~%Enter conclusion: ") (input+ wff)))
32
32
 
33
33
  (define proof-loop
34
34
  {(list sequent) --> proof --> proof}
@@ -70,7 +70,7 @@
70
70
 
71
71
  (define user-directive
72
72
  {A --> tactic}
73
- _ -> (do (output "~%Tactic: ") (input+ : tactic)))
73
+ _ -> (do (output "~%Tactic: ") (input+ tactic)))
74
74
 
75
75
  (define back
76
76
  {(list sequent) --> (list sequent)}
@@ -34,7 +34,7 @@
34
34
  _ -> (cartprod [2 3 4 5 6 7 8 9 10 11 12 13 14] [c d h s]))
35
35
 
36
36
  (define cartprod
37
- {[A] --> [B] --> [(A * B)]}
37
+ {(list A) --> (list B) --> (list (A * B))}
38
38
  [] _ -> []
39
39
  [X | Y] Z -> (append (map (/. W (@p X W)) Z) (cartprod Y Z)))
40
40
 
@@ -223,7 +223,7 @@
223
223
  {(list card) --> card}
224
224
  Cards -> (do (output "~%Your hand is ~%~%")
225
225
  (show-cards 1 Cards)
226
- (let N (input+ : number)
226
+ (let N (input+ number)
227
227
  (if (in-range? N Cards)
228
228
  (nth N Cards)
229
229
  (play-player Cards)))))
data/shen-ruby.gemspec CHANGED
@@ -7,12 +7,12 @@ Gem::Specification.new do |s|
7
7
  s.name = "shen-ruby"
8
8
  s.version = ShenRuby::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
- s.license = "Shen License and MIT License. See README.md for details."
10
+ s.license = "Shen License"
11
11
  s.authors = ["Greg Spurrier", "Mark Tarver"]
12
12
  s.email = ["greg@sourcematters.org"]
13
13
  s.homepage = "https://github.com/gregspurrier/shen-ruby"
14
14
  s.summary = %q{ShenRuby is a Ruby port of the Shen programming language}
15
- s.description = %q{ShenRuby is a port of the Shen programming language to Ruby. It currently supports Shen version 12.}
15
+ s.description = %q{ShenRuby is a port of the Shen programming language to Ruby. It currently supports Shen version 13.}
16
16
 
17
17
  s.required_ruby_version = ">= 1.9.3"
18
18
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shen-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Greg Spurrier
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-07-04 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,13 +21,12 @@ dependencies:
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
30
27
  version: '2.12'
31
28
  description: ShenRuby is a port of the Shen programming language to Ruby. It currently
32
- supports Shen version 12.
29
+ supports Shen version 13.
33
30
  email:
34
31
  - greg@sourcematters.org
35
32
  executables:
@@ -170,29 +167,28 @@ files:
170
167
  - spec/spec_helper.rb
171
168
  homepage: https://github.com/gregspurrier/shen-ruby
172
169
  licenses:
173
- - Shen License and MIT License. See README.md for details.
170
+ - Shen License
171
+ metadata: {}
174
172
  post_install_message:
175
173
  rdoc_options: []
176
174
  require_paths:
177
175
  - lib
178
176
  - shen/lib
179
177
  required_ruby_version: !ruby/object:Gem::Requirement
180
- none: false
181
178
  requirements:
182
- - - ! '>='
179
+ - - '>='
183
180
  - !ruby/object:Gem::Version
184
181
  version: 1.9.3
185
182
  required_rubygems_version: !ruby/object:Gem::Requirement
186
- none: false
187
183
  requirements:
188
- - - ! '>='
184
+ - - '>='
189
185
  - !ruby/object:Gem::Version
190
186
  version: '0'
191
187
  requirements: []
192
188
  rubyforge_project:
193
- rubygems_version: 1.8.23
189
+ rubygems_version: 2.0.3
194
190
  signing_key:
195
- specification_version: 3
191
+ specification_version: 4
196
192
  summary: ShenRuby is a Ruby port of the Shen programming language
197
193
  test_files:
198
194
  - spec/kl/cons_spec.rb