/* ======================================================================
DESC: defines p to be the position of the main connective, c to the connective

RETURNS: c, the main connective

PLATFORMS: 

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

function mainConn(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(0) == '~' ) {  c = '~' } 
	return c
}

