【发布时间】:2014-01-25 16:52:34
【问题描述】:
我正在努力创建自己的外壳。
我为用户输入创建了一个词法分析器和一个解析器(用于创建二叉树)。 所以对于这样的命令:cat main.c | ls |厕所。
我得到了这棵树:
"|"
/ \
/ \
/ \
"cat main.c" "|"
/ \
/ \
"ls" "wc"
所以我的树遍历函数(按顺序)是这样的:
inorder(root)
{
inorder(root->left);
//exec cmd and do redirection
inorder(root->right);
}
我的问题是当我在节点“ls”或“wc”上时,我不知道如何 检查命令前后是否有管道。
有什么想法吗?
【问题讨论】:
-
解析树不是 B 树。
标签: c shell tree binary-tree inorder