コード例 #1
0
        public override int VisitAssertionBwdneg(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label);

            // Visit assertionbwdneg context
            if (current.GetNumberOfContextElements(ContextType.CT_ASSERTION_BWDNEG) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_ASSERTION_BWDNEG.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_ASSERTION_BWDNEG))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.Write(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }


            base.VisitAssertionBwdneg(currentNode);

            return(0);
        }
コード例 #2
0
        public override FA VisitRegexpbasicParen(CASTElement currentNode)
        {
            CASTComposite curNode = currentNode as CASTComposite;

            m_currentNFA = Visit(curNode.GetChild(ContextType.CT_RGEXPBASIC_PAREN, 0));

            return(m_currentNFA);
        }
コード例 #3
0
 public CASTElementDescentantsContextIterator(CASTElement astNode)
 {
     m_node = astNode as CASTComposite;
     if (m_node == null)
     {
         throw new Exception("Iterator cannot iterate over leaf nodes");
     }
 }
コード例 #4
0
 public CASTElementDescentantsFlattenEventIterator(CASTElement astNode,
                                                   CASTGenericIteratorEvents events, object info = null)
 {
     m_Event = events;
     m_node  = astNode as CASTComposite;
     if (m_node == null)
     {
         throw new Exception("Iterator cannot iterate over leaf nodes");
     }
 }
コード例 #5
0
        public override int VisitTerminal(CASTElement node)
        {
            CASTComposite current = node as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", node.M_Parent.M_Label, node.M_Label);

            // Visit range_min context
            return(0);
        }
コード例 #6
0
        /// <summary>
        /// Visits the node given as an argument and all of its contexts
        /// and prints the cluster affilliated to it
        /// </summary>
        /// <param name="currentNode">the node we want to print </param>
        ///
        public override int VisitRegexpClosure(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label);

            // Visit closure's regexp context
            if (current.GetNumberOfContextElements(ContextType.CT_REGEXPCLOSURE_REGEXP) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_REGEXPCLOSURE_REGEXP.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_REGEXPCLOSURE_REGEXP))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.WriteLine(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }

            // Visit closure's quantifier context
            if (current.GetNumberOfContextElements(ContextType.CT_REGEXPCLOSURE_QUANTIFIER) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_REGEXPCLOSURE_QUANTIFIER.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_REGEXPCLOSURE_QUANTIFIER))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.WriteLine(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }

            base.VisitRegexpClosure(currentNode);

            return(0);
        }
コード例 #7
0
        /*
         * /* 27 #1# , CT_RANGE_MAX = 28,
         *  CT_NA*/

        /// <summary>
        /// Visits the node given as an argument and all of its contexts
        ///  and prints the cluster affilliated to it
        /// </summary>
        /// <param name="currentNode">the node we want to print </param>
        ///
        public override int VisitLexerDescription(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("digraph {\n");

            // Visit context
            if (current.GetNumberOfContextElements(ContextType.CT_LEXERDESCRIPTION_BODY) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_LEXERDESCRIPTION_BODY.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_LEXERDESCRIPTION_BODY))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.WriteLine(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }

            base.VisitLexerDescription(currentNode);

            m_outputStream.WriteLine("}");
            m_outputStream.Close();

            if (true)
            {
                Process process = new Process();
                // Configure the process using the StartInfo properties.
                process.StartInfo.FileName  = "dot.exe";
                process.StartInfo.Arguments = "-Tgif " + m_outputFile + " -o" +
                                              Path.GetFileNameWithoutExtension(m_outputFile) + ".gif";
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.Start();
                process.WaitForExit();// Waits here for the process to exit.
            }


            return(0);
        }
