bquote.red 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. module bquote; % Support for backquote.
  2. % Author: Anthony C. Hearn.
  3. % Copyright (c) 1993 The RAND Corporation. All rights reserved.
  4. % Lisp parsing case.
  5. symbolic procedure tokbquote;
  6. begin
  7. crchar!* := readch1();
  8. nxtsym!* := list('backq,rread());
  9. ttype!* := 3;
  10. return nxtsym!*
  11. end;
  12. put('!`,'tokprop,'tokbquote);
  13. put('backq,'formfn,'formbquote);
  14. symbolic procedure formbquote(u,vars,mode); mkbquote cadr u;
  15. symbolic procedure mkbquote u;
  16. % Returns the "unevaled" form of u.
  17. if null u or constantp u then u
  18. else if atom u then mkquote u
  19. else if car u eq 'quote
  20. then if cadr u eq '!# then rederr "Invalid use of # after '"
  21. else mkquote u
  22. else if car u eq 'listify then mkbquote cdr u
  23. else if car u eq '!#
  24. then if eqcar(cdr u,'!@)
  25. then if null cdddr u then caddr u
  26. else list('append,caddr u,mkbquote cdddr u)
  27. else list('cons,cadr u,mkbquote cddr u)
  28. else if car u eq '!@ then rederr "Invalid use of @"
  29. else list('cons,mkbquote car u,mkbquote cdr u);
  30. % Rlisp parsing case.
  31. put('backquote,'stat,'bquotstat);
  32. symbolic procedure bquotstat; list('backquote,rl2l cadr rlis());
  33. symbolic procedure rl2l u;
  34. if atom u then u
  35. else if atom car u then car u . rl2l cdr u
  36. else if caar u eq 'hash or caar u eq '!#
  37. then if eqcar(cadar u,'!@)
  38. then '!# . '!@ . cadr cadar u . rl2l cdr u
  39. else '!# . cadar u . rl2l cdr u
  40. else rl2l car u . rl2l cdr u;
  41. put('backquote,'formfn,'formbquote);
  42. endmodule;
  43. end;