extras.lsp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. (de oem!-supervisor nil (print (eval (read))))
  2. (de break!-loop (a)
  3. (prog (prompt ifile ofile u v)
  4. (setq ifile (rds !*debug!-io!*))
  5. (setq ofile (wrs !*debug!-io!*))
  6. (setq prompt (setpchar "Break loop (:X exits)> "))
  7. top (setq u (read))
  8. (cond
  9. ((equal u '!:x) (go exit))
  10. ((equal u '!:q)
  11. (progn
  12. (enable!-backtrace nil)
  13. (princ "Backtrace now disabled")
  14. (terpri)))
  15. ((equal u '!:v)
  16. (progn
  17. (enable!-backtrace t)
  18. (princ "Backtrace now enabled")
  19. (terpri)))
  20. (t (progn
  21. (cond
  22. ((null u) (setq v nil))
  23. (t (setq v (errorset u nil nil))))
  24. (cond
  25. ((atom v)
  26. (progn
  27. (princ ":Q quietens backtrace")
  28. (terpri)
  29. (princ ":V enables backtrace")
  30. (terpri)
  31. (princ ":X exits from break loop")
  32. (terpri)
  33. (princ "else form for evaluation")
  34. (terpri)
  35. nil))
  36. (t (progn (prin "=> ") (prinl (car v)) (terpri)))) )))
  37. (go top)
  38. exit (rds ifile)
  39. (wrs ofile)
  40. (setpchar prompt)
  41. (return nil)))
  42. (global '(s!:gensym!-serial))
  43. (setq s!:gensym!-serial 0)
  44. (de s!:stamp (n)
  45. (cond
  46. ((lessp n 0) (append (s!:stamp (minus n)) '(!-)))
  47. ((equal n 0) nil)
  48. (t (cons
  49. (schar "0123456789abcdefghijklmnopqrstuvwxyz" (remainder n 36))
  50. (s!:stamp (truncate n 36)))) ))
  51. (de dated!-name (base)
  52. (intern
  53. (list!-to!-string
  54. (append
  55. (explodec base)
  56. (cons
  57. '!_
  58. (append
  59. (reverse (s!:stamp (datestamp)))
  60. (cons
  61. '!_
  62. (explodec
  63. (setq s!:gensym!-serial
  64. (plus s!:gensym!-serial 1)))) ))) )))
  65. (de hashtagged!-name (base value)
  66. (intern
  67. (list!-to!-string
  68. (append (explodec base) (cons '!_ (s!:stamp (md60 value)))) )))
  69. (remflag '(sort sortip) 'lose)
  70. (de sort (l pred) (stable!-sortip (append l nil) pred))
  71. (de stable!-sort (l pred) (stable!-sortip (append l nil) pred))
  72. (de sortip (l pred) (stable!-sortip l pred))
  73. (de stable!-sortip (l pred)
  74. (prog (l1 l2 w)
  75. (cond ((null l) (return l)))
  76. (setq l1 l)
  77. (setq l2 (cdr l))
  78. (cond ((null l2) (return l)))
  79. (setq l (cdr l2))
  80. (cond
  81. ((null l)
  82. (progn
  83. (cond
  84. ((apply2 pred (car l2) (car l1))
  85. (progn
  86. (setq l (car l1))
  87. (rplaca l1 (car l2))
  88. (rplaca l2 l))))
  89. (return l1))))
  90. (setq l l1)
  91. (prog nil
  92. !G0 (cond
  93. ((not (and l2 (not (apply2 pred (car l2) (car l)))) )
  94. (return nil)))
  95. (progn (setq l l2) (setq l2 (cdr l2)))
  96. (go !G0))
  97. (cond ((null l2) (return l1)))
  98. (setq l2 l1)
  99. (setq l (cddr l2))
  100. (prog nil
  101. !G1 (cond ((not (and l (cdr l))) (return nil)))
  102. (progn (setq l2 (cdr l2)) (setq l (cddr l)))
  103. (go !G1))
  104. (setq l l2)
  105. (setq l2 (cdr l2))
  106. (rplacd l nil)
  107. (setq l1 (stable!-sortip l1 pred))
  108. (setq l2 (stable!-sortip l2 pred))
  109. (setq l (setq w (list nil)))
  110. (prog nil
  111. !G2 (cond ((not (and l1 l2)) (return nil)))
  112. (progn
  113. (cond
  114. ((apply2 pred (car l2) (car l1))
  115. (progn (rplacd w l2) (setq w l2) (setq l2 (cdr l2))))
  116. (t (progn (rplacd w l1) (setq w l1) (setq l1 (cdr l1)))) ))
  117. (go !G2))
  118. (cond (l1 (setq l2 l1)))
  119. (rplacd w l2)
  120. (return (cdr l))))
  121. (fluid
  122. '(!*prinl!-visited!-nodes!*
  123. !*prinl!-index!*
  124. !*prinl!-fn!*
  125. !*loop!-print!*
  126. !*print!-array!*
  127. !*print!-length!*
  128. !*print!-level!*))
  129. (setq !*print!-length!* (setq !*print!-level!* nil))
  130. (setq !*prinl!-visited!-nodes!* (mkhash 10 0 1.5))
  131. (de s!:prinl0 (x !*prinl!-fn!*)
  132. (prog (!*prinl!-index!*)
  133. (setq !*prinl!-index!* 0)
  134. (unwind!-protect
  135. (progn (s!:prinl1 x 0) (s!:prinl2 x 0))
  136. (clrhash !*prinl!-visited!-nodes!*))
  137. (return x)))
  138. (de s!:prinl1 (x depth)
  139. (prog (w length)
  140. (cond
  141. ((and (fixp !*print!-level!*) (greaterp depth !*print!-level!*))
  142. (return nil)))
  143. (setq length 0)
  144. top (cond
  145. ((and (atom x) (not (simple!-vector!-p x)) (not (gensymp x)))
  146. (return nil))
  147. ((setq w (gethash x !*prinl!-visited!-nodes!*))
  148. (progn
  149. (cond
  150. ((equal w 0)
  151. (progn
  152. (setq !*prinl!-index!* (plus !*prinl!-index!* 1))
  153. (puthash
  154. x
  155. !*prinl!-visited!-nodes!*
  156. !*prinl!-index!*))))
  157. (return nil)))
  158. (t (progn
  159. (puthash x !*prinl!-visited!-nodes!* 0)
  160. (cond
  161. ((simple!-vector!-p x)
  162. (progn
  163. (cond
  164. (!*print!-array!*
  165. (progn
  166. (setq length (upbv x))
  167. (cond
  168. ((and
  169. (fixp !*print!-length!*)
  170. (lessp !*print!-length!* length))
  171. (setq length !*print!-length!*)))
  172. (prog (i)
  173. (setq i 0)
  174. lab (cond
  175. ((minusp (difference length i))
  176. (return nil)))
  177. (s!:prinl1 (getv x i) (plus depth 1))
  178. (setq i (plus2 i 1))
  179. (go lab)))) )))
  180. ((not (atom x))
  181. (progn
  182. (s!:prinl1 (car x) (plus depth 1))
  183. (cond
  184. ((and
  185. (fixp !*print!-length!*)
  186. (greaterp
  187. (setq length (plus length 1))
  188. !*print!-length!*))
  189. (return nil)))
  190. (setq x (cdr x))
  191. (go top)))) ))) ))
  192. (de s!:prinl2 (x depth)
  193. (cond
  194. ((and (fixp !*print!-level!*) (greaterp depth !*print!-level!*))
  195. (princ "#"))
  196. ((and (atom x) (not (simple!-vector!-p x)) (not (gensymp x)))
  197. (progn (funcall !*prinl!-fn!* x)))
  198. (t (prog (w length)
  199. (setq w (gethash x !*prinl!-visited!-nodes!*))
  200. (cond
  201. ((not (zerop w))
  202. (progn
  203. (cond
  204. ((lessp w 0)
  205. (progn
  206. (princ "#")
  207. (princ (minus w))
  208. (princ "#")
  209. (return nil)))
  210. (t (progn
  211. (puthash x !*prinl!-visited!-nodes!* (minus w))
  212. (princ "#")
  213. (princ w)
  214. (princ "=")))) )))
  215. (cond
  216. ((simple!-vector!-p x)
  217. (progn
  218. (princ "%(")
  219. (cond
  220. (!*print!-array!*
  221. (progn
  222. (setq length (upbv x))
  223. (cond
  224. ((and
  225. (fixp !*print!-length!*)
  226. (lessp !*print!-length!* length))
  227. (setq length !*print!-length!*)))
  228. (prog (i)
  229. (setq i 0)
  230. lab (cond
  231. ((minusp (difference length i))
  232. (return nil)))
  233. (progn
  234. (s!:prinl2 (getv x i) (plus depth 1))
  235. (cond
  236. ((not (equal i (upbv x)))
  237. (princ " "))))
  238. (setq i (plus2 i 1))
  239. (go lab))))
  240. (t (princ "...")))
  241. (princ ")")
  242. (return nil)))
  243. ((atom x) (return (funcall !*prinl!-fn!* x))))
  244. (princ "(")
  245. (setq length 0)
  246. loop (s!:prinl2 (car x) (plus depth 1))
  247. (setq x (cdr x))
  248. (cond
  249. ((atom x)
  250. (progn
  251. (cond
  252. ((simple!-vector!-p x)
  253. (progn
  254. (princ " . %(")
  255. (cond
  256. (!*print!-array!*
  257. (progn
  258. (setq length (upbv x))
  259. (cond
  260. ((and
  261. (fixp !*print!-length!*)
  262. (lessp
  263. !*print!-length!*
  264. length))
  265. (setq length !*print!-length!*)))
  266. (prog (i)
  267. (setq i 0)
  268. lab (cond
  269. ((minusp (difference length i))
  270. (return nil)))
  271. (progn
  272. (s!:prinl2
  273. (getv x i)
  274. (plus depth 1))
  275. (cond
  276. ((not (equal i (upbv x)))
  277. (princ " "))))
  278. (setq i (plus2 i 1))
  279. (go lab))))
  280. (t (princ "...")))
  281. (princ ")")))
  282. (x (progn (princ " . ") (funcall !*prinl!-fn!* x))))
  283. (return (princ ")")))) )
  284. (cond
  285. ((and
  286. (fixp !*print!-length!*)
  287. (greaterp (setq length (plus length 1)) !*print!-length!*))
  288. (return (princ " ...)"))))
  289. (setq w (gethash x !*prinl!-visited!-nodes!*))
  290. (cond
  291. ((not (equal w 0))
  292. (cond
  293. ((lessp w 0)
  294. (progn
  295. (princ " . #")
  296. (princ (minus w))
  297. (return (princ "#)"))))
  298. (t (progn
  299. (princ " . ")
  300. (s!:prinl2 x (plus depth 1))
  301. (return (princ ")")))) ))
  302. (t (princ " ")))
  303. (go loop)))) )
  304. (de printl (x) (progn (prinl x) (terpri) x))
  305. (de printcl (x) (progn (princl x) (terpri) x))
  306. (de princl (x) (s!:prinl0 x (function princ)))
  307. (de prinl (x) (s!:prinl0 x (function prin)))
  308. (de s!:format (dest fmt args)
  309. (prog (len c a res o)
  310. (cond
  311. ((not (null dest))
  312. (progn
  313. (cond
  314. ((equal dest 't) (setq o (wrs nil)))
  315. (t (setq o (wrs dest)))) )))
  316. (setq len (upbv fmt))
  317. (prog (i)
  318. (setq i 0)
  319. lab (cond ((minusp (difference len i)) (return nil)))
  320. (progn
  321. (setq c (schar fmt i))
  322. (cond
  323. ((equal c '!~)
  324. (progn
  325. (setq i (plus i 1))
  326. (setq c (char!-downcase (schar fmt i)))
  327. (cond
  328. ((equal c '!%)
  329. (cond
  330. ((null dest) (setq res (cons !$eol!$ res)))
  331. (t (terpri))))
  332. ((equal c '!~)
  333. (cond
  334. ((null dest) (setq res (cons '!~ res)))
  335. (t (princ '!~))))
  336. (t (progn
  337. (cond
  338. ((null args) (setq a nil))
  339. (t (progn
  340. (setq a (car args))
  341. (setq args (cdr args)))) )
  342. (cond
  343. ((equal c 'a)
  344. (cond
  345. ((null dest)
  346. (prog (k)
  347. (setq k (explode2 a))
  348. lab (cond ((null k) (return nil)))
  349. ((lambda (k)
  350. (setq res (cons k res)))
  351. (car k))
  352. (setq k (cdr k))
  353. (go lab)))
  354. (t (princ a))))
  355. ((equal c 's)
  356. (cond
  357. ((null dest)
  358. (prog (k)
  359. (setq k (explode a))
  360. lab (cond ((null k) (return nil)))
  361. ((lambda (k)
  362. (setq res (cons k res)))
  363. (car k))
  364. (setq k (cdr k))
  365. (go lab)))
  366. (t (prin a))))
  367. ((null dest)
  368. (prog (k)
  369. (setq k (explode a))
  370. lab (cond ((null k) (return nil)))
  371. ((lambda (k) (setq res (cons k res)))
  372. (car k))
  373. (setq k (cdr k))
  374. (go lab)))
  375. (t (prin (list '!?!?!? c a)))) ))) ))
  376. (t (progn
  377. (cond
  378. ((null dest) (setq res (cons c res)))
  379. (t (princ c)))) )))
  380. (setq i (plus2 i 1))
  381. (go lab))
  382. (cond
  383. ((null dest) (return (list!-to!-string (reversip res))))
  384. (t (progn (wrs o) (return nil)))) ))
  385. (dm format (u) (list 's!:format (cadr u) (caddr u) (cons 'list (cdddr u))))
  386. (fluid
  387. '(bn bufferi buffero indblanks indentlevel initialblanks lmar pendingrpars
  388. rmar rparcount stack))
  389. (global '(!*quotes !*pretty!-symmetric thin!*))
  390. (setq !*pretty!-symmetric t)
  391. (setq !*quotes t)
  392. (setq thin!* 5)
  393. (de prettyprint (x) (progn (superprinm x (posn)) (terpri) nil))
  394. (de superprintm (x lmar) (progn (superprinm x lmar) (terpri) x))
  395. (de superprinm (x lmar)
  396. (prog (stack bufferi buffero bn initialblanks rmar pendingrpars indentlevel
  397. indblanks rparcount w)
  398. (setq bufferi (setq buffero (list nil)))
  399. (setq initialblanks 0)
  400. (setq rparcount 0)
  401. (setq indblanks 0)
  402. (setq rmar (linelength nil))
  403. (linelength 500)
  404. (cond
  405. ((lessp rmar 25)
  406. (error 0 (list rmar "Linelength too short for superprinting"))))
  407. (setq bn 0)
  408. (setq indentlevel 0)
  409. (cond ((geq (plus lmar 20) rmar) (setq lmar (difference rmar 21))))
  410. (setq w (posn))
  411. (cond ((greaterp w lmar) (progn (terpri) (setq w 0))))
  412. (cond ((lessp w lmar) (setq initialblanks (difference lmar w))))
  413. (s!:prindent x (plus lmar 3))
  414. (s!:overflow 'none)
  415. (linelength rmar)
  416. (return x)))
  417. (putc 's!:top 'smacro '(lambda nil (car stack)))
  418. (putc 's!:depth 'smacro '(lambda (frm) (car frm)))
  419. (putc 's!:indenting 'smacro '(lambda (frm) (cadr frm)))
  420. (putc 's!:blankcount 'smacro '(lambda (frm) (caddr frm)))
  421. (putc 's!:blanklist 'smacro '(lambda (frm) (cdddr frm)))
  422. (putc 's!:setindenting 'smacro '(lambda (frm val) (rplaca (cdr frm) val)))
  423. (putc 's!:setblankcount 'smacro '(lambda (frm val) (rplaca (cddr frm) val)))
  424. (putc 's!:setblanklist 'smacro '(lambda (frm val) (rplacd (cddr frm) val)))
  425. (putc 's!:newframe 'smacro '(lambda (n) (list n nil 0)))
  426. (putc 's!:blankp 'smacro '(lambda (char) (numberp (car char))))
  427. (de s!:prindent (x n)
  428. (cond
  429. ((atom x)
  430. (cond
  431. ((simple!-vector!-p x) (s!:prvector x n))
  432. (t (prog (c)
  433. (setq c
  434. (cond
  435. (!*pretty!-symmetric
  436. (cond
  437. ((stringp x) (s!:explodes x))
  438. (t (explode x))))
  439. (t (explode2 x))))
  440. lab (cond ((null c) (return nil)))
  441. ((lambda (c) (s!:putch c)) (car c))
  442. (setq c (cdr c))
  443. (go lab)))) )
  444. ((s!:quotep x) (progn (s!:putch '!') (s!:prindent (cadr x) (plus n 1))))
  445. (t (prog (cx)
  446. (cond
  447. ((greaterp (times 4 n) (times 3 rmar))
  448. (progn
  449. (s!:overflow 'all)
  450. (setq n (truncate n 8))
  451. (cond
  452. ((greaterp initialblanks n)
  453. (progn
  454. (setq lmar
  455. (plus (difference lmar initialblanks) n))
  456. (setq initialblanks n)))) )))
  457. (setq stack (cons (list n nil 0) stack))
  458. (s!:putch (cons 'lpar (car stack)))
  459. (setq cx (car x))
  460. (s!:prindent cx (plus n 1))
  461. (cond
  462. ((and (idp cx) (not (atom (cdr x))))
  463. (setq cx (get cx 's!:ppformat)))
  464. (t (setq cx nil)))
  465. (cond ((and (equal cx 2) (atom (cddr x))) (setq cx nil)))
  466. (cond
  467. ((equal cx 'prog)
  468. (progn
  469. (s!:putch '! )
  470. (s!:prindent (car (setq x (cdr x))) (plus n 3)))) )
  471. (setq x (cdr x))
  472. scan (cond ((atom x) (go outt)))
  473. (s!:finishpending)
  474. (cond
  475. ((equal cx 'prog)
  476. (progn
  477. (s!:putblank)
  478. (s!:overflow bufferi)
  479. (cond
  480. ((atom (car x))
  481. (progn
  482. (setq lmar
  483. (setq initialblanks
  484. (max (difference lmar 6) 0)))
  485. (s!:prindent (car x) (difference n 3))
  486. (setq x (cdr x))
  487. (cond
  488. ((and (not (atom x)) (atom (car x)))
  489. (go scan)))
  490. (cond
  491. ((greaterp (plus lmar bn) n) (s!:putblank))
  492. (t (prog (i)
  493. (setq i (plus lmar bn))
  494. lab (cond
  495. ((minusp
  496. (difference (difference n 1) i))
  497. (return nil)))
  498. (s!:putch '! )
  499. (setq i (plus2 i 1))
  500. (go lab))))
  501. (cond ((atom x) (go outt)))) ))) )
  502. ((numberp cx)
  503. (progn
  504. (setq cx (difference cx 1))
  505. (cond ((equal cx 0) (setq cx nil)))
  506. (s!:putch '! )))
  507. (t (s!:putblank)))
  508. (s!:prindent (car x) (plus n 3))
  509. (setq x (cdr x))
  510. (go scan)
  511. outt (cond
  512. ((not (null x))
  513. (progn
  514. (s!:finishpending)
  515. (s!:putblank)
  516. (s!:putch '!.)
  517. (s!:putch '! )
  518. (s!:prindent x (plus n 5)))) )
  519. (s!:putch (cons 'rpar (difference n 3)))
  520. (cond
  521. ((and
  522. (equal (cadr (car stack)) 'indent)
  523. (not (null (cdddr (car stack)))) )
  524. (s!:overflow (car (cdddr (car stack)))) )
  525. (t (s!:endlist (car stack))))
  526. (setq stack (cdr stack)))) ))
  527. (de s!:explodes (x) (explode x))
  528. (de s!:prvector (x n)
  529. (prog (bound)
  530. (setq bound (upbv x))
  531. (setq stack (cons (list n nil 0) stack))
  532. (s!:putch (cons 'lsquare (car stack)))
  533. (s!:prindent (getv x 0) (plus n 3))
  534. (prog (i)
  535. (setq i 1)
  536. lab (cond ((minusp (difference bound i)) (return nil)))
  537. (progn
  538. (s!:putch '!,)
  539. (s!:putblank)
  540. (s!:prindent (getv x i) (plus n 3)))
  541. (setq i (plus2 i 1))
  542. (go lab))
  543. (s!:putch (cons 'rsquare (difference n 3)))
  544. (s!:endlist (car stack))
  545. (setq stack (cdr stack))))
  546. (de s!:putblank nil
  547. (prog nil
  548. (s!:putch (car stack))
  549. (rplaca (cddr (car stack)) (plus (caddr (car stack)) 1))
  550. (rplacd (cddr (car stack)) (cons bufferi (cdddr (car stack))))
  551. (setq indblanks (plus indblanks 1))))
  552. (de s!:endlist (l) (setq pendingrpars (cons l pendingrpars)))
  553. (de s!:finishpending nil
  554. (progn
  555. (prog (stackframe)
  556. (setq stackframe pendingrpars)
  557. lab (cond ((null stackframe) (return nil)))
  558. ((lambda (stackframe)
  559. (progn
  560. (cond
  561. ((neq (cadr stackframe) 'indent)
  562. (prog (b)
  563. (setq b (cdddr stackframe))
  564. lab (cond ((null b) (return nil)))
  565. ((lambda (b)
  566. (progn
  567. (rplaca b '! )
  568. (setq indblanks (difference indblanks 1))))
  569. (car b))
  570. (setq b (cdr b))
  571. (go lab))))
  572. (rplacd (cddr stackframe) t)))
  573. (car stackframe))
  574. (setq stackframe (cdr stackframe))
  575. (go lab))
  576. (setq pendingrpars nil)))
  577. (de s!:quotep (x)
  578. (and !*quotes (not (atom x)) (equal (car x) 'quote) (not (atom (cdr x)))
  579. (null (cddr x))))
  580. (put 'prog 's!:ppformat 'prog)
  581. (put 'lambda 's!:ppformat 1)
  582. (put 'lambdaq 's!:ppformat 1)
  583. (put 'setq 's!:ppformat 1)
  584. (put 'set 's!:ppformat 1)
  585. (put 'while 's!:ppformat 1)
  586. (put 't 's!:ppformat 1)
  587. (put 'de 's!:ppformat 2)
  588. (put 'df 's!:ppformat 2)
  589. (put 'dm 's!:ppformat 2)
  590. (put 'defun 's!:ppformat 2)
  591. (put 'defmacro 's!:ppformat 2)
  592. (put 'foreach 's!:ppformat 4)
  593. (de s!:putch (c)
  594. (prog nil
  595. (cond
  596. ((atom c) (setq rparcount 0))
  597. ((numberp (car c)) (progn (setq rparcount 0) (go nocheck)))
  598. ((equal (car c) 'rpar)
  599. (progn
  600. (setq rparcount (plus rparcount 1))
  601. (cond
  602. ((greaterp rparcount 4)
  603. (progn (s!:putch '! ) (setq rparcount 2)))) ))
  604. (t (setq rparcount 0)))
  605. (prog nil
  606. !G3 (cond ((not (geq (plus lmar bn) rmar)) (return nil)))
  607. (s!:overflow 'more)
  608. (go !G3))
  609. nocheck
  610. (setq bufferi (cdr (rplacd bufferi (list c))))
  611. (setq bn (plus bn 1))))
  612. (de s!:overflow (flg)
  613. (prog (c blankstoskip)
  614. (cond
  615. ((and
  616. (equal indblanks 0)
  617. (greaterp initialblanks 3)
  618. (equal flg 'more))
  619. (progn
  620. (setq initialblanks (difference initialblanks 3))
  621. (setq lmar (difference lmar 3))
  622. (return 'moved!-left))))
  623. fblank(cond
  624. ((equal bn 0)
  625. (progn
  626. (cond ((not (equal flg 'more)) (return 'empty)))
  627. (cond ((atom (car buffero)) (prin2 "%+")))
  628. (terpri)
  629. (setq lmar 0)
  630. (return 'continued)))
  631. (t (progn (spaces initialblanks) (setq initialblanks 0))))
  632. (setq buffero (cdr buffero))
  633. (setq bn (difference bn 1))
  634. (setq lmar (plus lmar 1))
  635. (setq c (car buffero))
  636. (cond
  637. ((atom c) (progn (prin2 c) (go fblank)))
  638. ((numberp (car c))
  639. (cond
  640. ((not (atom blankstoskip))
  641. (progn
  642. (prin2 '! )
  643. (setq indblanks (difference indblanks 1))
  644. (cond
  645. ((eq c (car blankstoskip))
  646. (progn
  647. (rplacd
  648. blankstoskip
  649. (difference (cdr blankstoskip) 1))
  650. (cond
  651. ((equal (cdr blankstoskip) 0)
  652. (setq blankstoskip t)))) ))
  653. (go fblank)))
  654. (t (go blankfound))))
  655. ((or (equal (car c) 'lpar) (equal (car c) 'lsquare))
  656. (progn
  657. (prin2 (get (car c) 's!:ppchar))
  658. (cond ((equal flg 'none) (go fblank)))
  659. (setq c (cdr c))
  660. (cond ((not (null (cdddr c))) (go fblank)))
  661. (cond
  662. ((greaterp (car c) indentlevel)
  663. (progn
  664. (setq indentlevel (car c))
  665. (rplaca (cdr c) 'indent))))
  666. (go fblank)))
  667. ((or (equal (car c) 'rpar) (equal (car c) 'rsquare))
  668. (progn
  669. (cond ((lessp (cdr c) indentlevel) (setq indentlevel (cdr c))))
  670. (prin2 (get (car c) 's!:ppchar))
  671. (go fblank)))
  672. (t (error 0 (list c "UNKNOWN TAG IN OVERFLOW"))))
  673. blankfound
  674. (cond ((eqcar (cdddr c) buffero) (rplacd (cddr c) nil)))
  675. (setq indblanks (difference indblanks 1))
  676. (cond
  677. ((greaterp (car c) indentlevel)
  678. (progn
  679. (cond ((equal flg 'none) (progn (prin2 '! ) (go fblank))))
  680. (cond
  681. (blankstoskip (setq blankstoskip nil))
  682. (t (progn
  683. (setq indentlevel (car c))
  684. (rplaca (cdr c) 'indent)))) )))
  685. (cond
  686. ((greaterp (caddr c) (difference thin!* 1))
  687. (progn
  688. (setq blankstoskip (cons c (difference (caddr c) 2)))
  689. (rplaca (cdr c) 'thin)
  690. (rplaca (cddr c) 1)
  691. (setq indentlevel (difference (car c) 1))
  692. (prin2 '! )
  693. (go fblank))))
  694. (rplaca (cddr c) (difference (caddr c) 1))
  695. (terpri)
  696. (setq lmar (setq initialblanks (car c)))
  697. (cond ((eq buffero flg) (return 'to!-flg)))
  698. (cond ((or blankstoskip (not (equal flg 'more))) (go fblank)))
  699. (return 'more)))
  700. (put 'lpar 's!:ppchar '!()
  701. (put 'lsquare 's!:ppchar '![)
  702. (put 'rpar 's!:ppchar '!))
  703. (put 'rsquare 's!:ppchar '!])
  704. (de fetch!-url (url !&optional dest)
  705. (prog (a b c d e w)
  706. (setq a (open!-url url))
  707. (cond ((null a) (return nil)))
  708. (cond
  709. (dest
  710. (progn
  711. (setq d (open dest 'output))
  712. (cond
  713. ((null d)
  714. (progn
  715. (close a)
  716. (return
  717. (error 0 "unable to open destination file")))) )
  718. (setq d (wrs d)))) )
  719. (setq b (rds a))
  720. (setq w (linelength 500))
  721. (prog nil
  722. !G4 (cond ((not (not (equal (setq c (readch)) !$eof!$))) (return nil)))
  723. (princ c)
  724. (go !G4))
  725. (linelength e)
  726. (rds b)
  727. (close a)
  728. (cond (dest (close (wrs d)))) ))