コード例 #8
0
        public override int VisitRange(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label);

            // Visit range_min context
            clusterName = "cluster" + ms_clusterCounter++;
            contextName = ContextType.CT_RANGE_MIN.ToString();
            m_outputStream.WriteLine(
                "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                clusterName, contextName);
            foreach (CASTElement element in current.GetContextChildren(ContextType.CT_RANGE_MIN))
            {
                m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                {
                    m_outputStream.Write(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                }
            }

            m_outputStream.WriteLine("}");

            // Visit range_max context
            clusterName = "cluster" + ms_clusterCounter++;
            contextName = ContextType.CT_RANGE_MAX.ToString();
            m_outputStream.WriteLine(
                "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                clusterName, contextName);
            foreach (CASTElement element in current.GetContextChildren(ContextType.CT_RANGE_MAX))
            {
                m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                {
                    m_outputStream.Write(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                }
            }
            m_outputStream.WriteLine("}");


            base.VisitRange(currentNode);

            return(0);
        }
コード例 #9
0
        public override int VisitActionCode(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label);

            // Visit range_min context
            if (current.GetNumberOfContextElements(ContextType.CT_ACTIONCODE) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_ACTIONCODE.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                m_outputStream.WriteLine("}");
            }
            return(0);
        }
コード例 #10
0
        /// <summary>
        ///
        /// Visits the node given as an argument and prints the cluster affilliated to it
        /// </summary>
        /// <param name="currentNode">the node we want to print </param>
        ///
        public override int VisitRegexpbasicParen(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label);
            // Visit regexpalternation context
            if (current.GetNumberOfContextElements(ContextType.CT_RGEXPBASIC_PAREN) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_RGEXPBASIC_PAREN.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                m_outputStream.WriteLine("}");
            }


            base.VisitRegexpbasicParen(currentNode);

            return(0);
        }
コード例 #11
0
        /// <summary>
        /// Visits the node given as an argument and all of its contexts
        /// and prints the cluster affilliated to it
        /// </summary>
        /// <param name="currentNode">the node we want to print </param>
        ///
        public override int VisitRegexpStatement(CASTElement currentNode)
        {
            CASTComposite current = currentNode as CASTComposite;
            string        clusterName;
            string        contextName;

            m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label);

            // Visit regexpstatement_tokenname context
            if (current.GetNumberOfContextElements(ContextType.CT_REGEXPSTATEMENT_TOKENNAME) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_REGEXPSTATEMENT_TOKENNAME.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_REGEXPSTATEMENT_TOKENNAME))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.WriteLine(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }
            // Visit regexpstatement_regexp context
            if (current.GetNumberOfContextElements(ContextType.CT_REGEXPSTATEMENT_REGEXP) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_REGEXPSTATEMENT_REGEXP.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_REGEXPSTATEMENT_REGEXP))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.WriteLine(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }
            // Visit regexpstatement_actioncode context
            if (current.GetNumberOfContextElements(ContextType.CT_REGEXPSTATEMENT_ACTIONCODE) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_REGEXPSTATEMENT_ACTIONCODE.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                foreach (CASTElement element in current.GetContextChildren(ContextType.CT_REGEXPSTATEMENT_ACTIONCODE))
                {
                    m_outputStream.WriteLine("\"{0}\"", element.M_Label);
                    if (CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_Color != Color.C_DEFAULT)
                    {
                        m_outputStream.WriteLine(" [fillcolor = " + CConfigurationSettings.m_nodeTypeConfiguration[element.M_NodeType].M_ColorName + "]");
                    }
                }
                m_outputStream.WriteLine("}");
            }

            // Visit regexpstatement_ID context
            if (current.GetNumberOfContextElements(ContextType.CT_REGEXPSTATEMENT_TOKENNAME) > 0)
            {
                clusterName = "cluster" + ms_clusterCounter++;
                contextName = ContextType.CT_REGEXPSTATEMENT_TOKENNAME.ToString();
                m_outputStream.WriteLine(
                    "subgraph {0} {{\n node [style=filled,color=white];\n style=filled;\n color=lightgrey;\n label = \"{1}\";\n",
                    clusterName, contextName);
                m_outputStream.WriteLine("}");
            }

            base.VisitRegexpStatement(currentNode);

            return(0);
        }