示例#1
0
 public PsiAST(PsiAST parent, string val, NodeType lab)
 {
     Parent = parent;
     Value = val;
     Type = lab;
     Children = new List<PsiAST>();
 }
示例#2
0
 public void VisitPsiAST(PsiAST tree)
 {
     // Fa bejárása
 }
示例#3
0
 public PsiAST Clone()
 {
     PsiAST c = new PsiAST(Parent, Value, Type);
     if(Children.Count != 0)
         foreach (PsiAST t in Children)
             c.Add(t.Clone());
     return c;
 }
示例#4
0
 public void Visit(PsiAST node)
 {
     // Switch NodeType alapján
     // Hogy illeszkedik ide a a rekurzív bejárás ...
 }
示例#5
0
 public void AddSibling(PsiAST sibling)
 {
     if (Parent == null)
         throw new PsiASTException("Cannot add sibling to the root element of a tree, because root has no parent.");
     Parent.Add(sibling);
 }
示例#6
0
 public void AddClone(PsiAST child)
 {
     if (!Children.Contains(child))
     {
         PsiAST c = child.Clone();
         c.Parent = this;
         Children.Add(c);
     }
 }
示例#7
0
 public void Add(PsiAST child)
 {
     if (!Children.Contains(child))
     {
         child.Parent = this;
         Children.Add(child);
     }
 }
示例#8
0
        public static TreeNode FromPsiASTToTreeNode(PsiAST tree, ViewMode vm)
        {
            if (tree != null)
            {
                // ViewMode
                string text = "";
                switch (vm)
                {
                    case ViewMode.All:
                        text = tree.ToString();
                        break;
                    case ViewMode.Values:
                        text = tree.Value;
                        break;
                    case ViewMode.Hibrid:
                        if (tree.Value == "") text = tree.Type.ToString();
                        else text = tree.Value;
                        break;
                    default:
                        // Can't Be
                        break;
                }

                if (tree.Children != null)
                {
                    TreeNode[] children = new TreeNode[tree.Children.Count];

                    for (int i = 0; i < tree.Children.Count; i++)
                        children[i] = FromPsiASTToTreeNode(tree.Children[i],vm);
                    return new TreeNode(text, children);
                }
                return new TreeNode(text);
            }
            return new TreeNode("#");
        }
示例#9
0
        public static PsiAST FromCommonTreeToPsiAST(CommonTree tree)
        {
            PsiAST root = null;
            if (tree != null)
            {
                // Itt megkell még határozni, hogy miylen típusú legyen. (Type.ASTLabel1)
                // Egy esetszétválasztás kell.
                // ...

                switch (tree.Type)
                {
                    case Psimulex:
                        break;
                    default:
                        break;
                }

                root = new PsiAST(null, tree.Text, NodeType.X);

                if (tree.Children != null)
                    foreach (CommonTree child in tree.Children)
                        root.Add(FromCommonTreeToPsiAST(child));
            }
            return root;
        }