//----------------------------------------------------------------------------- // Makes a complete expression :: <term> { <cond> <term> }. //----------------------------------------------------------------------------- static void MakeExpression( ExprTree& tree ) { // Make a term, setting Tree to point to it MakeTerm( tree ); // while the next token is a conditional while ( IsConditional( mCurToken ) ) { // Make a conditional node, setting left child to Tree and right to NULL. (Tree points to new node) MakeExprNode( tree, mCurToken, CONDITIONAL, tree, NULL ); // Get the next token. GetNextToken(); // Make a term, setting the right child of Tree to point to it. MakeTerm( tree->right ); } }
bool CSemanticsHolder::BuildColloc (string ContentFieldStr, int CollocUnitNo) { size_t i = ContentFieldStr.find("("); if (i == -1) { CColloc C; C.UnitNo = CollocUnitNo; C.IsBlackBox = !FindField (GetRoss(CollocRoss), CollocUnitNo, "AUX"); C.IsConditional = IsConditional (*GetRossHolder(CollocRoss), CollocUnitNo); C.m_SemMainWord = GetRossHolder(CollocRoss)->GetSemMainWordFromArticle(CollocUnitNo); // Build items string ItemStr = ContentFieldStr; TrimLeft(ContentFieldStr); while (!ContentFieldStr.empty()) { int j = ContentFieldStr.find_first_of(" \t"); string Q = ContentFieldStr.substr (0, j); ContentFieldStr.erase(0, j); CCollocItem CollocItem; if (!CollocItem.InitCollocItem(Q)) { string mess = "Unbound reloperator in "; mess += GetRoss(CollocRoss)->GetEntryStr(C.UnitNo); ErrorMessage(mess); }; C.Items.push_back(CollocItem); TrimLeft(ContentFieldStr); } if (!GetRoss(CollocRoss)->IsEmptyArticle(CollocUnitNo)) // по словарной статье for (size_t j = GetRoss(CollocRoss)->GetUnitStartPos(CollocUnitNo); j <= GetRoss(CollocRoss)->GetUnitEndPos(CollocUnitNo); j++) { TCortege Cort = GetCortege(GetRoss(CollocRoss), j); //незаполненное поле? if (Cort.m_DomItemNos[0] == -1) continue; // строю массив U.m_Places по полю CONTENT string FieldStr = (const char*)GetRoss(CollocRoss)->Fields[Cort.m_FieldNo].FieldStr; // инициализирую перечень всех необходимых синтаксических отношений их поля SYNREP if ( (FieldStr == "SYNR") && (Cort.m_LeafId == 0) && (Cort.m_BracketLeafId == 0) ) { string F = GetRossHolder(CollocRoss)->GetDomItemStrInner(Cort.m_DomItemNos[1]); long PlaceNo1 = F[1] - '0' - 1; F = GetRossHolder(CollocRoss)->GetDomItemStrInner(Cort.m_DomItemNos[2]); long PlaceNo2 = F[1] - '0' - 1; string SynGrp = GetRossHolder(CollocRoss)->GetDomItemStrInner(Cort.m_DomItemNos[0]); rml_TRACE (SynGrp.c_str()); if ( (PlaceNo1 >= C.Items.size()) || (PlaceNo2 >= C.Items.size()) ) { string mess = "Error in SYNREP in "; mess += GetRoss(CollocRoss)->GetEntryStr(C.UnitNo); ErrorMessage(mess); return false; }; C.m_Rels.push_back(CSynRelation(PlaceNo1, PlaceNo2, SynGrp)); }; } m_RusCollocs.push_back(C); } else { size_t k = ContentFieldStr.find (")"); if (k == -1) { ErrorMessage(Format ("Error in parenthesis in colloc %s", ContentFieldStr.c_str())); return false; }; size_t last_j = i; for (size_t j= i+1; j <= k; j++) { if ( (j == k) || (ContentFieldStr[j] == '|')) { string q; if (i >0) q += ContentFieldStr.substr(0, i-1); q += string(" "); q += ContentFieldStr.substr(last_j+1, j-last_j-1); q += string(" "); if ( k-1 < ContentFieldStr.length() ) q += ContentFieldStr.substr(k+1); if (!BuildColloc(q, CollocUnitNo) ) return false; last_j = j; }; }; }; return true; };