/**
 * Function representing the <o_list_prime> productions
 */
void RecursiveDescentParser::o_list_prime(ParamList* &pList) {
	if(errorCondition) return;
	if(token == TK_COMMA) 
	{
#if DEBUG_PARSER
		std::cout << "<o_list_prime> --> ,<oelem><o_list_prime>\n";
#endif
		token = scanner->getToken();
		
		attr elemAttr = oelem(pList);
		/* delay the genration of TAC until we know it's a 
		 * function call, might just be printf
		iCode.threeAddressCode(TAC_PARAM, elemAttr.addr);
		*/
		o_list_prime(pList);
	}
	else if(token == TK_RIGHT_PARENTHESES || token == TK_SEMICOLON) 
	{
#if DEBUG_PARSER
		std::cout << "<o_list_prime> --> e\n";
#endif
	}
	else 
	{
		errorHandler();
	}
}
/**
 * Function representing the <o_list> productions
 */
ParamList* RecursiveDescentParser::o_list() {
	ParamList* pList = NULL;
	
	if(errorCondition) return pList;
	
	if(token == TK_IDENTIFIER || token == TK_NUM ||
			token == TK_CHAR_CONST) 
	{
#if DEBUG_PARSER
		std::cout << "<o_list> --> <oelem><o_list_prime>\n";
#endif
		pList = new ParamList();
		
		attr elemAttr = oelem(pList);
		/* delay the genration of TAC until we know it's a 
		 * function call, might just be printf
		iCode.threeAddressCode(TAC_PARAM, elemAttr.addr);
		*/
		o_list_prime(pList);		
	}
	else
	{
		errorHandler();
	}
	
	return pList;
}
Example #3
0
ElementList* Node::getSeparateElements( FaceList* list ){

  // Collect ONLY regular faces - not in cohesive,
  // not boundary, not in the "list" ("list" is a facelist of
  // the faces involving the node that is trying to be separated). 
  
  //"list" is used as a separator list of faces.  We need to build a list of
  //faces that CAN be traversed. That list will be node_faces.
  
  FaceList node_faces;
  int i;
  for( i = 0; i < d_numFaces; i++ ){
  	//step through all the faces in the d_faces array for this node.
    Face *face = d_faces[i];
    //see if each face is on the "list" of separable faces sent in.
    if( list->move_to( face )){
      continue; //if it is, then go to the next face. 
    }
    
    //if this face is an exterior face, or if either element that it
    //is associated with is cohesive, then don't add it to the facelist. 
    if( !face->getElement2() || face->getElement1()->isCohesive() ||
	face->getElement2()->isCohesive() ){
      continue;
    }
    node_faces.insert_first( face );
  }
  
  //count the number of non-cohesive ("real") elements attached to this node. 
  int count_real=0;
  for( i = 0; i < d_numElements; i++ ){
    if( !d_elements[i]->isCohesive() ){
      count_real++;
    }
  }
  
  // Try to find ONE non-cohesive element.  Note the "break" in the "if" 
  // below if one is found!
  ElementList *shared_elements = new ElementList;
  for( i = 0; i < d_numElements; i++ ){
    if( !d_elements[i]->isCohesive() ){
      shared_elements->insert_first(d_elements[i]);
      break;
    }
  }
  
  //We should always find at least one non-cohesive element (says Alla). 
  if( shared_elements->size() != 1 ){
    // thoretically this should not happen (pure cohesive node)
    delete shared_elements;
    return 0;  //get out of town if node is pure cohesive - can't separate. 
  }

  // Since we found one non-cohesive element, now try to add more
  boolean changed = TRUE;
  while( changed ) { 
    changed = FALSE;
    //number of faces with non-cohesive or non-exterior elements on both sides. 
    int size = node_faces.size();  
    int i;
    //loop over all the candidate faces for this node. 
    for( i = 0; i < size; i++ ) { 
      //retrieve the list of faces for this node.
      Face* face = node_faces.get();  
      boolean found=FALSE;
      // check if face belongs to any shared element
      shared_elements->reset();
      int nums = shared_elements->size();
      int j;
      //for each element in the shared_elements list...
      for( j = 0; j < nums; j++ ) {
		Element* sh_el = shared_elements->get();
		Element* oelem(0);
		//check and see if the current face involves one of the elements on the list.
		//If so, get the other element that is on the other side of the face (put 
		//in oelem). 
		if( face->getElement1() == sh_el ){
	  		oelem = face->getElement2();
		}
		else if( face->getElement2() == sh_el ){
	  		oelem = face->getElement1();
		}
		//if find the second element ...
		if( oelem ){
	  		found = TRUE;
	  		//if it's not already on the shared elements list, then put it on the list. 
	  		if( !shared_elements->move_to( oelem ) ){
	    		shared_elements->insert_first( oelem );
	  		}
	  		break; //exit j loop (element loop)
		}
		
		//get ready to check the next element. 
		shared_elements->next();
		
      } //for (j=0...
      
      if( found ){ 
      	//remove the current face from the facelist
		node_faces.remove();
		//get ready to look at the new facelist (sans the current face)
		changed = TRUE;
		//exit the i loop and go back to the while (start over with new list of faces)
		break;
      }
      
      //one of the faces must be part of elements that are already on the list, so go on!
      node_faces.next();
      
    } //for (i=0 ...
  } //while(changed)
  
  // count_real is the number of non-cohesive elements attached to this node.
  // have separation surface
  //if the actual number of elements is greater than the number you found, then there must
  //be a separation plane.  If it is the same, then you went all the way around and found no
  //boundary.
  if( count_real > shared_elements->size() ){
    return shared_elements;
  }
  delete shared_elements;
  return 0;
}