12-io.lpt 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425
  1. PSL Manual 7 February 1983 Input and Output
  2. section 12.0 page 12.1
  3. CHAPTER 12 CHAPTER 12 CHAPTER 12
  4. INPUT AND OUTPUT INPUT AND OUTPUT INPUT AND OUTPUT
  5. 12.1. Introduction . . . . . . . . . . . . . . . 12.1
  6. 12.2. The Underlying Primitives for Input and Output. . . . 12.1
  7. 12.3. Opening, Closing, and Selecting Channels. . . . . . 12.5
  8. 12.4. Functions for Printing. . . . . . . . . . . . 12.8
  9. 12.5. Functions for Reading . . . . . . . . . . . . 12.16
  10. 12.5.1. Reading S-Expression . . . . . . . . . . 12.16
  11. 12.5.2. Reading Files into PSL . . . . . . . . . 12.17
  12. 12.5.3. Reading Single Characters . . . . . . . . 12.20
  13. 12.5.4. Reading Tokens . . . . . . . . . . . . 12.21
  14. 12.5.5. Read Macros . . . . . . . . . . . . . 12.30
  15. 12.6. Scan Table Utility Functions. . . . . . . . . . 12.31
  16. 12.7. I/O to and from Lists and Strings . . . . . . . . 12.32
  17. 12.8. Example of Simple I/O in PSL. . . . . . . . . . 12.34
  18. 12.1. Introduction 12.1. Introduction 12.1. Introduction
  19. Most LISP programs are written with no sophisticated I/O, so this chapter
  20. may be skimmed by those with simple I/O requirements. Section
  21. 12.8 contains an example showing the use of some I/O functions. This
  22. should help the beginning PSL user get started. Sections 12.5 and
  23. 12.6 deal extensively with customizing the scanner and reader, which is of
  24. interest only to the sophisticated user.
  25. 12.2. The Underlying Primitives for Input and Output 12.2. The Underlying Primitives for Input and Output 12.2. The Underlying Primitives for Input and Output
  26. All input and output functions are implemented in terms of operations on
  27. 1
  28. _______ "channels". A channel is just a small integer which has 3 functions and
  29. some other information associated with it. The three functions are:
  30. a. A reading function, which is called with the channel as its
  31. _______ argument and returns the integer ASCII value of the next
  32. _______________
  33. 1
  34. The range of channel numbers is from 0 to MaxChannels, where MaxChannels
  35. is a system-dependent constant, currently 31, defined in IO-DATA.RED.
  36. MaxChannels is a WCONST, and is not available for use at runtime. Input and Output 7 February 1983 PSL Manual
  37. page 12.2 section 12.2
  38. character of the input stream. If the channel is for writing
  39. WriteOnlyChannel WriteOnlyChannel only, this function is WriteOnlyChannel. If the channel has not
  40. ChannelNotOpen ChannelNotOpen been opened, this function is ChannelNotOpen. The reading
  41. function is responsible for echoing characters if the flag
  42. WriteChar WriteChar !*ECHO is T. It should use the function WriteChar to echo the
  43. character. It may not be appropriate for a read function to
  44. echo characters. For example, the "disk" reading function does
  45. Compress Compress echoing, while the reader used to implement the Compress
  46. function does not.
  47. The read function must also be concerned with the handling of
  48. ends of "files" (actually, ends of channels) and ends of lines.
  49. It should return the ASCII code for an end of file character
  50. (system dependent) when reaching the end of a channel. It
  51. should return the ASCII code for a line feed character to
  52. indicate an end of line (or "newline"). This may require that
  53. the ASCII code for carriage return be ignored when read, not
  54. returned.
  55. b. A writing function, which is called with the channel as its
  56. _______ first argument and the integer ASCII value of the character to
  57. write as its second argument. If the channel is for reading
  58. ReadOnlyChannel ReadOnlyChannel only, this function is ReadOnlyChannel. If the channel has not
  59. ChannelNotOpen ChannelNotOpen been opened, this function is ChannelNotOpen.
  60. c. A closing function, which is called with the channel as its
  61. argument and performs any action necessary for the graceful
  62. termination of input and/or output operations to that channel.
  63. ChannelNotOpen ChannelNotOpen If the channel is not open, this function is ChannelNotOpen.
  64. The other information associated with a channel includes the current
  65. Posn Posn position in the output line (used by Posn), the maximum line length allowed
  66. LineLength LineLength (used by LineLength and the printing functions), the single character input
  67. backup buffer (used by the token scanner), and other system-dependent
  68. information.
  69. Ordinarily, the user need not be aware of the existence of this
  70. mechanism. However, because of its generality, it is possible to implement
  71. operations other than just reading from and writing to files using it. In
  72. Explode Compress Explode Compress particular, the LISP functions Explode and Compress are performed by
  73. ____ ____ writing to a list and reading from a list, respectively (on channels 3 and
  74. 4 respectively).
  75. Ordinarily, user interaction with the system is done by reading from the
  76. standard input channel and writing to the standard output channel. These
  77. are 0 and 1 respectively, to which the GLOBAL variables STDIN!* and
  78. STDOUT!* are bound. These channels usually refer to the user's terminal,
  79. and cannot be closed. Other files are accessed by calling the function
  80. Open Open Open, which returns a channel. Most functions which perform input and
  81. output come in two forms, one which takes a channel as its first argument,
  82. Rds Rds and one which uses the "currently selected channel". The functions Rds and PSL Manual 7 February 1983 Input and Output
  83. section 12.2 page 12.3
  84. Wrs Wrs Wrs are used to change the currently selected input and output channels.
  85. The GLOBAL variables IN!* and OUT!* are bound to these channels.
  86. GLOBAL variables containing information about channels are listed below.
  87. __________ ______ IN!* [Initially: 0] global
  88. Contains the currently selected input channel. This is changed
  89. Rds Rds by the function Rds.
  90. __________ ______ OUT!* [Initially: 1] global
  91. Contains the currently selected output channel. This is changed
  92. Wrs Wrs by the function Wrs.
  93. __________ ______ STDIN!* [Initially: 0] global
  94. The standard input channel.
  95. __________ ______ STDOUT!* [Initially: 1] global
  96. The standard output channel.
  97. __________ ______ BREAKIN!* [Initially: NIL] global
  98. BREAK BREAK The channel from which the BREAK loop gets its input. It has
  99. been set to default to STDIN!*, but may have to be changed on
  100. some systems with buffered-IO.
  101. __________ ______ BREAKOUT!* [Initially: NIL] global
  102. BREAK BREAK The channel to which the BREAK loop sends its output. It has
  103. been set to default to STDOUT!*, but may have to be changed on
  104. some systems with buffered-IO.
  105. __________ ______ HELPIN!* [Initially: NIL] global
  106. Help Help The channel used for input by the Help mechanism.
  107. __________ ______ HELPOUT!* [Initially: NIL] global
  108. Help Help The channel used for output by the Help mechanism. Input and Output 7 February 1983 PSL Manual
  109. page 12.4 section 12.2
  110. __________ ______ ERROUT!* [Initially: 1] global
  111. ErrorPrintF ErrorPrintF The channel used by the ErrorPrintF.
  112. __________ ______ PROMPTSTRING!* [Initially: "lisp>"] global
  113. Displayed as a prompt when any input is taken from TTY. Thus
  114. prompts should not be directly printed. Instead the value should
  115. be bound to PROMPTSTRING!*.
  116. 12.3. Opening, Closing, and Selecting Channels 12.3. Opening, Closing, and Selecting Channels 12.3. Opening, Closing, and Selecting Channels
  117. Open Open ________ ______ __________ __ _______ __ _______ ____ (Open FILENAME:string ACCESSTYPE:id): CHANNEL:io-channel expr
  118. Eq __________ Eq If ACCESSTYPE is Eq to INPUT or OUTPUT, an attempt is made to
  119. ________ access the system-dependent FILENAME for reading or writing. If
  120. the attempt is unsuccessful, an error is generated; otherwise a
  121. free channel is returned and initialized to the default
  122. conditions for ordinary file input or output.
  123. Eq __________ Eq If ACCESSTYPE is Eq to SPECIAL and the GLOBAL variables
  124. SPECIALREADFUNCTION!*, SPECIALWRITEFUNCTION!*, and
  125. __ SPECIALCLOSEFUNCTION!* are bound to ids, then a free channel is
  126. returned and its associated functions are set to the values of
  127. these variables. Other non system-dependent status is set to
  128. default conditions, which can later be overridden. The functions
  129. ReadOnlyChannel WriteOnlyChannel ReadOnlyChannel WriteOnlyChannel ReadOnlyChannel and WriteOnlyChannel are available as error
  130. ________ handlers. The parameter FILENAME is used only if an error
  131. occurs.
  132. [??? We should replace these globals and SPECIAL option by a [??? We should replace these globals and SPECIAL option by a [??? We should replace these globals and SPECIAL option by a
  133. (SPECIALOPEN Readfunction writefunction closefunction) call (SPECIALOPEN Readfunction writefunction closefunction) call (SPECIALOPEN Readfunction writefunction closefunction) call
  134. ???] ???] ???]
  135. If none of these conditions hold, a file is not available, or
  136. there are no free channels, an error is generated.
  137. ***** Unknown access type
  138. ***** Improperly set-up special IO open call
  139. ***** File not found
  140. ***** No free channels
  141. FileP FileP One can use FileP to find out whether a file exists. PSL Manual 7 February 1983 Input and Output
  142. section 12.3 page 12.5
  143. FileP FileP ____ ______ _______ ____ (FileP NAME:string): boolean expr
  144. ____ This function will return T if file NAME can be opened, and NIL
  145. if not, e.g. if it does not exist.
  146. Close Close _______ __ _______ __ _______ ____ (Close CHANNEL:io-channel): io-channel expr
  147. _______ The closing function associated with CHANNEL is called, with
  148. _______ _______ CHANNEL as its argument. If it is illegal to close CHANNEL, if
  149. _______ _______ CHANNEL is not open, or if CHANNEL is associated with a file and
  150. the file cannot be closed by the operating system, this function
  151. _______ generates an error. Otherwise, CHANNEL is marked as free and is
  152. returned.
  153. Shut Shut _ ______ ____ ________ _____ (Shut [L:string]): None Returned macro
  154. Shut _ Shut Closes the output files in the list L. Note that Shut takes file
  155. Close Close __ _______ names as arguments, while Close takes an io-channel. The RLISP
  156. IN IN IN function maintains a stack of file-name . io-channel
  157. shut shut associations for this purpose. Thus a shut will also correctly
  158. select the previous file for further output.
  159. EvShut EvShut _ ______ ____ ____ ________ ____ (EvShut L:string-list): none Returned expr
  160. Shut Shut Does the same as Shut but evaluates its arguments.
  161. Rds Rds _______ __ _______ ___ __ _______ ____ (Rds {CHANNEL:io-channel, NIL}): io-channel expr
  162. Rds Rds Rds sets IN!* to the value of its argument, and returns the
  163. previous value of IN!*. In addition, if SPECIALRDSACTION!* is
  164. non-NIL, it should be a function of 2 arguments, which is called
  165. _______ _______ with the old CHANNEL as its first argument and the new CHANNEL as
  166. Rds Rds Rds Rds its second argument. Rds(NIL) does the same as Rds(STDIN!*).
  167. Wrs Wrs _______ __ _______ ___ __ _______ ____ (Wrs {CHANNEL:io-channel, NIL}): io-channel expr
  168. Wrs Wrs Wrs sets OUT!* to the value of its argument and returns the
  169. previous value of OUT!*. In addition, if SPECIALWRSACTION!* is
  170. non-NIL, it should be a function of 2 arguments, which is called
  171. _______ _______ with the old CHANNEL as its first argument and the new CHANNEL as
  172. Wrs Wrs Wrs Wrs its second argument. Wrs(NIL) does the same as Wrs(STDOUT!*).
  173. Out Out _ ______ ____ ________ _____ (Out U:string): None Returned macro
  174. _ Opens file U for output, redirecting standard output. Note that
  175. Out Wrs Out ______ Wrs __ _______ Out takes a string as an argument, while Wrs takes an io-channel. Input and Output 7 February 1983 PSL Manual
  176. page 12.6 section 12.3
  177. EvOut EvOut _ ______ ____ ____ ________ ____ (EvOut L:string-list): None Returned expr
  178. _ L is a list containing one file name which must be a string.
  179. EvOut Out EvOut Out EvOut is the called by Out after evaluating its argument.
  180. The reading and writing functions come in two flavors: those that read or
  181. RDS WRS RDS WRS write to the current channel, as set by a previous RDS or WRS into IN!* or
  182. OUT!*, and those that explicitly designate the desired input or output
  183. Channel Channel channel. The latter typically have a Channel as part of their name.
  184. ________ The following GLOBALs are used by the functions in this section.
  185. __________ ______ SPECIALCLOSEFUNCTION!* [Initially: NIL] global
  186. __________ ______ SPECIALRDSACTION!* [Initially: NIL] global
  187. __________ ______ SPECIALREADFUNCTION!* [Initially: NIL] global
  188. __________ ______ SPECIALWRITEFUNCTION!* [Initially: NIL] global
  189. __________ ______ SPECIALWRSACTION!* [Initially: NIL] global
  190. 12.4. Functions for Printing 12.4. Functions for Printing 12.4. Functions for Printing
  191. ChannelWriteChar ChannelWriteChar _______ __ _______ __ _________ _________ ____ (ChannelWriteChar CHANNEL:io-channel CH:character): character expr
  192. _______ Write one character to CHANNEL. All output is defined in terms
  193. __ of this function. If CH is equal to char EOL (ASCII LF, 8#12)
  194. _______ the line counter POSN associated with CHANNEL is set to zero.
  195. Otherwise, it is increased by one. The writing function
  196. _______ _______ __ associated with CHANNEL is called with CHANNEL and CH as its
  197. arguments.
  198. WriteChar WriteChar __ _________ _________ ____ (WriteChar CH:character): character expr
  199. Write single character to current output.
  200. (de WRITECHAR (CH)
  201. (CHANNELWRITECHAR OUT!* CH)) PSL Manual 7 February 1983 Input and Output
  202. section 12.4 page 12.7
  203. ChannelPrin1 ChannelPrin1 ____ __ _______ ___ ___ ___ ___ ____ (ChannelPrin1 CHAN:io-channel ITM:any): ITM:any expr
  204. ChannelPrin1 ChannelPrin1 ChannelPrin1 is the basic LISP printing function. For
  205. well-formed, non-circular (non-self-referential) structures, the
  206. Read Read result can be parsed by the function Read.
  207. ______ - Strings are printed surrounded by double quotes (").
  208. __ - Delimiters inside ids are preceded by the escape character
  209. (!).
  210. _____ - Floats are printed as {-}nnn.nnn{E{-}nn}.
  211. _______ - Integers are printed as {-}nnn, unless the value of
  212. OUTPUTBASE!* is not 10, in which case they are printed as
  213. {-}r#nnn; r is the value of OutPutBase!*.
  214. ____ - Pairs are printed in list-notation. For example,
  215. (a . (b . c))
  216. is printed as
  217. (a b . c)
  218. while
  219. (a . (b . (c . NIL)))
  220. is printed as
  221. (a b c)
  222. ______ ______ - Vectors are printed in vector-notation; a vector of three
  223. elements a, b, and c is printed as [a b c].
  224. Read Read The following items can be printed, but cannot be parsed by Read.
  225. ____ _______ - code-pointers are printed as
  226. ________ _____ _____ _______ _____ _______ #<Code argument-count octal-address>. where octal-address
  227. is the octal machine address of the entry point of the code Input and Output 7 February 1983 PSL Manual
  228. page 12.8 section 12.4
  229. ______ ________ _____ vector, and argument-count is the number of arguments that
  230. the code takes. The argument count cannot always be
  231. determined, in which case nothing is printed for the
  232. ________ _____ argument-count.
  233. - Anything else is printed as #<Unknown:nnnn>, where nnnn is
  234. the octal value found in the argument register. Such items
  235. are not legal LISP entities and may cause garbage collector
  236. errors if they are found in the heap.
  237. Prin1 Prin1 ___ ___ ___ ___ ____ (Prin1 ITM:any): ITM:any expr
  238. ErrPrin ErrPrin _ ___ ____ ________ ____ (ErrPrin U:any): None Returned expr
  239. Prin1 Prin1 _ Prin1 with special quotes to highlight U.
  240. ChannelPrin2 ChannelPrin2 ____ __ _______ ___ ___ ___ ___ ____ (ChannelPrin2 CHAN:io-channel ITM:any): ITM:any expr
  241. ChannelPrin2 ChannelPrin1 ChannelPrin2 ChannelPrin1 ______ ChannelPrin2 is similar to ChannelPrin1, except that strings are
  242. printed without the surrounding double quotes, and delimiters
  243. __ within ids are not preceded by the escape character.
  244. Prin2 Prin2 ___ ___ ___ ___ ____ (Prin2 ITM:any): ITM:any expr
  245. ChannelPrinC ChannelPrinC ____ __ _______ ___ ___ ___ ___ ____ (ChannelPrinC CHAN:io-channel ITM:any): ITM:any expr
  246. ChannelPrint2 ChannelPrint2 Same function as ChannelPrint2.
  247. PrinC PrinC ___ ___ ___ ___ ____ (PrinC ITM:any): ITM:any expr
  248. Prin2 Prin2 Same function as Prin2.
  249. ChannelPrint ChannelPrint ____ __ _______ _ ___ _ ___ ____ (ChannelPrint CHAN:io-channel U:any): U:any expr
  250. ChannelPrin1 _ ChannelPrin1 Display U using ChannelPrin1 and terminate line using
  251. ChannelTerpri ChannelTerpri ChannelTerpri.
  252. Print Print _ ___ _ ___ ____ (Print U:any): U:any expr
  253. ChannelPrint ChannelPrint _ ChannelPrint U to current output channel, OUT!*. PSL Manual 7 February 1983 Input and Output
  254. section 12.4 page 12.9
  255. ChannelPrintF ChannelPrintF ____ __ _______ ______ ______ ____ ___ ___ ____ (ChannelPrintF CHAN:io-channel FORMAT:string [ARGS:any]): NIL expr
  256. ChannelPrintF ChannelPrintF ChannelPrintF is a simple routine for formatted printing, similar
  257. ______ to the function with the same name in the C language[22]. FORMAT
  258. ______ is either a LISP or SYSLISP string, which is printed on the
  259. currently selected output channel. However, if a % is
  260. ______ encountered in the string, the character following it is a
  261. formatting directive, used to interpret and print the other
  262. ChannelPrintF ChannelPrintF arguments to ChannelPrintF in order. The following format
  263. characters are currently supported:
  264. - For SYSLISP arguments, use:
  265. _______ %d print the next argument as a decimal integer
  266. _______ %o print the next argument as an octal integer
  267. _______ %x print the next argument as a hexadecimal integer
  268. %c print the next argument as a single character
  269. ______ %s print the next argument as a string
  270. - For LISP tagged items, use:
  271. %p print the next argument as a LISP item, using
  272. Prin1 Prin1 Prin1
  273. %w print the next argument as a LISP item, using
  274. Prin2 Prin2 Prin2
  275. %r print the next argument as a LISP item, using
  276. ErrPrin Prin2 Prin1 Prin2 ErrPrin Prin2 Prin1 Prin2 ErrPrin (Ordinarily Prin2 "`"; Prin1 Arg; Prin2
  277. "'" )
  278. %l same as %w, except lists are printed without top
  279. level parens; NIL is printed as a blank
  280. %e eval the next argument for side-effect -- most
  281. eval eval useful if the thing evaled does some printing
  282. - Control formats:
  283. %b take next argument as an integer and print that
  284. many blanks
  285. %f "fresh-line", print an end-of-line character if
  286. not at the beginning of the output line (does not
  287. use a matching argument)
  288. %n print end-of-line character (does not use a
  289. matching argument)
  290. %t take the next argument as an integer, and
  291. ChannelTab ChannelTab ChannelTab to that position Input and Output 7 February 1983 PSL Manual
  292. page 12.10 section 12.4
  293. If the character following % is not either one of the above or
  294. another %, it causes an error. Thus, to include a % in the
  295. format to be printed, use %%.
  296. There is no checking for correspondence between the number of
  297. ______ arguments the FORMAT expects and the number given. If the number
  298. ______ given is less than the number in the FORMAT string, then garbage
  299. will be inserted for the missing arguments. If the number given
  300. ______ is greater than the number in the FORMAT string, then the extra
  301. ones are ignored.
  302. PrintF PrintF ______ ______ ____ ___ ___ ____ (PrintF FORMAT:string [ARGS:any]): NIL expr
  303. ChannelPrintF ChannelPrintF ChannelPrintF to the current output channel, OUT!*.
  304. ErrorPrintF ErrorPrintF ______ ______ ____ ___ ___ ____ (ErrorPrintF FORMAT:string [ARGS:any]): NIL expr
  305. ErrorPrintF PrintF ErrorPrintF PrintF ErrorPrintF is similar to PrintF, except that instead of using
  306. the currently selected output channel, ERROUT!* is used. Also,
  307. an end-of-line character is always printed after the message, and
  308. an end-of-line character is printed before the message if the
  309. line position of ERROUT!* is greater than zero.
  310. ChannelTerPri ChannelTerPri ____ __ _______ ___ ____ (ChannelTerPri CHAN:io-channel): NIL expr
  311. ____ Terminate OUTPUT line on channel CHAN, and reset the POSN counter
  312. to 0.
  313. TerPri TerPri ___ ____ (TerPri ): NIL expr
  314. Terminate current OUTPUT line, and reset the POSN counter to 0.
  315. ChannelEject ChannelEject ____ __ _______ ___ ____ (ChannelEject CHAN:io-channel): NIL expr
  316. ____ Skip to top of next output page on channel CHAN.
  317. Eject Eject ___ ____ (Eject ): NIL expr
  318. Skip to top of next output page on current output channel.
  319. ChannelPosn ChannelPosn ____ __ _______ _______ ____ (ChannelPosn CHAN:io-channel): integer expr
  320. Returns number of characters output on this line (i.e. POSN
  321. counter since last Terpri) on this channel. PSL Manual 7 February 1983 Input and Output
  322. section 12.4 page 12.11
  323. Posn Posn _______ ____ (Posn ): integer expr
  324. Returns number of characters output on this line (i.e. POSN
  325. counter since last Terpri)
  326. ChannelLPosn ChannelLPosn ____ __ _______ _______ ____ (ChannelLPosn CHAN:io-channel): integer expr
  327. LPosn LPosn Returns number of lines output on this page (i.e. LPosn counter
  328. since last Eject) on this channel.
  329. LPosn LPosn _______ ____ (LPosn ): integer expr
  330. LPosn LPosn Returns number of lines output on this page (i.e. LPosn counter
  331. since last Eject).
  332. ChannelLineLength ChannelLineLength ____ __ _______ ___ _______ ___ _______ ____ (ChannelLineLength CHAN:io-channel LEN:{integer, NIL}): integer expr
  333. ____ _______ Set maximum output line length on CHAN if a positive integer,
  334. returning previous value. If NIL just return previous value.
  335. Terpri Terpri Controls the insertion of automatic Terpri's.
  336. LineLength LineLength ___ _______ ___ _______ ____ (LineLength LEN:{integer, NIL}): integer expr
  337. Set maximum output line length on current channel OUT!* if a
  338. _______ positive integer, returning previous value. If NIL just return
  339. Terpri Terpri previous value. Controls the insertion of automatic Terpri's.
  340. RPrint RPrint _ ____ ___ ____ (RPrint U:form): NIL expr
  341. Print in RLISP format. Autoloading.
  342. PrettyPrint PrettyPrint _ ____ _ ____ (PrettyPrint U:form): U expr
  343. _ Prettyprints U. Autoloading.
  344. Prin2L Prin2L _ ___ _ ____ (Prin2L L:any): L expr
  345. Prin2 Prin2 ____ Prin2, except that a list is printed without the top level
  346. parens.
  347. ChannelSpaces ChannelSpaces ____ __ _______ _ _______ ___ ____ (ChannelSpaces CHAN:io-channel N:integer): NIL expr
  348. ChannelPrin2 ChannelPrin2 _ _ ChannelPrin2 N spaces. Will continue across multiple lines if N
  349. is greater than the number of positions in the output buffer. Input and Output 7 February 1983 PSL Manual
  350. page 12.12 section 12.4
  351. POSN LINELENGTH POSN LINELENGTH (See POSN and LINELENGTH)
  352. Spaces Spaces _ _______ ___ ____ (Spaces N:integer): NIL expr
  353. Prin2 Prin2 _ Prin2 N spaces.
  354. ChannelPrin2T ChannelPrin2T ____ __ _______ _ ___ ___ ____ (ChannelPrin2T CHAN:io-channel X:any): any expr
  355. ChannelPrin2 _ ChannelPrin2 Output X using ChannelPrin2 and terminate line with
  356. ChannelTerpri ChannelTerpri ChannelTerpri.
  357. Prin2T Prin2T _ ___ ___ ____ (Prin2T X:any): any expr
  358. ChannelPrin2T ChannelPrin2T _ ChannelPrin2T X to the current output channel, OUT!*.
  359. ChannelTab ChannelTab ____ __ _______ _ _______ ___ ____ (ChannelTab CHAN:io-channel N:integer): NIL expr
  360. _ ____ Move to position N on channel CHAN, emitting spaces as needed.
  361. ChannelTerPri ChannelTerPri _ Calls ChannelTerPri if past column N.
  362. Tab Tab _ _______ ___ ____ (Tab N:integer): NIL expr
  363. TerPri _ TerPri Move to position N, emitting spaces as needed. TerPri() if past
  364. _ column N.
  365. _________ __________ The fluid variables PRINLEVEL and PRINLENGTH allow the user to control
  366. how deep the printer will print and how many elements at a given level the
  367. printer will print. This is useful for debugging or dealing large or deep
  368. Prin1 Prin2 PrinC Print Prin1 Prin2 PrinC Print objects. These variables affect the functions Prin1, Prin2, PrinC, Print,
  369. PrintF PrintF and PrintF (and the corresponding Channel functions). The documentation of
  370. these variables is from the Common Lisp Manual.
  371. __________ ______ PRINLEVEL [Initially: Nil] global
  372. Controls how many levels deep a nested data object will print.
  373. _________ If PRINLEVEL is NIL, then no control is exercised. Otherwise the
  374. value should be an integer, indicating the maximum level to be
  375. printed. An object to be printed is at level 0.
  376. __________ ______ PRINLENGTH [Initially: Nil] global
  377. Controls how many elements at a given level are printed. A value
  378. of NIL indicates that there be no limit to the number of
  379. __________ components printed. Otherwise the value of PRINLENGTH should be
  380. an integer. PSL Manual 7 February 1983 Input and Output
  381. section 12.5 page 12.13
  382. 12.5. Functions for Reading 12.5. Functions for Reading 12.5. Functions for Reading
  383. 12.5.1. Reading S-Expression 12.5.1. Reading S-Expression 12.5.1. Reading S-Expression
  384. ChannelRead ChannelRead ____ __ _______ ___ ____ (ChannelRead CHAN:io-channel): any expr
  385. ____ Reads and returns the next S-expression from input channel CHAN.
  386. Valid input forms are: vector-notation, pair-notation, list-
  387. ______ ____ _______ ______ __________ notation, numbers, code-pointers, strings, and identifiers.
  388. Intern __________ Intern Identifiers are interned (see the Intern function in Chapter 6),
  389. ChannelRead ChannelRead unless the FLUID variable !*COMPRESSING is non-NIL. ChannelRead
  390. returns the value of the global variable !$EOF!$ when the end of
  391. the currently selected input channel is reached.
  392. ChannelRead ChannelReadToken ChannelRead ChannelReadToken ChannelRead uses the ChannelReadToken function, with tokens
  393. scanned according to the "Lisp scan table". The user can define
  394. similar read functions for use with other scan tables.
  395. ____ _____ ____ _____ ____ _____ ChannelRead Read macro ChannelRead Read macro ChannelRead uses the Read macro mechanism to do S-expression
  396. parsing. See section 12.5.5 for more information on read macros
  397. and how to add extensions. The following read macros are defined
  398. initially:
  399. ( Starts a scan collecting S-expressions according to
  400. ____ ____ list or dot notation until terminated by a ). A pair
  401. ____ or list is returned.
  402. [ Starts a scan collecting S-expressions according to
  403. ______ vector notation until terminated by a ]. A vector is
  404. returned.
  405. Read Read ' Calls Read to get an S-expression, x, and then returns
  406. Quote Quote the list (Quote x).
  407. !$EOF!$ Generates an error when still inside an S-expression:
  408. ***** Unexpected EOF while reading on channel
  409. . Otherwise !$EOF!$ is returned.
  410. Read Read ___ ____ (Read ): any expr
  411. Reads and returns an S-expression from the current input channel.
  412. ChannelRead ChannelRead That is, it does a ChannelRead(IN!*). Input and Output 7 February 1983 PSL Manual
  413. page 12.14 section 12.5
  414. 12.5.2. Reading Files into PSL 12.5.2. Reading Files into PSL 12.5.2. Reading Files into PSL
  415. The following procedures are used to read complete files into PSL, by
  416. Open Open first calling Open, and then looping until end of file. The effect is
  417. similar to what would happen if the file were typed into PSL. Recall that
  418. file names are strings, and therefore one needs string-quotes (") around
  419. file names. File names may be given using full system dependent file name
  420. conventions, including directories and sub-directories, "links" and
  421. "logical-device-names", as appropriate on the specific system.
  422. __________ ______ !*ECHO [Initially: Nil] switch
  423. ____ The switch !*ECHO is used to control the echoing of input. When
  424. (On Echo) is placed in an input file, the contents of the file
  425. Dskin Dskin are echoed on the standard output device. Dskin does not change
  426. ____ the value of !*ECHO, so one may say (On Echo) before calling
  427. Dskin Dskin Dskin, and the input will be echoed.
  428. DskIn DskIn _ ______ ____ ________ ____ (DskIn F:string): None Returned expr
  429. Read Eval Print Read Eval Print _ Enters a Read-Eval-Print loop on the contents of the file F.
  430. DskIn DskIn _ DskIn expects LISP syntax in the file F. Use the following
  431. format: (DskIn "File").
  432. LapIn LapIn _ ______ ____ ________ ____ (LapIn U:string): None Returned expr
  433. Reads a single LISP file as "quietly" as possible, i.e., it does
  434. LapIn LapIn not echo or return values. Note that LapIn can be used only for
  435. LISP files. By convention, files with the extension ".LAP" are
  436. LapIn LapIn intended to be read by LapIn. These files are typically used to
  437. load modules made up of several binary (also known as FASL)
  438. Load Load files. The use of the Load function is normally preferable to
  439. LapIn LapIn using LapIn. For information about fast loading of files of
  440. Load FaslIn Load FaslIn compiled functions (FASL files) see FASL and the Load and FaslIn
  441. functions in Chapter 18.
  442. The following functions are present in RLISP, they can be used from
  443. Bare-PSL by loading RLISP.
  444. In In _ ______ ____ ________ _____ (In [L:string]): None Returned macro
  445. DskIn DskIn Similar to DskIn but expects RLISP syntax in the files it reads
  446. unless it can determine that the files are not in RLISP syntax.
  447. In In Also In can take more than one file name as an argument. On most
  448. In In systems the function In expects files with extension .LSP and .SL
  449. to be written in LISP syntax, not in RLISP. This is convenient
  450. when using both LISP and RLISP files. It is conventional to use
  451. the extension .RED (or .R) for RLISP files and use .LSP or .SL PSL Manual 7 February 1983 Input and Output
  452. section 12.5 page 12.15
  453. only for fully parenthesized LISP files. There are some system
  454. programs, such as TAGS on the DEC-20, which expect RLISP files to
  455. have the extension .RED.
  456. If it is not desired to have the contents of the file echoed as
  457. In In it is read, either end the In command with a "$" in RLISP, as
  458. In "FILE1.RED","FILE2.SL"$
  459. Off Off ____ or include the statement "Off ECHO;" in your file.
  460. PathIn PathIn ________ ____ ______ ____ ________ ____ (PathIn FileName-Tail:string): None Returned expr
  461. IN IN Allows the use of a directory search path with the Rlisp IN
  462. function. It finds a list of search paths in the fluid variable
  463. PATHIN!*. These are successively concatenated onto the front of
  464. PathIn PathIn the string argument to PathIn until an existing file is found
  465. FileP In FileP In (using FileP. If one is found, In will be invoked on this file.
  466. If not, a continuable error occurs. For example on the VAX,
  467. (Setq PathIn!* '( "" "/u/psl/" "/u/smith/"))
  468. (PathIn "foo.red")
  469. will attempt to open "foo.red", then "/u/psl/foo.red", and
  470. finally "/u/smith/foo.red" until a successful open is achieved.
  471. Pathin Pathin To use Pathin in Bare-PSL, load PATHIN as well as RLISP.
  472. EvIn EvIn _ ______ ____ ____ ________ ____ (EvIn L:string-list): None Returned expr
  473. EvIn _ EvIn L must be a list of strings that are filenames. EvIn is the
  474. In In In In function called by In after evaluating its arguments. In is
  475. EvIn EvIn useful only at the top-level, while EvIn can be used inside
  476. functions with file names passed as parameters.
  477. 12.5.3. Reading Single Characters 12.5.3. Reading Single Characters 12.5.3. Reading Single Characters
  478. ChannelReadChar ChannelReadChar _______ __ _______ _________ ____ (ChannelReadChar CHANNEL:io-channel): character expr
  479. _______ _______ Reads one character (an integer) from CHANNEL. All input is
  480. _______ defined in terms of this function. If CHANNEL is not open or is
  481. open for writing only, an error is generated. If there is a
  482. _______ non-zero value in the backup buffer associated with CHANNEL, the
  483. buffer is emptied (set to zero) and the value returned.
  484. _______ Otherwise, the reading function associated with CHANNEL is called
  485. _______ with CHANNEL as argument, and the value it returns is returned by
  486. ChannelReadChar ChannelReadChar ChannelReadChar. Input and Output 7 February 1983 PSL Manual
  487. page 12.16 section 12.5
  488. ***** Channel not open
  489. ***** Channel open for write only
  490. ReadChar ReadChar _________ ____ (ReadChar ): character expr
  491. Reads one character from the current input channel.
  492. ChannelReadCH ChannelReadCH ____ __ _______ __ ____ (ChannelReadCH CHAN:io-channel): id expr
  493. ChannelReadChar ChannelReadChar __ Like ChannelReadChar, but returns the id for the character rather
  494. than its ASCII code.
  495. ReadCH ReadCH __ ____ (ReadCH ): id expr
  496. ChannelReadCH ChannelReadCH ChannelReadCH from the current input channel.
  497. ChannelUnReadChar ChannelUnReadChar ____ __ _______ __ _________ _________ ____ (ChannelUnReadChar CHAN:io-channel CH:character): Undefined expr
  498. __ The input backup function. CH is deposited in the backup buffer
  499. ____ associated with CHAN. This function should be only called after
  500. ChannelReadChar ChannelReadChar ChannelReadChar is called, before any intervening input
  501. operations, since it is used by the token scanner.
  502. UnReadChar UnReadChar __ _________ _________ ____ (UnReadChar CH:character): Undefined expr
  503. Backup on the current input channel.
  504. 12.5.4. Reading Tokens 12.5.4. Reading Tokens 12.5.4. Reading Tokens
  505. The functions described here pertain to the token scanner and reader.
  506. Globals and switches used by these functions are defined at the end of this
  507. section.
  508. ChannelReadToken ChannelReadToken _______ __ _______ __ ______ ______ ____ (ChannelReadToken CHANNEL:io-channel): {id, number, string} expr
  509. This is the basic LISP token scanner. The value returned is a
  510. LISP item corresponding to the next token from the input stream.
  511. __ Ids are interned, unless the FLUID variable !*COMPRESSING is
  512. non-NIL. The GLOBAL variable TOKTYPE!* is set to:
  513. __ 0 if the token is an ordinary id,
  514. ______ 1 if the token is a string,
  515. ______ 2 if the token is a number, or PSL Manual 7 February 1983 Input and Output
  516. section 12.5 page 12.17
  517. 3 if the token is an unescaped delimiter.
  518. __ In the last case, the value returned is the id whose print name
  519. is the same as the delimiter.
  520. The precise behavior of this function depends on two FLUID
  521. variables:
  522. CURRENTSCANTABLE!*
  523. ______ Is bound to a vector known as a scan table. Described
  524. below.
  525. CURRENTREADMACROINDICATOR!*
  526. __ Bound to an id known as a read macro indicator.
  527. Described below.
  528. Scan tables have 129 entries, indexed by 0 through 128. 0
  529. _______ through 127 are indexed by ASCII character code to get an integer
  530. code determining the treatment of the corresponding character.
  531. _______ __ The last entry is not an integer, but rather an id which
  532. _________ _________ specifies a Diphthong Indicator for the token scanner.
  533. [??? A future implementation may replace the FLUID [??? A future implementation may replace the FLUID [??? A future implementation may replace the FLUID
  534. CURRENTREADMACROINDICATOR!* with another entry in the scan CURRENTREADMACROINDICATOR!* with another entry in the scan CURRENTREADMACROINDICATOR!* with another entry in the scan
  535. table. ???] table. ???] table. ???]
  536. The following encoding for characters is used.
  537. 0 ... 9 DIGIT: indicates the character is a digit, and gives
  538. the corresponding numeric value.
  539. 10 LETTER: indicates that the character is a letter.
  540. 11 DELIMITER: indicates that the character is a delimiter
  541. which is not the starting character of a diphthong.
  542. 12 COMMENT: indicates that the character begins a comment
  543. terminated by an end of line.
  544. 13 DIPHTHONG: indicates that the character is a delimiter
  545. which may be the starting character of a diphthong. (A
  546. diphthong is a two character sequence read as one
  547. token, i.e., "<<" or ":=".)
  548. 14 IDESCAPE: indicates that the character is an escape
  549. character, to cause the following character to be taken
  550. __ as part of an id. (Ordinarily an exclamation point,
  551. i.e. "!".)
  552. 15 STRINGQUOTE: indicates that the character is a string
  553. quote. (Ordinarily a double quote, i.e. '"'.)
  554. 16 PACKAGE: indicates that the character is used to
  555. introduce explicit package names. (Ordinarily "\".)
  556. 17 IGNORE: indicates that the character is to be ignored. Input and Output 7 February 1983 PSL Manual
  557. page 12.18 section 12.5
  558. (Ordinarily BLANK, TAB, EOL and NULL.)
  559. 18 MINUS: indicates that the character is a minus sign.
  560. 19 PLUS: indicates that the character is a plus sign.
  561. 20 DECIMAL: indicates that the character is a decimal
  562. point.
  563. 21 IDSURROUND: indicates that the character is to act for
  564. identifiers as a string quote acts for strings.
  565. Although this is not used in the default scan table,
  566. the intended character for this function is a vertical
  567. bar, |.)
  568. System builders who wish to define their own parsers can bind an
  569. appropriate scan table to CURRENTSCANTABLE!* and then call
  570. ChannelReadToken ChannelReadTokenWithHooks ChannelReadToken ChannelReadTokenWithHooks ChannelReadToken or ChannelReadTokenWithHooks for lexical
  571. scanning. Utility functions for building scan tables are
  572. described in the next section.
  573. The following standards for scanning tokens are used.
  574. __ - Ids begin with a letter or any character preceded by an
  575. escape character. They may contain letters, digits and
  576. __ escaped characters. Ids may also start with a digit, if the
  577. first non-digit following is a plus sign, minus sign, or
  578. letter other than "b" or "e". This is to allow identifiers
  579. such as "1+" which occur in some LISPs. Finally, a string
  580. of characters bounded by the IDSURROUND character is treated
  581. __ as an id.
  582. If !*RAISE is non-NIL, unescaped lower case letters are
  583. __ folded to upper case. The maximum size of an id (or any
  584. other token) is currently 5000 characters.
  585. __________ Note: Using lower case letters in identifiers may cause
  586. portability problems. Lower case letters are automatically
  587. converted to upper case if the !*RAISE switch is T. This
  588. __ case conversion is done only for id input, not for single
  589. character or string input.
  590. [??? Can we retain input Case, but Compare RAISEd ???] [??? Can we retain input Case, but Compare RAISEd ???] [??? Can we retain input Case, but Compare RAISEd ???]
  591. Here are some examples, using the RLISP scan table. Note
  592. that the first and second examples are read as the same
  593. identifier if !*RAISE is T. The fourth and fifth examples
  594. are read as the same identifier.
  595. * ThisIsALongIdentifier
  596. * THISISALONGIDENTIFIER
  597. * ThisIsALongIdentifierAndDifferentFromTheOther
  598. * this_is_a_long_identifier_with_underscores PSL Manual 7 February 1983 Input and Output
  599. section 12.5 page 12.19
  600. * this!_is!_a!_long!_identifier!_with!_underscores
  601. * an!-identifier!-with!-dashes
  602. * !*RAISE
  603. * !2222
  604. The following examples show the same identifiers in a form
  605. accepted by the LISP scan table. Note that most characters
  606. are treated as letters by the LISP scan table, while they
  607. are treated as delimiters by the RLISP scan table.
  608. * ThisIsALongIdentifier
  609. * THISISALONGIDENTIFIER
  610. * ThisIsALongIdentifierAndDifferentFromTheOther
  611. * this_is_a_long_identifier_with_underscores
  612. * this!_is!_a!_long!_identifier!_with!_underscores
  613. * an-identifier-with-dashes
  614. * *RAISE
  615. * !2222
  616. ______ - Strings begin with a double quote (") and include all
  617. characters up to a closing double quote. A double quote can
  618. ______ ______ be included in a string by doubling it. An empty string,
  619. consisting of only the enclosing quote marks, is allowed.
  620. ______ The characters of a string are not affected by the value of
  621. the !*RAISE. Examples:
  622. * "This is a string"
  623. * "This is a ""string"""
  624. * ""
  625. ____ _______ - Code-pointers cannot be read directly, but can be printed
  626. and constructed. Currently printed as
  627. ________ _____ _____ _______ #<Code argument-count octal-address>.
  628. _______ - Integers begin with a digit, optionally preceded by a + or
  629. - sign, and consist only of digits. The GLOBAL input radix
  630. is 10; there is no way to change this. However, numbers of
  631. different radices may be read by the following convention.
  632. A decimal number from 2 to 36 followed by a sharp sign (#),
  633. causes the digits (and possibly letters) that follow to be
  634. 2
  635. read in the radix of the number preceding the #. Thus 63
  636. _______________
  637. 2
  638. Octal numbers can also be written as a string of digits followed by the
  639. letter "B". This "feature" may be removed in the future. Input and Output 7 February 1983 PSL Manual
  640. page 12.20 section 12.5
  641. may be entered as 8#77, or 255 as 16#ff or 16#FF. The
  642. output radix can be changed, by setting OUTPUTBASE!*. If
  643. _______ OutPutBase!* is not 10, the printed integer appears with
  644. appropriate radix. Leading zeros are suppressed and a minus
  645. _______ sign precedes the digits if the integer is negative.
  646. Examples:
  647. * 100
  648. * +5234
  649. * -8#44 (equal to -36)
  650. [??? Should we permit trailing . in integers for [??? Should we permit trailing . in integers for [??? Should we permit trailing . in integers for
  651. compatibility with some LISPs and require digits on each compatibility with some LISPs and require digits on each compatibility with some LISPs and require digits on each
  652. side of . for floats ???] side of . for floats ???] side of . for floats ???]
  653. _____ - Floats have a period and/or a letter "e" or "E" in them.
  654. _____ Any of the following are read as floats. The value appears
  655. in the format [-]n.nn...nnE[-]mm if the magnitude of the
  656. number is too large or small to display in [-]nnnn.nnnn
  657. format. The crossover point is determined by the
  658. _____ implementation. In BNF, floats are recognized by the
  659. grammar:
  660. <base> ::= <unsigned-integer>.|
  661. .<unsigned-integer>|
  662. <unsigned-integer>.<unsigned-integer>
  663. <ebase> ::= <base>|<unsigned-integer>
  664. <unsigned-float> ::= <base>|
  665. <ebase>e<unsigned-integer>|
  666. <ebase>e-<unsigned-integer>|
  667. <ebase>e+<unsigned-integer>|
  668. <ebase>E<unsigned-integer>|
  669. <ebase>E-<unsigned-integer>|
  670. <ebase>E+<unsigned-integer>
  671. <float> ::= <unsigned-float>|
  672. +<unsigned-float>|
  673. -<unsigned-float>
  674. That is:
  675. * [+|-][nnn][.]nnn{e|E}[+|-]nnn
  676. * nnn.
  677. * .nnn
  678. * nnn.nnn
  679. Examples: PSL Manual 7 February 1983 Input and Output
  680. section 12.5 page 12.21
  681. * 1e6
  682. * .2
  683. * 2.
  684. * 2.0
  685. * -1.25E-9
  686. RAtom RAtom __ ______ ______ ____ (RAtom ): {id, number, string} expr
  687. Reads a token from the current input channel. (Not called
  688. ReadToken ReadToken ReadToken for historical reasons.)
  689. [??? Should we bind CurrentScanTable!* for this function too [??? Should we bind CurrentScanTable!* for this function too [??? Should we bind CurrentScanTable!* for this function too
  690. ???] ???] ???]
  691. __________ ______ !*COMPRESSING [Initially: NIL] switch
  692. ChannelReadToken ChannelReadToken If !*COMPRESSING is non-NIL, ChannelReadToken does not intern
  693. __ ids.
  694. __________ ______ !*EOLINSTRINGOK [Initially: NIL] switch
  695. If !*EOLINSTRINGOK is non-NIL, the warning message
  696. *** STRING CONTINUED OVER END-OF-LINE
  697. is suppressed.
  698. __________ ______ !*RAISE [Initially: T] switch
  699. __ If !*RAISE is non-NIL, all characters input for ids through PSL
  700. input functions are raised to upper case. If !*RAISE is NIL,
  701. ______ characters are input as is. A string is unaffected by !*RAISE.
  702. __________ ______ CURRENTSCANTABLE!* [Initially: ] global
  703. Read Read This variable is set to LISPSCANTABLE!* by the Read function (the
  704. "Lisp syntax" reader). The RLISP reader sets it to
  705. RLISPSCANTABLE!* or LISPSCANTABLE!* depending on the syntax it
  706. expects. Input and Output 7 February 1983 PSL Manual
  707. page 12.22 section 12.5
  708. __________ ______ LISPSCANTABLE!* [Initially: as shown in following table] global
  709. 0 ^@ IGNORE 32 IGNORE 64 @ LETTER 96 ` DELIMITER
  710. 1 ^A LETTER 33 ! IDESCAPECHAR 65 A LETTER 97 a LETTER
  711. 2 ^B LETTER 34 " STRINGQUOTE 66 B LETTER 98 b LETTER
  712. 3 ^C LETTER 35 # LETTER 67 C LETTER 99 c LETTER
  713. 4 ^D LETTER 36 $ LETTER 68 D LETTER 100 d LETTER
  714. 5 ^E LETTER 37 % COMMENTCHAR 69 E LETTER 101 e LETTER
  715. 6 ^F LETTER 38 & LETTER 70 F LETTER 102 f LETTER
  716. 7 ^G LETTER 39 ' DELIMITER 71 G LETTER 103 g LETTER
  717. 8 ^H LETTER 40 ( DELIMITER 72 H LETTER 104 h LETTER
  718. 9 <tab> IGNORE 41 ) DELIMITER 73 I LETTER 105 i LETTER
  719. 10 <lf> IGNORE 42 * LETTER 74 J LETTER 106 j LETTER
  720. 11 ^K LETTER 43 + PLUSSIGN 75 K LETTER 107 k LETTER
  721. 12 ^L IGNORE 44 , DIPHTHONGSTART 76 L LETTER 108 l LETTER
  722. 13 <cr> IGNORE 45 - MINUSSIGN 77 M LETTER 109 m LETTER
  723. 14 ^N LETTER 46 . DECIMALPOINT 78 N LETTER 110 n LETTER
  724. 15 ^O LETTER 47 / LETTER 79 O LETTER 111 o LETTER
  725. 16 ^P LETTER 48 0 DIGIT 80 P LETTER 112 p LETTER
  726. 17 ^Q LETTER 49 1 DIGIT 81 Q LETTER 113 q LETTER
  727. 18 ^R LETTER 50 2 DIGIT 82 R LETTER 114 r LETTER
  728. 19 ^S LETTER 51 3 DIGIT 83 S LETTER 115 s LETTER
  729. 20 ^T LETTER 52 4 DIGIT 84 T LETTER 116 t LETTER
  730. 21 ^U LETTER 53 5 DIGIT 85 U LETTER 117 u LETTER
  731. 22 ^V LETTER 54 6 DIGIT 86 V LETTER 118 v LETTER
  732. 23 ^W LETTER 55 7 DIGIT 87 W LETTER 119 w LETTER
  733. 24 ^X LETTER 56 8 DIGIT 88 X LETTER 120 x LETTER
  734. 25 ^Y LETTER 57 9 DIGIT 89 Y LETTER 121 y LETTER
  735. 26 ^Z DELIMITER 58 : LETTER 90 Z LETTER 122 z LETTER
  736. 27 $ LETTER 59 ; LETTER 91 [ DELIMITER 123 { LETTER
  737. 28 ^\ LETTER 60 < LETTER 92 \ PACKAGE 124 | LETTER
  738. 29 ^] LETTER 61 = LETTER 93 ] DELIMITER 125 } LETTER
  739. 30 ^^ LETTER 62 > LETTER 94 ^ LETTER 126 ~ LETTER
  740. 31 ^_ LETTER 63 ? LETTER 95 _ LETTER 127 <rubout>
  741. LETTER
  742. _________ _________ The Diphthong Indicator in the 128th entry is the identifier
  743. LISPDIPTHONG.
  744. [??? Note that LISPDIPTHONG should be spelled LISPDIPHTHONG, this will [??? Note that LISPDIPTHONG should be spelled LISPDIPHTHONG, this will [??? Note that LISPDIPTHONG should be spelled LISPDIPHTHONG, this will
  745. probably be corrected in the future. ???] probably be corrected in the future. ???] probably be corrected in the future. ???] PSL Manual 7 February 1983 Input and Output
  746. section 12.5 page 12.23
  747. __________ ______ RLISPSCANTABLE!* [Initially: as shown in following table] global
  748. 0 ^@ IGNORE 32 IGNORE 64 @ DELIMITER 96 ` DELIMITER
  749. 1 ^A DELIMITER 33 ! IDESCAPECHAR 65 A LETTER 97 a LETTER
  750. 2 ^B DELIMITER 34 " STRINGQUOTE 66 B LETTER 98 b LETTER
  751. 3 ^C DELIMITER 35 # DELIMITER 67 C LETTER 99 c LETTER
  752. 4 ^D DELIMITER 36 $ DELIMITER 68 D LETTER 100 d LETTER
  753. 5 ^E DELIMITER 37 % COMMENTCHAR 69 E LETTER 101 e LETTER
  754. 6 ^F DELIMITER 38 & DELIMITER 70 F LETTER 102 f LETTER
  755. 7 ^G DELIMITER 39 ' DELIMITER 71 G LETTER 103 g LETTER
  756. 8 ^H DELIMITER 40 ( DELIMITER 72 H LETTER 104 h LETTER
  757. 9 <tab> IGNORE 41 ) DELIMITER 73 I LETTER 105 i LETTER
  758. 10 <lf> IGNORE 42 * DIPHTHONGSTART 74 J LETTER 106 j LETTER
  759. 11 ^K DELIMITER 43 + DELIMITER 75 K LETTER 107 k LETTER
  760. 12 ^L IGNORE 44 , DELIMITER 76 L LETTER 108 l LETTER
  761. 13 <cr> IGNORE 45 - DELIMITER 77 M LETTER 109 m LETTER
  762. 14 ^N DELIMITER 46 . DECIMALPOINT 78 N LETTER 110 n LETTER
  763. 15 ^O DELIMITER 47 / DELIMITER 79 O LETTER 111 o LETTER
  764. 16 ^P DELIMITER 48 0 DIGIT 80 P LETTER 112 p LETTER
  765. 17 ^Q DELIMITER 49 1 DIGIT 81 Q LETTER 113 q LETTER
  766. 18 ^R DELIMITER 50 2 DIGIT 82 R LETTER 114 r LETTER
  767. 19 ^S DELIMITER 51 3 DIGIT 83 S LETTER 115 s LETTER
  768. 20 ^T DELIMITER 52 4 DIGIT 84 T LETTER 116 t LETTER
  769. 21 ^U DELIMITER 53 5 DIGIT 85 U LETTER 117 u LETTER
  770. 22 ^V DELIMITER 54 6 DIGIT 86 V LETTER 118 v LETTER
  771. 23 ^W DELIMITER 55 7 DIGIT 87 W LETTER 119 w LETTER
  772. 24 ^X DELIMITER 56 8 DIGIT 88 X LETTER 120 x LETTER
  773. 25 ^Y DELIMITER 57 9 DIGIT 89 Y LETTER 121 y LETTER
  774. 26 ^Z DELIMITER 58 : DIPHTHONGSTART 90 Z LETTER 122 z LETTER
  775. 27 $ DELIMITER 59 ; DELIMITER 91 [ DELIMITER 123 { DELIMITER
  776. 28 ^\ DELIMITER 60 < DIPHTHONGSTART 92 \ PACKAGE 124 | DELIMITER
  777. 29 ^] DELIMITER 61 = DELIMITER 93 ] DELIMITER 125 } DELIMITER
  778. 30 ^^ DELIMITER 62 > DIPHTHONGSTART 94 ^ DELIMITER 126 ~ DELIMITER
  779. 31 ^_ DELIMITER 63 ? DELIMITER 95 _ LETTER 127 <rubout>
  780. DELIMITER
  781. _________ _________ The Diphthong Indicator in the 128th entry is the identifier
  782. RLISPDIPTHONG.
  783. [??? Note that RLISPDIPTHONG should be spelled RLISPDIPHTHONG, this [??? Note that RLISPDIPTHONG should be spelled RLISPDIPHTHONG, this [??? Note that RLISPDIPTHONG should be spelled RLISPDIPHTHONG, this
  784. will probably be corrected in the future. ???] will probably be corrected in the future. ???] will probably be corrected in the future. ???]
  785. [??? What about the RlispRead scantable ???] [??? What about the RlispRead scantable ???] [??? What about the RlispRead scantable ???]
  786. [??? Perhaps describe one basic table, and changes from one to other, [??? Perhaps describe one basic table, and changes from one to other, [??? Perhaps describe one basic table, and changes from one to other,
  787. since mostly the same ???] since mostly the same ???] since mostly the same ???] Input and Output 7 February 1983 PSL Manual
  788. page 12.24 section 12.5
  789. __________ ______ OUTPUTBASE!* [Initially: 10] global
  790. This global can be set to control the radix in which integers are
  791. printed out. If the radix is not 10, the radix is given before a
  792. sharp sign, e.g. 8#20 is"20" in base 8, or 16.
  793. __________ ______ TOKTYPE!* [Initially: 3] global
  794. ChannelReadToken ChannelReadToken ChannelReadToken sets TOKTYPE!* to:
  795. __ 0 if the token is an ordinary id,
  796. ______ 1 if the token is a string,
  797. ______ 2 if the token is a number, or
  798. 3 if the token is an unescaped delimiter.
  799. __ In the last case, the value returned is the id whose print name
  800. is the same as the delimiter.
  801. 12.5.5. Read Macros 12.5.5. Read Macros 12.5.5. Read Macros
  802. Channel Token Channel Token A function of two arguments (Channel, Token) can be associated with any
  803. DELIMITER or DIPHTHONG token (i.e. those that have TOKTYPE!*=3) by calling
  804. PutReadMacro ChannelReadTokenWithHooks PutReadMacro _________ ChannelReadTokenWithHooks PutReadMacro. A ReadMacro function is called by ChannelReadTokenWithHooks
  805. ChannelReadToken ChannelReadToken if the appropriate token with TOKTYPE!*=3 is returned by ChannelReadToken.
  806. This function can then take over the reading (or scanning) process, finally
  807. returning a token (actually an S-expression) to be returned in place of the
  808. token itself.
  809. Quote Quote Example: The quote mark, 'x converting to (Quote x), is done by the
  810. PutReadMacro PutReadMacro following example which makes use of the function PutReadMacro which is
  811. defined in Section 12.6.
  812. In LISP:
  813. (de DOQUOTE (CHANNEL TOKEN))
  814. (LIST 'QUOTE (CHANNELREAD CHANNEL))
  815. (PUTREADMACRO LISPSCANTABLE!* '!' (FUNCTION DOQUOTE))
  816. _________ A ReadMacro is installed on the property list of the macro-character as a
  817. function under the indicators 'LISPREADMACRO, 'RLISPREADMACRO, etc. A
  818. _________ Diphthong is installed on the property list of the first character as
  819. (second-character . diphthong) under the indicators 'LISPDIPHTHONG,
  820. 'RLISPDIPHTHONG, etc. PSL Manual 7 February 1983 Input and Output
  821. section 12.6 page 12.25
  822. 12.6. Scan Table Utility Functions 12.6. Scan Table Utility Functions 12.6. Scan Table Utility Functions
  823. The following functions are provided to manage scan tables, in the
  824. READ-UTILS module (use via LOAD READ-UTILS):
  825. PrintScanTable PrintScanTable _____ ______ ___ ____ (PrintScanTable TABLE:vector): NIL expr
  826. Prints the entire scantable, gives the 0 ... 127 entries with the
  827. name of the character class. Also prints the indicator used for
  828. diphthongs.
  829. [??? Make smarter, reduce output, use nice names for control [??? Make smarter, reduce output, use nice names for control [??? Make smarter, reduce output, use nice names for control
  830. characters, ala EMODE. ???] characters, ala EMODE. ???] characters, ala EMODE. ???]
  831. CopyScanTable CopyScanTable ________ ______ ___ ______ ____ (CopyScanTable OLDTABLE:{vector, NIL}): vector expr
  832. Copies the existing scantable (or CURRENTSCANTABLE!* if given
  833. GenSym GenSym NIL). Currently GenSym()'s the indicators used for diphthongs.
  834. [??? Change when we use Property Lists in extra slots of the [??? Change when we use Property Lists in extra slots of the [??? Change when we use Property Lists in extra slots of the
  835. Scan-Table ???] Scan-Table ???] Scan-Table ???]
  836. PutDipthong PutDipthong _____ ______ __ __ ___ __ ___ __ ___ ____ (PutDipthong TABLE:vector, D1:id ID2:id DIP:id): NIL expr
  837. ___ ___ ___ Installs DIP as the name of the diphthong ID1 followed by ID2 in
  838. the given scan table.
  839. [??? Note that PutDipthong should be spelled PutDiphthong, [??? Note that PutDipthong should be spelled PutDiphthong, [??? Note that PutDipthong should be spelled PutDiphthong,
  840. this will probably be corrected in the future. ???] this will probably be corrected in the future. ???] this will probably be corrected in the future. ???]
  841. PutReadMacro PutReadMacro _____ ______ ___ __ _____ __ ___ ____ (PutReadMacro TABLE:vector ID1:id FNAME:id): NIL expr
  842. ____ _____ ____ _____ ____ _____ Read macro _____ Read macro Installs FNAME as the name of the Read macro function for the
  843. ___ ___ ___ [not ___ [not delimiter or diphthong ID1 in the given scan table. [not
  844. ___________ ___ ___________ ___ ___________ ___ implemented yet] implemented yet] implemented yet]
  845. 12.7. I/O to and from Lists and Strings 12.7. I/O to and from Lists and Strings 12.7. I/O to and from Lists and Strings
  846. Digit Digit _ ___ _______ ____ (Digit U:any): boolean expr
  847. _ Returns T if U is a digit, otherwise NIL. Effectively this is:
  848. (de DIGIT (U)
  849. (IF (MEMQ U '(!0 !1 !2 !3 !4 !5 !6 !7 !8 !9)) T NIL)) Input and Output 7 February 1983 PSL Manual
  850. page 12.26 section 12.7
  851. Liter Liter _ ___ _______ ____ (Liter U:any): boolean expr
  852. _ Returns T if U is a character of the alphabet, NIL otherwise.
  853. This is effectively:
  854. (de LITER(U)
  855. (IF (MEMQ U '(A B C D E F G H I J K L M
  856. N O P Q R S T U V W X Y Z a b c d e f
  857. g h i j k l m n o p q r s t u v w x y
  858. z)) T NIL))
  859. Explode Explode _ ___ __ ____ ____ (Explode U:any): id-list expr
  860. Explode Explode Explode takes the constituent characters of an S-expression and
  861. ____ __ forms a list of single character ids. It is implemented via the
  862. ChannelPrin1 ChannelPrin1 ____ function ChannelPrin1, with a list rather than a file or terminal
  863. ____ as destination. Returned is a list of interned characters
  864. _ representing the characters required to print the value of U.
  865. Example:
  866. - Explode 'FOO; => (F O O)
  867. - Explode '(A . B); => (!( A ! !. ! B !))
  868. [??? add print macros. cf. UCI lisp ???] [??? add print macros. cf. UCI lisp ???] [??? add print macros. cf. UCI lisp ???]
  869. Explode2 Explode2 _ ____ ______ __ ____ ____ (Explode2 U:{atom}-{vector}): id-list expr
  870. Prin2 Explode Prin2 Explode Prin2 version of Explode.
  871. Compress Compress _ __ ____ ____ ______ ____ (Compress U:id-list): {atom}-{vector} expr
  872. _ ____ U is a list of single character identifiers which is built into a
  873. ______ ______ PSL entity and returned. Recognized are numbers, strings, and
  874. __________ identifiers with the escape character prefixing special
  875. characters. The formats of these items appear in the "Primitive
  876. __________ ___ Data Types" Section, Section 4.1.2. Identifiers are not interned
  877. ________ _______ on the ID-HASH-TABLE. Function pointers may not be compressed.
  878. _ If an entity cannot be parsed out of U or characters are left
  879. over after parsing an error occurs:
  880. ***** Poorly formed atom in COMPRESS PSL Manual 7 February 1983 Input and Output
  881. section 12.7 page 12.27
  882. Implode Implode _ __ ____ ____ ____ (Implode U:id-list): atom expr
  883. Compress Compress __ Compress with ids interned.
  884. FlatSize FlatSize _ ___ _______ ____ (FlatSize U:any): integer expr
  885. Prin1 Prin1 Character length of Prin1 S-expression.
  886. FlatSize2 FlatSize2 _ ___ _______ ____ (FlatSize2 U:any): integer expr
  887. Prin2 flatsize Prin2 flatsize Prin2 version of flatsize.
  888. BldMsg BldMsg ______ ______ ____ ___ ______ ____ (BldMsg FORMAT:string, [ARGS:any]): string expr
  889. PrintF BldMsg PrintF ______ BldMsg ______ PrintF to string. BldMsg returns a string stating that the
  890. ______ string could not be constructed if overflow occurs.
  891. 12.8. Example of Simple I/O in PSL 12.8. Example of Simple I/O in PSL 12.8. Example of Simple I/O in PSL
  892. In the following example a list of S-expressions is read, one expression
  893. at a time, from a file STUFF.IN and is written to a file STUFF.OUT.
  894. Following is the contents of STUFF.IN:
  895. (r e d)
  896. (a b c)
  897. (1 2 3 4)
  898. "ho ho ho"
  899. 6.78
  900. 5000
  901. xyz
  902. The following shows the execution of the function TRYIO. Input and Output 7 February 1983 PSL Manual
  903. page 12.28 section 12.8
  904. @psl:psl
  905. PSL 3.1, 15-Nov-82
  906. 1 lisp> (On Echo)
  907. NIL
  908. 2 lisp> (Dskin "Exampio.Sl")
  909. (De Tryio (Fil1 Fil2)
  910. (Prog (Oldin Oldout Exp)
  911. (Setq Oldin (Rds (Open Fil1 'input)))
  912. (Setq Oldout (Wrs (Open Fil2 'output)))
  913. (While (Neq (Setq Exp (Read)) !$EOF!$)
  914. (Print Exp))
  915. (Close (Rds Oldin))
  916. (Close (Wrs Oldout))))
  917. TRYIO
  918. NIL
  919. 3 lisp> (Off Echo)
  920. NIL
  921. 4 lisp> (Tryio "Stuff.In" "Stuff.Out")
  922. NIL
  923. The output file STUFF.OUT contains the following.
  924. (R E D)
  925. (A B C)
  926. (1 2 3 4)
  927. "ho ho ho"
  928. 6.78
  929. 5000
  930. XYZ