⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeform.cpp

📁 Code for top down parser in C++
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "treeform.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
//---------------------------------------------------------------------------
__fastcall TfrmTree::TfrmTree(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void TfrmTree::FillTree(TList* theList, ParseNode* node, TTreeNode* parentTreeNode){
  if(node->index != -1){
    TTreeNode* item = TreeView1->Items->AddChild(parentTreeNode, (node->str=="") ? String("epsilon") : node->str);
    if(node->terminal){
        if(node->str == ""){
            item->ImageIndex = 2; item->SelectedIndex = 2;
        }else{
            item->ImageIndex = 1; item->SelectedIndex = 1;
        }
    }
    else{ item->ImageIndex = 0; item->SelectedIndex = 0; }
    //find all the children of this node, and call them
    for(int i=0; i<theList->Count; i++){
        ParseNode* childNode = (ParseNode*)theList->Items[i];
        if(childNode->parent == node) FillTree(theList, childNode, item);
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TfrmTree::FormShow(TObject *Sender){
    SetForegroundWindow(this->Handle);
}
//---------------------------------------------------------------------------

void __fastcall TfrmTree::mnuExpandClick(TObject *Sender){
    TreeView1->FullExpand();
}
//---------------------------------------------------------------------------

void __fastcall TfrmTree::mnuCollapseClick(TObject *Sender){
    TreeView1->FullCollapse();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -