home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / language / forst / detab.s < prev    next >
Encoding:
Text File  |  1993-10-23  |  778 b   |  45 lines

  1. : task ;
  2.  
  3. decimal
  4.  
  5. 9 constant tab
  6. 8 constant tabwidth
  7. -1 constant eof
  8. 64 constant maxline
  9. 13 constant cret
  10. 10 constant lfeed
  11.  
  12. 0 constant rd
  13. 1 constant wr
  14.  
  15. variable col
  16. file file1
  17. file file2
  18.  
  19. : .newline  cret file2 putc  lfeed file2 putc  0 col ! ;
  20. : emit_char ( char--)  file2 putc  1 col +! ;
  21.  
  22. : ?emit  ( char--)
  23.   dup lfeed  =  if  drop exit  then
  24.   dup cret   =  if  drop .newline exit  then
  25.   emit_char ;
  26.   
  27. : dotab
  28.   begin  bl emit_char  col @ tabwidth mod  0= until ;
  29.   
  30. : detab  { 1 reg char }
  31.  
  32.    file1 rd namearg fopen
  33.    file2 wr namearg fopen
  34.    cr  0 col !
  35.  
  36.    begin
  37.      file1 getc  to char
  38.      char eof = not
  39.    while
  40.      char tab =
  41.      if  dotab  else char ?emit  then
  42.    repeat
  43.    
  44.    file1 fclose   file2 fclose ;
  45.