src/PredFinder/macros/IndividualParameter.cpp
/**
 * Reads the individual parameter in some operator
 * context from the specified S-expression.
 *
 * @param sexp The read S-expression.
 *
 * @author nward@bbn.com
 * @date 2010.10.05
 **/
Reads the individual parameter in some operator
context from the specified S-expression.

@param sexp The read S-expression.


Reads the individual parameter in some operator context from the specified S - expression . @param sexp The read S - expression .
IndividualParameter::IndividualParameter(Sexp* sexp) : ReadingMacroParameter(sexp) {
	std::stringstream error;
	if (sexp->getNumChildren() < 2 || sexp->getNumChildren() > 4) {
		error << "Ill-formed individual parameter: need 2-4 top-level nodes; got " << sexp->getNumChildren();
		error << " " << sexp->to_debug_string();
		throw UnexpectedInputException("IndividualParameter::IndividualParameter(Sexp*)", error.str().c_str());
	}
	if (sexp->getFirstChild()->isList() || sexp->getFirstChild()->getValue() !=  ReadingMacroParameter::INDIVIDUAL_SYM) {
		error << "Ill-formed individual parameter: need individual expression; got ";
		error << " " << sexp->getFirstChild()->to_debug_string();
		throw UnexpectedInputException("IndividualParameter::IndividualParameter(Sexp*)", error.str().c_str());
	}
	int child = 1;
	if (_shortcut_name != Symbol())
		child++;
	if (child >= sexp->getNumChildren()) {
		error << "Ill-formed individual parameter: need 1-2 top-level nodes after shortcut; got none";
		error << " " << sexp->to_debug_string();
		throw UnexpectedInputException("IndividualParameter::IndividualParameter(Sexp*)", error.str().c_str());
	}
	if (sexp->getNthChild(child)->isAtom())
		_individual_type = sexp->getNthChild(child)->getValue().to_string();
	else {
		error << "Ill-formed individual parameter: need ontology type atom; got ";
		error << " " << sexp->getNthChild(sexp->getNumChildren() - 1)->to_debug_string();
		throw UnexpectedInputException("IndividualParameter::IndividualParameter(Sexp*)", error.str().c_str());
	}
	child++;
	if (child < sexp->getNumChildren()) {
		if (sexp->getNthChild(child)->isAtom())
			_individual_value = sexp->getNthChild(child)->getValue().to_string();
		else {
			error << "Ill-formed individual parameter: need ontology type atom; got ";
			error << " " << sexp->getNthChild(sexp->getNumChildren() - 1)->to_debug_string();
			throw UnexpectedInputException("IndividualParameter::IndividualParameter(Sexp*)", error.str().c_str());
		}
	} else
		_individual_value = L"";
}
IndividualParameter :: IndividualParameter ( Sexp * sexp ) : ReadingMacroParameter ( sexp ) { std :: stringstream error ; if ( sexp -> getNumChildren ( ) < 2 || sexp -> getNumChildren ( ) > 4 ) { error << " " << sexp -> getNumChildren ( ) ; error << " " << sexp -> to_debug_string ( ) ; throw UnexpectedInputException ( " " , error . str ( ) . c_str ( ) ) ; } if ( sexp -> getFirstChild ( ) -> isList ( ) || sexp -> getFirstChild ( ) -> getValue ( ) != ReadingMacroParameter :: INDIVIDUAL_SYM ) { error << " " ; error << " " << sexp -> getFirstChild ( ) -> to_debug_string ( ) ; throw UnexpectedInputException ( " " , error . str ( ) . c_str ( ) ) ; } int child = 1 ; if ( _shortcut_name != Symbol ( ) ) child ++ ; if ( child >= sexp -> getNumChildren ( ) ) { error << " " ; error << " " << sexp -> to_debug_string ( ) ; throw UnexpectedInputException ( " " , error . str ( ) . c_str ( ) ) ; } if ( sexp -> getNthChild ( child ) -> isAtom ( ) ) _individual_type = sexp -> getNthChild ( child ) -> getValue ( ) . to_string ( ) ; else { error << " " ; error << " " << sexp -> getNthChild ( sexp -> getNumChildren ( ) - 1 ) -> to_debug_string ( ) ; throw UnexpectedInputException ( " " , error . str ( ) . c_str ( ) ) ; } child ++ ; if ( child < sexp -> getNumChildren ( ) ) { if ( sexp -> getNthChild ( child ) -> isAtom ( ) ) _individual_value = sexp -> getNthChild ( child ) -> getValue ( ) . to_string ( ) ; else { error << " " ; error << " " << sexp -> getNthChild ( sexp -> getNumChildren ( ) - 1 ) -> to_debug_string ( ) ; throw UnexpectedInputException ( " " , error . str ( ) . c_str ( ) ) ; } } else _individual_value = L" " ; }
Reads the individual parameter in some operator
 context from the specified S-expression.
Reads the individual parameter in some operator context from the specified S - expression .
// Local error messages
 // Make sure we have an S-expression worth reading
 // Make sure this is an individual expression
 // Check if we need to start reading subexpressions after a shortcut expression
 // Make sure we have a type specification
 // Get the type specification
 // Get the optional value specification
