The GNU Modula-2 front end to GCC

gm2-libs/PushBackInput

DEFINITION MODULE PushBackInput ;

(*
    Description: provides a method for pushing back and consuming input
                 from a standard file descriptor. Insipred by software
                 tools.
*)

FROM FIO IMPORT File ;
FROM DynamicStrings IMPORT String ;

EXPORT QUALIFIED Open, PutCh, GetCh, Error, WarnError, WarnString,
                 Close, SetDebug, GetExitStatus,
                 PutString, GetColumnPosition, GetCurrentLine ;


(*
   Open - opens a file for reading.
*)


PROCEDURE Open (a: ARRAY OF CHAR) : File ;


(*
   GetCh - gets a character from either the push back stack or
           from file, f.
*)


PROCEDURE GetCh (f: File) : CHAR ;


(*
   PutCh - pushes a character onto the push back stack, it also
           returns the character which has been pushed.
*)


PROCEDURE PutCh (f: File; ch: CHAR) : CHAR ;


(*
   PutString - pushes a string onto the push back stack.
*)


PROCEDURE PutString (f: File; a: ARRAY OF CHAR) ;


(*
   Error - emits an error message with the appropriate file, line combination.
*)


PROCEDURE Error (a: ARRAY OF CHAR) ;


(*
   WarnError - emits an error message with the appropriate file, line combination.
               It does not terminate but when the program finishes an exit status of
               1 will be issued.
*)


PROCEDURE WarnError (a: ARRAY OF CHAR) ;


(*
   WarnString - emits an error message with the appropriate file, line combination.
                It does not terminate but when the program finishes an exit status of
                1 will be issued.
*)


PROCEDURE WarnString (s: String) ;


(*
   Close - closes the opened file.
*)


PROCEDURE Close (f: File) ;


(*
   GetExitStatus - returns the exit status which will be 1 if any warnings were issued.
*)


PROCEDURE GetExitStatus () : CARDINAL ;


(*
   SetDebug - sets the debug flag on or off.
*)


PROCEDURE SetDebug (d: BOOLEAN) ;


(*
   GetColumnPosition - returns the column position of the current character.
*)


PROCEDURE GetColumnPosition () : CARDINAL ;


(*
   GetCurrentLine - returns the current line number.
*)


PROCEDURE GetCurrentLine () : CARDINAL ;


END PushBackInput.