home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FUZZY.ZIP / IO.S < prev    next >
Text File  |  1986-11-30  |  5KB  |  82 lines

  1. -------------------------------------------------------------------------------
  2. --                                                                           --
  3. --  Library Unit:  io  --  Source and Listing I/O                            --
  4. --                                                                           --
  5. --  Author:  Bradley L. Richards                                             --
  6. --                                                                           --
  7. --     Version     Date     Notes . . .                                      --
  8. --    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    --
  9. --       1.0     6 Feb 86   Initial Version                                  --
  10. --       1.1    25 Feb 86   Minor revisions to error messages                --
  11. --       1.2     4 Mar 86   Added 2 character lookahead (required to         --
  12. --                            differentiate between the Ada ellipse and      --
  13. --                            a floating point number).                      --
  14. --       1.3    22 May 86   Split error handlers into separate package       --
  15. --                            to limit higher level visibility               --
  16. --       1.4    18 Jun 86   Allow variable lookahead (1 or 2 characters)     --
  17. --       2.0    20 Jun 86   Version number change only (for consistancy)     --
  18. --       2.1    13 Jul 86   Fixed bugs pertaining to interactive i/o         --
  19. --                          Split into separate spec and body files          --
  20. --    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    --
  21. --                                                                           --
  22. --  Library units used:  text_io                                             --
  23. --                                                                           --
  24. --  Description:  This package handles all source file access and listing    --
  25. --     output for an interpreter or compiler.  It assumes a maximum output   --
  26. --     file width of 132 characters; since it reserves the first seven       --
  27. --     character positions for line numbering, it accepts a maximum of       --
  28. --     125 characters on an input line (defined as a constant in the         --
  29. --     package specification).                                               --
  30. --          The package suppresses empty lines entirely.  When it reaches    --
  31. --     the end of a line which did contain data, it returns an ascii.cr as   --
  32. --     the end-of-line delimiter.                                            --
  33. --          To initialize the package, call start_io with the names of the   --
  34. --     source and listing files.  Characters are retrieved by get_char,      --
  35. --     which returns the current character and two lookahead characters.     --
  36. --     The first character retrieved from any file is an ascii.nul (in       --
  37. --     other words, the true first character appears initially as the        --
  38. --     first lookahead character.  When the end of the source file is        --
  39. --     reached get_char returns an ascii.eot.  further read requests         --
  40. --     produce more ascii.eot characters.                                    --
  41. --          Comments may be inserted with the routines "lput," "lput_line,"  --
  42. --     and "lnew_line."  These are equivalent to the normal text_io          --
  43. --     routines, but take the listing format into account.  If desired, a    --
  44. --     pointer to the current character can be printed by "pointer."         --
  45. --          If the listing file name is empty then listing output and        --
  46. --     pointers are suppressed and comments are written to the standard      --
  47. --     output with line and character number references.                     --
  48. --          After everything is finished, stop_io will tidy up the           --
  49. --     files, and handle any post_processing required by the package.        --
  50. --                                                                           --
  51. -------------------------------------------------------------------------------
  52.  
  53. -------------------------------------------------------------------------------
  54. --                                                                           --
  55. --                          Package Specification                            --
  56. --                                                                           --
  57. -------------------------------------------------------------------------------
  58.  
  59. with text_io; use text_io;
  60. package io is
  61.  
  62.     subtype vision is integer range 1..2;
  63.  
  64.     max_line_length : constant integer := 125;
  65.     current_char : character;
  66.     look_ahead_char : character := ascii.nul;
  67.     look_ahead_2_char : character := ascii.nul;
  68.  
  69.     procedure get_char;
  70.     procedure lnew_line;
  71.     procedure lput(comment : in string);
  72.     procedure lput_line(comment : in string);
  73.     procedure print_pointer;
  74.     procedure start_io(source_name, listing_name : string; look_ahead : vision);
  75.     procedure stop_io;
  76.  
  77.   private
  78.  
  79.     function internal_get_char return character;
  80.  
  81. end io;
  82.