/* ======================================================================
DESC: 

PLATFORMS: 

USAGE NOTES:  requires simp.js, def.js
====================================================================== */

/* ======================================================================
FUNCTION: 	

INPUT:		
				
RETURNS:		

DESC:							
====================================================================== */
function mainLO(text) {
	text = dropParen(deSpace(text))
	var left = 0; p = 0; c = null
	outer: 
	 for ( var i=0; i<text.length; i++ ) {
    	if (  text.charAt(i)=='(' || text.charAt(i)=='[' )  left++
    	else if ( text.charAt(i)==')' || text.charAt(i)==']' )   left--
      else if ( left == 0 )   {
       	for ( var j=0; j<4; j++ ) {
       		if ( text.charAt(i) == BiC[j] ) {
          		c = BiC[j];
          		p = i;
          		break outer;
       		}     
       	}
       }
     }
if ( p != 0) return c
else return unaryTest(text)
}

function unaryTest(text) {
	if ( text.charAt(1) == '%' ) { p = 1; c = '%' } 
	else if ( text.charAt(1) == '^' ) { p = 1; c = '^' } 
	else if ( text.charAt(0) == '~' ) {  c = '~' } 
	return c
}

