Esempio n. 1
0
NodeInt factor(){
	switch (CurrToken) {
		case NUMBER:{
			Token tok = mutch(NUMBER);
			return AddLeaf(tok, atoi(lexeme));
			break;
		}
		case IDENTIFIER:{
			mutch(IDENTIFIER);
			if(CurrToken == LEFT_BRECKET){
				int idNum = Lookup(lexeme,1,0);
				if (idNum < 0){
					printf("Syntax error:В строке %d использована не объявленая переменная \n",line);
					return 0;
				}
				NodeInt idLeaf = AddLeaf(IDENTIFIER, idNum);
				
				//mutch(LEFT_BRECKET);
				NodeInt nodeR =boool();
				//mutch(RIGHT_BRECKET);

				return AddNode(FUNCTION, idLeaf, 0, nodeR);
			}else {
				int idNum = Lookup(lexeme,0,0);
				if (idNum < 0){
					printf("Syntax error:В строке %d использована не объявленая переменная \n",line);
					return 0;
				}
				return AddLeaf(IDENTIFIER, idNum);
			}

			break;
		}


		case LEFT_BRECKET:{
			mutch(LEFT_BRECKET);
			if (RIGHT_BRECKET == CurrToken) {
				mutch(RIGHT_BRECKET);
				return	AddLeaf(EMPTY, 0);
			}
			NodeInt a = boool();
			mutch(RIGHT_BRECKET);
			return a;
			break;
		}
		default:
			//printf("Syntaxes error\n");
			break;
	}
	return -1;
}
Esempio n. 2
0
    virtual bool    EatKey( const plKey& key )
    {
        if( fCurrType != key->GetUoid().GetClassType() )
        {
            fCurrType = key->GetUoid().GetClassType();
            const char *className = plFactory::GetNameOfClass( fCurrType );
            fCurrTypeItem = AddLeaf( fTree, fCurrItem, className != nil ? className : "<unknown>", nil );
        }

        if( !fFilter )
            AddLeaf( fTree, fCurrTypeItem, key->GetUoid().GetObjectName().c_str(), new plKeyInfo( key, fCurrPage ) );
        return true;
    }
Esempio n. 3
0
void Manager::fillTree()
{
	initRootItems();

	TVINSERTSTRUCT tvi = { 0 };
	tvi.hInsertAfter = TVI_LAST;
	tvi.item.mask = TVIF_TEXT | TVIF_STATE;
	tvi.item.stateMask = TVIS_STATEIMAGEMASK;
	tvi.item.state = TreeItem::_UNCHECKED();

	mir_cslock lock(DBEntry::mutexDB);

	DBEntry *entry = DBEntry::getFirst();
	while (entry != NULL) {
		if ((UINT)entry->m_iFtpNum < m_rootItems.size()) {
			tvi.item.pszText = mir_a2t(entry->m_szFileName);
			tvi.hParent = m_rootItems[entry->m_iFtpNum]->m_handle;
			HTREEITEM hItem = TreeView_InsertItem(m_hwndFileTree, &tvi);
			AddLeaf(hItem, tvi.hParent, entry->m_fileID);
			FREE(tvi.item.pszText);
		}

		entry = DBEntry::getNext(entry);
	}
}
Esempio n. 4
0
    virtual bool    EatPage( plRegistryPageNode *page )
    {
        char    str[ 512 ];


        fCurrPage = page;
        const plPageInfo &info = page->GetPageInfo();
        sprintf( str, "%s->%s", info.GetAge().c_str(), info.GetPage().c_str());
        fCurrItem = AddLeaf( fTree, NULL, str, new plKeyInfo( nil, fCurrPage ) );

        fCurrType = (uint16_t)-1;
        page->LoadKeys();
        page->IterateKeys( this );
        return true;
    }
