///////////////////////////////////////////////////////////////////////////////
//                             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    := Expanded BOOLEAN;


  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";

  - comment := "Boolean library (self is mapping on int C).";

  - type    := `char`;
  - default := FALSE;
  
Section Insert
  
  - parent_object:OBJECT := OBJECT;
  
Section Private  
  
  - deferred_boolean:BOOLEAN <-
  ( + result:BOOLEAN;
    
    deferred;
    result
  );
  
Section Public

  //
  // Conditional :
  //
  
  - if_true block:BLOCK  <- deferred;
  
  - if_false block:BLOCK <- deferred;
  
  - if true_block:BLOCK else false_block:BLOCK <- `ERROR`; //deferred;
  
  - if_true true_block:BLOCK else false_block:BLOCK <- deferred;
  
  - if_false true_block:BLOCK else false_block:BLOCK <- deferred;
  
  - if true_block:BLOCK :BOOLEAN <- deferred_boolean;
  
  - elseif cond:BLOCK then block:BLOCK :BOOLEAN <- deferred_boolean;
  
  - elseif cond:BLOCK then block:BLOCK else block_else:BLOCK <- deferred;
    
  - else_if cond:BLOCK then block:BLOCK :BOOLEAN <- 
  // Alias.
  elseif cond then block;
  
  - else_if cond:BLOCK then block:BLOCK else block_else:BLOCK <- 
  // Alias.
  elseif cond then block else block_else;
  
  //
  // Binary operator :
  //
  
  - '||' Left 10  other:BLOCK   :BOOLEAN <- deferred_boolean;
  
  - '&&' Left 20  other:BLOCK   :BOOLEAN <- deferred_boolean; 
  
  - '|'  Left 10  other:BOOLEAN :BOOLEAN <- deferred_boolean;
  
  - '&'  Left 20  other:BOOLEAN :BOOLEAN <- deferred_boolean;
  
  - '^' Left 10  other:BOOLEAN :BOOLEAN  <- deferred_boolean;
  
  - '->' Right 25 other:BOOLEAN :BOOLEAN <- deferred_boolean;

  - '->>' Right 25 other:BLOCK  :BOOLEAN <- deferred_boolean;
  
  - '=>' s:ABSTRACT_STRING <- deferred;
  
  //
  // Prefix operator
  //
  
  - '!' :BOOLEAN <- deferred;
  
  //
  // Convertion
  //
  
  - to_string:STRING <- 
  ( + result:STRING;
    
    deferred;
    result
  );
  
  - to_integer:INTEGER <- 
  ( + result:INTEGER;
    
    deferred;
    result
  );
  
  - to_character:CHARACTER <- 
  ( + result:CHARACTER;
    
    deferred;
    result
  );
  
  - append_in str:STRING <- str.append to_string;

  //
  // Output.
  //
  
  - print <-
  (
    to_string.print;
  );


