compat.sl 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. % Compat.sl. Useful definitions for Reduce PSL versions.
  2. % Author: Winfried Neun.
  3. (compiletime
  4. (progn
  5. (load defmacro bind-macros strings backquote)
  6. (defmacro def-pass-1-reform (name args . body)
  7. (let ((fcn-name (intern (string-concat "PA1R-" (id2string name)))))
  8. `(progn
  9. (put (quote ,name) (quote pass-1-reform) (quote ,fcn-name))
  10. (defmacro ,fcn-name ,args ,@body)
  11. )))
  12. ))
  13. (def-pass-1-reform digit (u)
  14. `((lambda ( ($local $$x$$)) (eq (quote 1) (field
  15. (wand (wdifference (quote 8#057)
  16. (field ($local $$x$$) ',infstartingbit ',infbitlength))
  17. (wdifference
  18. (field ($local $$x$$) ',infstartingbit ',infbitlength)
  19. (quote 8#072)))
  20. '0 '1))) ,u))
  21. (def-pass-1-reform orderp (u v)
  22. `(not (wgreaterp (field ,u ',infstartingbit ',infbitlength)
  23. (field ,v ',infstartingbit ',infbitlength))))
  24. (def-pass-1-reform flagp** (u v)
  25. `(flagp ,u ,v))
  26. (def-pass-1-reform terminalp ()
  27. '(and ($fluid !*int) (null ($fluid ifl!*))))
  28. (def-pass-1-reform liter (u)
  29. `((lambda (($local &u&) ($local &infu&))
  30. (eq '0 (wor (wxor
  31. (field ($local &u&) ',tagstartingbit ',infstartingbit) ',id-tag)
  32. (wshift
  33. (wand (wor (wdifference ($local &infu&) '8#141) % a
  34. (wdifference '8#172 ($local &infu&))) % z
  35. (wor (wdifference ($local &infu&) '8#101) % A
  36. (wdifference '8#132 ($local &infu&))) % Z
  37. ) '-31)))) ,u (field ,u ',infstartingbit ',infbitlength)))
  38. (def-pass-1-reform length (u)
  39. % length (length (explode x)) -> (flatsize x)
  40. (when (eqcar u 'explode) `(flatsize ,(cadr u))))
  41. (def-pass-1-reform lengthc (u)
  42. `(flatsize2 ,u))
  43. (compiletime
  44. (defmacro def-pass-1-macro (name args . body)
  45. (let ((fcn-name (intern (string-concat "PA1M-" (id2string name)))))
  46. `(progn
  47. (put (quote ,name) (quote pass-1-macro) (quote ,fcn-name))
  48. (defmacro ,fcn-name ,args ,@body)
  49. ))))
  50. (def-pass-1-macro flagpcar (u v)
  51. `((lambda (&&u&&)
  52. (and (null (atom &&u&&))
  53. (idp (car &&u&&))
  54. (flagp (car &&u&&) ,v) )) ,u ))
  55. (def-pass-1-macro lispapply(w v)
  56. `((lambda(&&u&&)
  57. (cond ((not (atom &&u&&))
  58. (rerror 'rlisp '2 (list '"Apply called with non-id arg" &&u&&)))
  59. (t (apply &&u&& ,v)))) ,w))
  60. (def-pass-1-reform apply1(u v)
  61. `(apply ,u (list ,v)))
  62. (def-pass-1-reform apply2(u v w)
  63. `(apply ,u (list ,v ,w)))
  64. (def-pass-1-reform apply3(u v w x)
  65. `(apply ,u (list ,v ,w ,x)))
  66. (def-pass-1-reform lispeval (u) `(eval ,u))