/* ======================================================================
DESC: 		Checks for membership in SL and defines component structure CS[]
							[this is just a version of isSL() ]
CS provides a connective position's immediate component positions.  comp gives each position's component
while compOrder provides an ordering for connective evaluation.  absMcPos gives the main connective position
of each comp's position in full sentence (=text).
USAGE NOTES: structureSL()  removes spaces and adds parens if needed, then returns structure().

	The functions here require simp.js and mainC.js to work!!!
====================================================================== */

/* ======================================================================
FUNCTIONS: 	structureSL(), structure()

INPUT:		text string
				
RETURNS:		boolean (true iff text is an SL sentence)

DESC:					
====================================================================== */
var pos; var k;
CS = new Array; comp = new Array; compOrder = new Array; absMcPos = new Array
function structureSL(text)  {
k=1; pos = 0
text = deSpace(text);
mainConn(dropParen(text));
	if ( biC.indexOf(c)>-1 && !out(text)  )   {
			text = '[' + text + ']'; p++
	}
comp[p] = text; absMcPos[p] = p;
compOrder[0] = p; newtext = text; nowtext = text
	return structure(text);
}
function structure(text)  {
	if ( text.length == 1 && atomic.indexOf(text) > -1 )   {
		CS[pos] = text; 
		return true; 
		}
	else if ( mainConn(dropParen(text)) == '~' && text.charAt(0) == '~')  { 
		gamma = text.substring(1);
		var x = pos
		pos += 1;
		mainConn(dropParen(gamma));
		if ( biC.indexOf(c) > -1 ) {
   		p++			}
		CS[x] = p + pos;
		var y = CS[x];
		comp[y] = gamma; absMcPos[y] = p
		compOrder[k] = y; k++
		return structure(gamma);
		}
	else if ( biC.indexOf(c) > -1 && out(text) )  { 
	x = p +  ++pos;
	alpha = text.substring(1,p+1); 
	mainConn(dropParen(alpha));
		if ( biC.indexOf(c) > -1 ) {
   		p++
			}
	y = pos + p
	CS[x] = y
	comp[y] = alpha; absMcPos[y] = p
	compOrder[k] = y; k++
		CS[x] += '|';
	if ( !structure(alpha) )  {
		return false;} 
	else { mainConn(dropParen(text));
	beta = text.substring(p+2,text.length - 1);
	pos = x + 1;
	mainConn(dropParen(beta));
		if ( biC.indexOf(c) > -1 ) {
   		p++
			}	
	l = pos + p;
	CS[x] += '' + l
		comp[l] = beta; absMcPos[l] = p
		compOrder[k] = l; k++
	if ( !structure(beta) )  {
		return false;}  
	else {return true}
}}
else { return false }
}

