zfiles.doc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ZFILES contains 2 packages --
  2. (1) YFILES -- useful functions for accessing files.
  3. (2) YTOPCOM -- useful functions for compiling files.
  4. %%%% YFILES -- BASIC FILE ACCESSING UTILITIES
  5. File descriptor is a canonical FILE name, gets converted to file
  6. string:
  7. FILE or (FILE) -> "FILE.LSP"
  8. (FILE.EXT) -> "File.Ext"
  9. (DIR FILE) -> "<Dir>File.LSP"
  10. (DIR FILE EXT) -> "<dir>File.Ext"
  11. "xxx" -> "xxx"
  12. ---------------------------------------------------------------
  13. FORM-FILE ( FILE:DSCR ): filename EXPR
  14. GRABBER ( SELECTION FILE:DSCR ): NIL EXPR
  15. DUMPER ( FILE:DSCR ): NIL EXPR
  16. DUMPFNS-DE ( SELECTION FILE:DSCR ): NIL EXPR
  17. DUMP-REMAINING ( SELECTION:list DUMPED:list ): NIL EXPR
  18. FCOPY ( IN:DSCR OUT:DSCR filedscrs ):boolean EXPR
  19. REFPRINT-FOR-GRAB-CTL( #X: any ):NIL EXPR
  20. G:CREFON Switched on by cross reference program CREF:FILE
  21. G:JUST:FNS Save only fn names in variable whose name is the first
  22. field of filename if T, O/W save all exprs in that variable
  23. G:FILES List of files read into LISP
  24. G:SHOW:TRACE Turns backtrace in ERRORSET on if T
  25. G:SHOW:ERRORS Prints ERRORSET error messages if T
  26. GRAB( <file description> ) MACRO
  27. ===> (GRABBER NIL '<file-dscr>)
  28. Reads in entire file, whose system name is created using
  29. conventions described in FORM-FILE. See ZMACROS.
  30. GRABFNS( <ids> . <file description> ) MACRO
  31. ===> (GRABBER IDS <file-dscr>)
  32. Like GRAB, but only reads in specified ids. See ZMACROS.
  33. FORM-FILE( FILE:DSCR ): filename EXPR
  34. ---------
  35. Takes a file dscr, possibly NIL, and returns a file name
  36. corresponding to that dscr and suitable as an argument to OPEN.
  37. F:OLD:FILE is set to this file name for future reference.
  38. Meanwhile, F:FILE:ID is set to a lisp identifier, and the file
  39. name is put on the OPEN:FILE:NAME property of that identifier.
  40. The identifier can be used to hold info about the file.
  41. E.g. its value may be a list of objects read from the file.
  42. NB: FORM-FILE is at the lowest level of machine-independant code.
  43. MAKE-OPEN-FILE-NAME is a system dependant routine that creates
  44. file names specifically tailored to the version of SLISP in use.
  45. GRABBER( SELECTION:id-list FILE:DSCR ):T EXPR
  46. -------
  47. Opens the specified file, applies GRAB-EVAL-CTL to each
  48. expression on it, and then closes it. Returns T.
  49. See GRAB-EVAL-CTL for important side effects.
  50. GRAB-EVAL-CTL( #SELECTION EXPR#READ FILE#ID ) EXPR
  51. -------------
  52. Examines each expression read from file, and determines whether
  53. to EVAL that expression. Also decides whether to append the
  54. expression, or an id taken from it, or nothing at all, to the
  55. value of the file id poined at by FILE#ID.
  56. The file id is stored for use as an argument to DUMP or COMPILE,
  57. for example.
  58. Note: G:JUSTFNS suppresses the storage of comments from the file.
  59. When reading LAP files, no list of fns is made.
  60. DUMPER( FILE:DSCR : file-dscr ): NIL EXPR
  61. ------
  62. Dumps file onto disk. Filename as in GRABBER.
  63. Prettyprints the defined functions, set variables, and evaluated
  64. expressions which are members of the value of the variable filename.
  65. (For DEC versions:
  66. If IBASE neq 10, puts (SETQ IBASE current:base) at head of file.)
  67. DUMPFNS-DE( FNS FILE:DSCR ): NIL EXPR
  68. ----------
  69. Like DUMPER. Copies old file, putting new definitions for specified
  70. functions/variables.
  71. E.g.: (DUMPFNS-DE '(A B) '(FOO)) will first copy verbatim all the
  72. expressions on FOO.LSP which do not define A or B.
  73. Then the core definitions of A and B are dumped onto the file.
  74. DUMP-REMAINING( SELECTION:list DUMPED:list ) EXPR
  75. --------------
  76. Taken out of DUMPFNS for ease of reading.
  77. Dumps those properties of items in selection which have not
  78. already been dumped.
  79. FCOPY( IN:DSCR filename, OUT:DSCR filename ):boolean EXPR
  80. -----
  81. Reformats file using the prettyprinter. Useful for removing
  82. angle brackets or for tightening up function format.
  83. Returns T on normal exit, NIL if error reading file.
  84. FCOPY-SQ ( IN:DSCR filename, OUT:DSCR filename ):boolean EXPR
  85. -----
  86. Reformats file using the compacting printer. Letterizes
  87. and reports via '<big>' message long strings.
  88. Returns T on normal exit, NIL if error reading file.
  89. YTOPCOM -- Compiler Control functions
  90. (DF COMPILE-FILE (FILE:NAME)
  91. (DF COMPILE-IN-CORE (FILE:NAME)
  92. Commonly used globals. Declared in this file so each individual
  93. file doesn't have to declare them.
  94. "Other globals/fluids
  95. "This flag is checked by COMPILE-FILE.
  96. PPLAP( MODE CODE ) EXPR
  97. -----
  98. Prints the lap code in some appropriate format.
  99. Currently uses PRIN1SQ (PRIN1, Safe, use apostrophe to Quote
  100. non-numeric expressions).
  101. COMPILE-FILE( FILE:DSCR ) FEXPR
  102. ------------
  103. Reads the given file, and creates a corresponding LAP file.
  104. Each expression on the original file is mapped into an expression
  105. on the LAP file.
  106. Comments map into NIL.
  107. Function definitions map into the corresponding LAP code.
  108. These definitions are compiled, but NOT evaluated -- hence the
  109. functions will not be loaded into this core image by this routine.
  110. All other expressions are evaluated in an errorset then copied verbatim.
  111. EXCEPTION: UNFLUID is evalutated, but converted into a comment
  112. when printed, to avoid confusing loader.
  113. COMPILE-IN-CORE( FILE:DSCR ):NIL FEXPR
  114. ---------------
  115. Compiles all EXPRS and FEXPRS on a file and loads compiled code into
  116. core. Creates a file FILE:NAME.cpl which is a compilation log
  117. consisting of the names of functions compiled and the space used in
  118. their loading.
  119. GCMSG( X:boolean ):any EXPR
  120. -----
  121. Pre-defined in both SLISP and new IBM intpreter, so this cde shouln't
  122. do anything. GCMSG turns the garbage collection msgs on or off.