Esempio n. 5
0
NodeInt stmts(){
	if (EMPTY == CurrToken) {
		
		return AddLeaf(EMPTY, 0);
	}
	if (RIGHT_FIG_BRECKET == CurrToken) {
		return 1;
	}
	else {
		NodeInt stmtNode = stmt();
		if (stmtNode == 0) {
			return 0;
		}
		NodeInt stmtsNode = stmts();
		return AddNode(STMTS, stmtNode, 0,stmtsNode);
	}
}
Esempio n. 6
0
void StaticWorldObject::WalkTree(ssgEntity *e, sgVec3 initialpos)
{
  if (!e) return;
  if (e->isAKindOf (ssgTypeBranch()) )
  {
    ssgBranch *branch = (ssgBranch*) e ;
    for (int i=0; i<branch->getNumKids(); i++)
    {
      ssgEntity *kid = branch->getKid(i);
      assert(kid!=NULL);
      WalkTree(kid, initialpos);
    }
  }
  if ( e->isAKindOf ( ssgTypeLeaf () ) )
  {
    AddLeaf((ssgLeaf*)e, initialpos);
  }
}
Esempio n. 7
0
Node * buildST(int numberOfStrings) {
	root = initNode();
	previouslyNode = root;
	Node *sentinel = initNode();
	root->slink = sentinel;
	root->hook = &(sentinel->child);
	sentinel->child = root;
	sentinel->sdep = -1;
	Point *p = malloc(sizeof(Point));
	p->a = root;
	p->b = root;
	int i = 0;
	while (i < numberOfStrings) {
		p->s = 0;
		int j = 0;
		Ti[i][ni[i]] = '!';
		while (j <= ni[i]) {
			while (!DescendQ(p, Ti[i][j])) {
				AddLeaf(p, i, j);

				SuffixLink(p);
			}
			Descend(p);
			j++;
		}
		Ti[i][ni[i]] = '-';
		i++;
		p->a = root;
		p->b = root;
		previouslySplit = NULL;
		previouslyNode = root;
	}
	free(p);
	free(sentinel);
	return root;
}
Esempio n. 8
0
void
AnimationSelector::Reload(void)
{
	resetState();

	if (!Ogre::ResourceGroupManager::getSingletonPtr())
		return;
	if(NULL == GetDataManipulator())
		return;

	mAnimationList->Freeze();

	wxTreeItemId root = mAnimationList->GetRootItem();

	mAnimationList->Unselect();

	mAnimationList->DeleteChildren(root);

	if (mIsMeshAnim)
	{
		// Get animation list of current mesh	
		Fairy::ObjectPtr pCurMesh = GetDataManipulator()->m_pMeshObject;
		if (!pCurMesh)
		{
			mAnimationList->Thaw();
			return;
		}

		Fairy::StaticEntityObject* entity = static_cast<Fairy::StaticEntityObject*>((pCurMesh).get());
		Ogre::Entity* pCurEntity = entity->getEntity();
		if(pCurEntity && pCurEntity->hasSkeleton())
		{	
			//更新动画列表
			unsigned short numAnim = pCurEntity->getSkeleton()->getNumAnimations();
			for(int i=0;i<numAnim;++i)
			{
				Ogre::String AniName = pCurEntity->getSkeleton()->getAnimation(i)->getName();
				wxTreeItemId item = AddLeaf(root, AniName);
				mAnimationList->SetItemData(item, new AnimationItemData(AniName));
			}
		}
		mAnimationList->Thaw();
	}
	else
	{
		Fairy::LogicModel* pObjModel = GetDataManipulator()->m_pObjTemplate;
		if (!pObjModel)
		{
			mAnimationList->Thaw();
			return;
		}

		Fairy::LogicModelManager::AnimationSkeletonLinks* pAniLinks = GetDataManipulator()->_getCurAniLinks();
		if (!pAniLinks)
		{
			mAnimationList->Thaw();
			return;
		}

		for ( Fairy::LogicModelManager::AnimationSkeletonLinks::iterator iter = pAniLinks->begin(); iter!= pAniLinks->end(); ++iter)
		{
			Ogre::String AniName(iter->first);
			wxTreeItemId item = AddLeaf(root, AniName);
			mAnimationList->SetItemData(item, new AnimationItemData(AniName));
		}

		mAnimationList->Thaw();
	}
}
Esempio n. 9
0
NodeInt stmt()
{
	switch (CurrToken) {
		case INT32:{
			mutch(INT32); 
			Token tokL = mutch(IDENTIFIER);
			int idNum = Lookup(lexeme, 1, INT32);
			NodeInt nodeL = AddLeaf(tokL, idNum);
			if(CurrToken == MOV_OP){
				Token tok = mutch(MOV_OP); 
				NodeInt nodeR = boool();

					mutch(COMM_POINT);

				return AddNode(tok, nodeL,0,nodeR);
			}
			mutch(COMM_POINT);
			NodeInt nodeR = AddLeaf(NUMBER, 0);
			return AddNode(MOV_OP, nodeL, 0,nodeR);
			break;
		}
		case INT16:{
			mutch(INT16); 
			Token tokL = mutch(IDENTIFIER);
			int idNum = Lookup(lexeme, 1, INT16);
			NodeInt nodeL = AddLeaf(tokL, idNum);
			if(CurrToken == MOV_OP){
				Token tok = mutch(MOV_OP); 
				NodeInt nodeR = boool();
				mutch(COMM_POINT);
				return AddNode(tok, nodeL,0,nodeR);
			}
			mutch(COMM_POINT);
			NodeInt nodeR = AddLeaf(NUMBER, 0);
			return AddNode(MOV_OP, nodeL, 0,nodeR);
			break;
		}
			
		case DO:{
			mutch(DO);
			NodeInt nodeL = stmt(); 
			mutch(WHILE);
			mutch(LEFT_BRECKET);
			NodeInt nodeR = boool();
			mutch(RIGHT_BRECKET);
			mutch(COMM_POINT);
			return AddNode(DO, nodeL, 0,nodeR);
			break;
		}
			
		case IF:{
			Token tok = mutch(IF); 
			mutch(LEFT_BRECKET);
			NodeInt nodeL = boool();
			mutch(RIGHT_BRECKET);
			NodeInt nodeR = stmt();
			NodeInt nodeM = 0;
			if(CurrToken == ELSE){
				tok = mutch(ELSE);
				nodeM = stmt();
			}
			return AddNode(tok, nodeL, nodeM, nodeR);
			break;
		}
			
		case LEFT_FIG_BRECKET:{
			mutch(LEFT_FIG_BRECKET);
			NodeInt node = stmts();
			mutch(RIGHT_FIG_BRECKET);
			return AddNode(STMT, node, 0, 0);
			break;
		}
			
		case IDENTIFIER:{
			Token tok =  mutch(IDENTIFIER);

			
			if(CurrToken == MOV_OP){
				int idNum = Lookup(lexeme,0,0);
				if (idNum < 0){
					printf("Syntax error:В строке %d использована не объявленая переменная \n",line);
					return 0;
				}
				NodeInt idLeaf = AddLeaf(IDENTIFIER, idNum);
				
				tok = mutch(MOV_OP);
				NodeInt nodeR = boool();
				mutch(COMM_POINT);
				return AddNode(tok, idLeaf, 0,nodeR);
			}
			if(CurrToken == LEFT_BRECKET){
				int idNum = Lookup(lexeme,1,0);
				if (idNum < 0){
					printf("Syntax error:В строке %d использована не объявленая переменная \n",line);
					return 0;
				}
				NodeInt idLeaf = AddLeaf(IDENTIFIER, idNum);
				
				mutch(LEFT_BRECKET);
				NodeInt nodeR =boool();
				mutch(RIGHT_BRECKET);
				mutch(COMM_POINT);
				return AddNode(FUNCTION, idLeaf, 0, nodeR);
			}
			break;
		}
			
		case CONTINUE:{
			return AddNode(CONTINUE, 0, 0, 0);
		}
			
		case BREAK:{
			return AddNode(BREAK, 0, 0, 0);
		}
			
			
		default:
			printf("Syntaxes error\n");
			return 0;
			break;
	}
}
Esempio n. 10
0
void SuffixTree<Symb,NSymb>::Create()
{
	iscreating = true;

	// set 'lens' array
	lens = new int[dlen];
	for(int z = 0, i = 0; z < dlen; z++)
		if(data[z] == '\0')
			for(; i <= z; i++) lens[i] = z + 1 - i;

	// make root node
	nodes.resize(2);
	Node& root = GetNode(ROOT);
	root = Node();
	root.len = 1;
	root.prev = ROOT;

	// active point
	Point active = { ROOT, 0 };

	const uchar* s = data;
	PNode last_int = NIL, last_leaf = NIL;	// index of the recently created internal and leaf node; stored for initialization of their 'suf' links

	// add leaf representing string "\0"
	AddLeaf(active, 0, last_int, last_leaf);
	GetNode(last_leaf).suf = ROOT; GetNode(last_leaf).count = 0;
	last_leaf = NIL;

	int nsuf = 1;
	while(nsuf < dlen)
	{
		// only if active point is at node, it's worth invoking MoveDown()
		if(active.proj == 0) {
			// after following a suffix link, we reached a node, so we already know how to initialize
			// the suf link of the recently created node
			if(last_int != NIL) {
				GetNode(last_int).suf = active.n;
				last_int = NIL;
			}

			// maybe we can move further down the tree
			MoveDown(active, s);

			// Did we passed the end of the next string? (symbol '\0')
			// If so, we don't add new leaves, but walk along the border path,
			// to the root, and update counts of the passed leaves. Finally, we skip to the next string.
			if(IsLeaf(active.n)) {
				if(last_leaf != NIL) {
					GetNode(last_leaf).suf = active.n;
					last_leaf = NIL;
				}
				do {
					BHASSERT_WITH_NO_PERFORMANCE_IMPACT(*(s-1) == '\0');
					BHASSERT_WITH_NO_PERFORMANCE_IMPACT(IsLeaf(active.n));
					BHASSERT_WITH_NO_PERFORMANCE_IMPACT(active.proj == 0);
					GetNode(active.n).count++;
					MoveSuffix(active, s);
				}
				while(active.n != ROOT);			// TODO: time - optimize the leaf counting

				//GetNode(active.n).count++;
				nsuf = (int)(s - data);
				continue;
			}
		}

		AddLeaf(active, (int)(s - data), last_int, last_leaf);
		MoveSuffix(active, s);

		nsuf++;
	}

	iscreating = false;
}