home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / constant.seq < prev    next >
Text File  |  1988-07-21  |  2KB  |  54 lines

  1. \ CONSTANT.SEQ  Allow defining a bunch of constant or variables
  2.  
  3. comment:
  4.  
  5.   A simple utility to allow the definition of a bunch of variables or
  6. constants.
  7.  
  8. comment;
  9.  
  10. anew cons
  11.  
  12. : constants     ( | <values> <names> --- )      \ define a bunch of constants
  13.                 loading @ 0= abort" CONSTANTS can ONLY be used while loading"
  14.                 begin   begin   bl word c@ 0=           \ while word len=0
  15.                                                         \ discard comments
  16.                                 here " \" ">$ dup c@ 1+ caps-comp 0= or
  17.                                 outbuf c@ 2 > and       \ while read length<>0
  18.                         while   filltib                 \ refill tib
  19.                         repeat
  20.                         here " ;" ">$ dup c@ 1+ caps-comp
  21.                         0<>                             \ word <> ";" and
  22.                         here c@ 0<> and                 \ word length <> 0
  23.                 while   here number drop constant
  24.                 repeat  ;
  25.  
  26. : variables     ( | <names> --- )               \ define a bunch of variables
  27.                 loading @ 0= abort" VARIABLES can ONLY be used while loading"
  28.                 begin   >in @ >r
  29.                         begin   bl word c@ 0=           \ while word len=0
  30.                                                         \ discard line after "\"
  31.                                 here " \" ">$ dup c@ 1+ caps-comp 0= or
  32.                                 outbuf c@ 2 > and       \ while read length<>0
  33.                         while   r>drop 0 >r             \ save beginning of buf
  34.                                 filltib                 \ refill tib
  35.                         repeat
  36.                         here " ;" ">$ dup c@ 1+ caps-comp
  37.                         0<>                             \ word <> ";" and
  38.                         here c@ 0<> and                 \ word length <> 0
  39.                 while   r> >in ! VARIABLE
  40.                 repeat  r>drop ;
  41.  
  42. \s      An example of how to use CONSTANTS and VARIABLES
  43.  
  44. constants
  45.         34 george                       \ allows these type of comments only"\"
  46.         26 bob
  47.         18 john  ;                      \ don't forget the terminating ";"
  48.  
  49. VARIABLES
  50.         tom     dick    harry
  51.         jerry   bobby   robert  ;      \ again, don't forget the ";"
  52.  
  53.  
  54.