templt.red 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. module templt; %% GENTRAN Template Processing Routines %%
  2. %% Author: Barbara L. Gates %%
  3. %% December 1986 %%
  4. % Entry Points: ProcCTem, ProcFortTem, ProcRatTem
  5. % Moved to separate language modules - JHD December 1987
  6. symbolic$
  7. % User-Accessible Global Variables %
  8. global '(gentranlang!* !$!#)$
  9. fluid '(!*gendecs)$
  10. share gentranlang!*, !$!#$
  11. gentranlang!* := 'fortran$
  12. !$!# := 0$
  13. switch gendecs$
  14. global '(!*space!* !*stdout!* !$eof!$ !$eol!$)$
  15. % GENTRAN Global Variables %
  16. !*space!* := '! $
  17. fluid '(!*mode)$
  18. %% %%
  19. %% Text Processing Routines %%
  20. %% %%
  21. %% %%
  22. %% Template File Active Part Handler %%
  23. %% %%
  24. symbolic procedure procactive;
  25. % active parts: ;BEGIN; ... ;END; %
  26. % eof markers: ;END; %
  27. begin scalar c, buf, mode, och, !*int,!*errcont;
  28. % By turning INT off we avoid some excess blank lines, and avoid trouble
  29. % with END being caught by BEGIN1. We use !*errcont to recover
  30. % gracefully when an error is caught in the template.
  31. !*errcont := 't;
  32. c := readch();
  33. if c eq 'e then
  34. if (c := readch()) eq 'n then
  35. if (c := readch()) eq 'd then
  36. if (c := readch()) eq '!; then
  37. return !$eof!$
  38. else buf := '!;end
  39. else buf := '!;en
  40. else buf := '!;e
  41. else if c eq 'b then
  42. if (c := readch()) eq 'e then
  43. if (c := readch()) eq 'g then
  44. if (c := readch()) eq 'i then
  45. if (c := readch()) eq 'n then
  46. if (c := readch()) eq '!; then
  47. <<
  48. mode := !*mode;
  49. !*mode := 'algebraic;
  50. och := wrs cdr !*stdout!*;
  51. begin1();
  52. wrs och;
  53. !*mode := mode;
  54. linelength 150;
  55. return if (c := readch()) eq !$eol!$
  56. then readch()
  57. else c
  58. >>
  59. else buf := '!;begin
  60. else buf := '!;begi
  61. else buf := '!;beg
  62. else buf := '!;be
  63. else buf := '!;b
  64. else buf := '!;;
  65. pprin2 buf;
  66. return c
  67. end$
  68. endmodule;
  69. end;