///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Compiler                               //
//                                                                           //
//                   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        := EXPR_OR_LOGIC;

  - copyright   := "2003-2007 Benoit Sonntag";

  
  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "Or binary logical expression.";
  
Section Inherit
  
  + parent_expr_binary_logic:Expanded EXPR_BINARY_LOGIC;
  
Section Public  
  
  + symbol:STRING_CONSTANT := "|";
  
  //
  // Execute.
  //
 
  - exec_conservator_left  left_cst :TYPE :EXPR <- 
  //-- FALSE | E -> E
  ( + result:EXPR;

    (left_cst = type_false).if { 
      result := right;
      left.remove;
    };
    result
  );
  
  - exec_conservator_right right_cst:TYPE :EXPR <- 
  //-- E | FALSE -> E
  ( + result:EXPR;

    (right_cst = type_false).if {
      result := left;
      right.remove;
    };
    result
  );
  
  - exec left_cst:TYPE and right_cst:TYPE :EXPR <-
  //-- C1 | C2 -> C3
  ( + result:EXPR;

    (left_cst = type_true).if {
      result := left;
      right.remove;
    } else {
      result := right;
      left.remove;
    };    
    result
  );
  
  - exec:EXPR <- 
  //-- (E1 > E2) | (E1 = E2) -> E1 >= E2 (a lot of possibilities, but see INTEGER)
  //-- E | E -> E
  ( + result:EXPR;
    + sup:EXPR_SUP;
    + eq:EXPR_EQUAL;

    (left == right).if {
      result := left;
      right.remove;
    } else {
      sup ?= left;
      eq  ?= right;
      ((sup != NULL) && {eq != NULL}).if {
	((sup.left == eq.left) && {sup.right == eq.right}).if {
	  result := EXPR_SUP_EQ.create position with (sup.left) and (sup.right);
	  right.remove;
	};
      };
    };
    result      
  );

  - exec_left  left_cst :TYPE :EXPR <- 
  //-- TRUE | E -> TRUE
  ( + result:EXPR;

    (left_cst = type_true).if {
      result := left;
      right.remove;
    };
    result
  );
  
  - exec_right right_cst:TYPE :EXPR <- 
  //-- E | TRUE -> TRUE
  ( + result:EXPR;
    
    (right_cst = type_true).if {
      result := right;
      left.remove;
    };
    result
  );
  
  






