1
我正在創建自己的shell。在「按順序遍歷樹」中查找特定節點
我已經爲用戶輸入創建了詞法分析器和解析器(它創建了一個二叉樹)。 所以對於這樣的命令:cat main.c | ls | wc。
我得到這個樹:
"|"
/\
/ \
/ \
"cat main.c" "|"
/\
/ \
"ls" "wc"
所以我的樹遍歷功能(按順序)是這樣的:
inorder(root)
{
inorder(root->left);
//exec cmd and do redirection
inorder(root->right);
}
我的問題是,當我在節點「LS」或「 wc「,我不知道如何 檢查命令之前和之後是否有管道。
有什麼想法?
解析樹不是B樹。 – EJP