int is_effEnd(FullHist* tree, FullHist* child) { if(!tree) return 1; if(Term::fromInt(tree->term)->isRoot()) return 1; int loc = 0; int sz = tree->size; FullHist** fhs = tree->fharray; for( ; ; loc++) { assert(loc < sz); FullHist* nxt = fhs[loc]; assert(nxt); if(nxt != child) continue; loc++; if(loc == sz) return is_effEnd(tree->back,tree); nxt = fhs[loc]; ECString ntrmNm = Term::fromInt(nxt->term)->name(); const Term* ntrm = Term::get(ntrmNm); if(ntrm== Term::stopTerm) return is_effEnd(tree->back,tree); if(ntrm->isColon() || ntrm->isFinal()) return 1; if(ntrm->isComma()) return 0; loc++; if(loc == sz) return 0; nxt = fhs[loc]; ntrmNm = Term::fromInt(nxt->term)->name(); if(ntrmNm == "''") return 1; return 0; } error("should not get here"); return 0; }
int is_effEnd(InputTree* tree, InputTree* child) { if(!tree) return 1; const Term* trm = Term::get(tree->term()); if(trm->isRoot()) return 1; InputTreesIter iti = tree->subTrees().begin(); for( ; ; iti++) { assert(iti != tree->subTrees().end()); InputTree* nxt = (*iti); assert(nxt); if(nxt != child) continue; iti++; if(iti == tree->subTrees().end()) return is_effEnd(tree->parent(),tree); nxt = (*iti); ECString ntrmNm = nxt->term(); const Term* ntrm = Term::get(ntrmNm); if(ntrm== Term::stopTerm) return is_effEnd(tree->parent(),tree); if(ntrm->isColon() || ntrm->isFinal()) return 1; if(ntrm->isComma()) return 0; iti++; if(iti == tree->subTrees().end()) return 0; nxt = (*iti); if(nxt->term() == "''") return 1; return 0; } error("should not get here"); return 0; }
int tree_mE(TreeHist* treeh) { int m = tree_grandparent_term(treeh); int e = is_effEnd(treeh->tree->parent(), treeh->tree); return m+(e*150); }
int tree_vE(TreeHist* treeh) { int v = tree_parent_pos(treeh); int e = is_effEnd(treeh->tree->parent(), treeh->tree); return v+(e*MAXNUMNTS); }
int fh_mE(FullHist* treeh) { int m = fh_grandparent_term(treeh); int e = is_effEnd(treeh->back, treeh); //if(treeh->e) cerr << "Me " << e << " " << treeh->term << endl; return m+(e*150); }
int fh_vE(FullHist* treeh) { int v = fh_parent_pos(treeh); int e = is_effEnd(treeh->back, treeh); //cerr << e << " " << *treeh->e << endl; return v+(e*MAXNUMNTS); }