Beispiel #1
0
 public override void ProcessNode(syntax_tree_node Node)
 {
     if (Node == null)
     {
         return;
     }
     if (Node.source_context == null)
     {
         return;
     }
     if (FindContextIn(Node))
     {
         Node.visit(this);
     }
     else
     {
         if (ContextInRightOrder(_findContext, Node.source_context))
         {
             if (_findResult == null)
             {
                 _findResult = Node;
             }
             else
             if (ContextStartsInRightOrder(Node.source_context, _findResult.source_context))
             {
                 _findResult = Node;
             }
         }
     }
 }
 void visit_node(syntax_tree_node node)
 {
     if (node != null)
     {
         node.visit(this);
     }
 }
        public static string node(syntax_tree_node tn)
        {
            string_ref    sr  = new string_ref();
            get_node_info gni = new get_node_info(sr);

            tn.visit(gni);
            return(sr.s);
        }
 public override void Exit(syntax_tree_node st)
 {
     if (st is procedure_definition)
     {
         if (mids.vars.Count > 0)
         {
             d[st as procedure_definition] = new HashSet <string>(mids.vars);
         }
         var fld = new FindLocalDefsVisitor();
         st.visit(fld);
         fld.Print();
         var t = fld.ids.Intersect(mids.vars); // идентификаторы, захваченные из локального контекста
     }
     base.Exit(st);
 }
Beispiel #5
0
        public syntax_tree_node Convert(syntax_tree_node root)
        {
            root.visit(new MarkMethodHasYieldAndCheckSomeErrorsVisitor());
            ProcessYieldCapturedVarsVisitor.New.ProcessNode(root);

#if DEBUG
            try
            {
                //root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.txt"));
            }
            catch
            {
            }
#endif

            return(root);
        }
Beispiel #6
0
        private void prepare_node_with_text(syntax_tree_node subnode, string text)
        {
            if (subnode == null)
            {
                return;
            }
            TreeNode tn = new TreeNode();

            tn.Text = text;
            tn.Tag  = subnode;
            string s = get_node_info.node(subnode);

            if (s != null)
            {
                tn.Text += "     " + s;
            }
            //tn.Nodes.Clear();
            visualizator vs = new visualizator(tn.Nodes);

            subnode.visit(vs);
            nodes.Add(tn);
        }
Beispiel #7
0
        protected bool visitNode = true; // в OnEnter можно сделать false

        public virtual void ProcessNode(syntax_tree_node Node)
        {
            if (Node != null)
            {
                if (OnEnter != null)
                {
                    OnEnter(Node);
                }

                if (visitNode)
                {
                    Node.visit(this);
                }
                else
                {
                    visitNode = true;
                }

                if (OnLeave != null)
                {
                    OnLeave(Node);
                }
            }
        }
 public semantic_node visit(syntax_tree_node tn)
 {
     tn.visit(syntax_tree_visitor);
     return(ret_semantic);
 }