home *** CD-ROM | disk | FTP | other *** search
- -------------------------------------------------------------------------------
- -- --
- -- Library Unit: io -- Source and Listing I/O --
- -- --
- -- Author: Bradley L. Richards --
- -- --
- -- Version Date Notes . . . --
- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
- -- 1.0 6 Feb 86 Initial Version --
- -- 1.1 25 Feb 86 Minor revisions to error messages --
- -- 1.2 4 Mar 86 Added 2 character lookahead (required to --
- -- differentiate between the Ada ellipse and --
- -- a floating point number). --
- -- 1.3 22 May 86 Split error handlers into separate package --
- -- to limit higher level visibility --
- -- 1.4 18 Jun 86 Allow variable lookahead (1 or 2 characters) --
- -- 2.0 20 Jun 86 Version number change only (for consistancy) --
- -- 2.1 13 Jul 86 Fixed bugs pertaining to interactive i/o --
- -- Split into separate spec and body files --
- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
- -- --
- -- Library units used: text_io --
- -- --
- -- Description: This package handles all source file access and listing --
- -- output for an interpreter or compiler. It assumes a maximum output --
- -- file width of 132 characters; since it reserves the first seven --
- -- character positions for line numbering, it accepts a maximum of --
- -- 125 characters on an input line (defined as a constant in the --
- -- package specification). --
- -- The package suppresses empty lines entirely. When it reaches --
- -- the end of a line which did contain data, it returns an ascii.cr as --
- -- the end-of-line delimiter. --
- -- To initialize the package, call start_io with the names of the --
- -- source and listing files. Characters are retrieved by get_char, --
- -- which returns the current character and two lookahead characters. --
- -- The first character retrieved from any file is an ascii.nul (in --
- -- other words, the true first character appears initially as the --
- -- first lookahead character. When the end of the source file is --
- -- reached get_char returns an ascii.eot. further read requests --
- -- produce more ascii.eot characters. --
- -- Comments may be inserted with the routines "lput," "lput_line," --
- -- and "lnew_line." These are equivalent to the normal text_io --
- -- routines, but take the listing format into account. If desired, a --
- -- pointer to the current character can be printed by "pointer." --
- -- If the listing file name is empty then listing output and --
- -- pointers are suppressed and comments are written to the standard --
- -- output with line and character number references. --
- -- After everything is finished, stop_io will tidy up the --
- -- files, and handle any post_processing required by the package. --
- -- --
- -------------------------------------------------------------------------------
-
- -------------------------------------------------------------------------------
- -- --
- -- Package Specification --
- -- --
- -------------------------------------------------------------------------------
-
- with text_io; use text_io;
- package io is
-
- subtype vision is integer range 1..2;
-
- max_line_length : constant integer := 125;
- current_char : character;
- look_ahead_char : character := ascii.nul;
- look_ahead_2_char : character := ascii.nul;
-
- procedure get_char;
- procedure lnew_line;
- procedure lput(comment : in string);
- procedure lput_line(comment : in string);
- procedure print_pointer;
- procedure start_io(source_name, listing_name : string; look_ahead : vision);
- procedure stop_io;
-
- private
-
- function internal_get_char return character;
-
- end io;
-