///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Library                                //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header
  
  + name        := STD_INPUT;


  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
  
  - comment     :=" To use the standard input file. As for UNIX, the default standard input is the keyboard.";
      
Section Inherit
  
  - parent_input_stream:INPUT_STREAM := INPUT_STREAM;
  
Section Private

  - memory:CHARACTER;
  // Memory of the last available user's value.

Section Public
  
  - is_connected:BOOLEAN := TRUE;
  
  - read_character:CHARACTER<-
  (
    push_back_flag.if {
      push_back_flag := FALSE;
    } else {
      memory := basic_io_getc;
    };
    last_character
  );
  
  
  - unread_character <-
  (
    push_back_flag := TRUE;
  );
  
  
  - last_character:CHARACTER <-
  (
    memory
  );
  
  
  - end_of_input:BOOLEAN <-
  (
    + result:BOOLEAN;
    (! push_back_flag).if {
      result := (memory = basic_io_eof);
    };
    result
  );
  
  - read_line_in str:STRING <-
  (
    + mem:CHARACTER;
    read_character;
    ( (last_character != '\n') && { memory != basic_io_eof } ).if {
      str.extend memory;
      mem := basic_io_getc;
      
      { (mem = basic_io_eof) || {mem = '\n'} }.until_do {
	str.extend mem;
	mem := basic_io_getc;
      };
      memory := mem;
    };
  );
    


