public override FA VisitRegexpbasicSet(CASTElement currentNode) { CRegexpbasicSet setNode = currentNode as CRegexpbasicSet; FAGraphQueryInfo FAInfo; //Create FA m_NFA = new FA(); FAInfo = new FAGraphQueryInfo(m_NFA, FA.m_FAINFOKEY); CGraphNode init = m_NFA.CreateGraphNode <CGraphNode>(); CGraphNode final = m_NFA.CreateGraphNode <CGraphNode>(); m_NFA.M_Initial = init; m_NFA.SetFinalState(final); m_NFA.M_Alphabet.AddSet(setNode.MSet); CGraphEdge newEdge = m_NFA.AddGraphEdge <CGraphEdge, CGraphNode>(init, final, GraphType.GT_DIRECTED); FAInfo.Info(newEdge).M_TransitionCharSet = setNode.MSet; //4.Pass FA to the predecessor m_NFA.PrefixGraphElementLabels(m_currentRegularExpression.M_StatementID, GraphElementType.ET_NODE); m_ReportingServices.ExctractThompsonStep(m_NFA, @"../Debug/BasicSet_" + setNode.MSet.ToString() + ".dot"); m_ReportingServices.AddThompsonStepToReporting(m_NFA); return(m_NFA); }
/// <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> /// <returns></returns> public override int VisitRegexpbasicSet(CASTElement currentNode) { CRegexpbasicSet current = currentNode as CRegexpbasicSet; string clusterName; string contextName; m_outputStream.WriteLine("\"{0}\"->\"{1}\"", currentNode.M_Parent.M_Label, currentNode.M_Label); //set negation if (current.M_IsSetNegation) { if (current.GetNumberOfContextElements(ContextType.CT_REGEXPBASIC_SETNEGATION) > 0) { clusterName = "cluster" + ms_clusterCounter++; contextName = ContextType.CT_REGEXPBASIC_SETNEGATION.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_REGEXPBASIC_SETNEGATION)) { 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 regexpbasic set context else if (current.GetNumberOfContextElements(ContextType.CT_REGEXPBASIC_SET) > 0) { clusterName = "cluster" + ms_clusterCounter++; contextName = ContextType.CT_REGEXPBASIC_SET.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_REGEXPBASIC_SET)) { 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.VisitRegexpbasicSet(currentNode); return(0); }
public override FA VisitRegexpbasicSet(CASTElement currentNode) { CRegexpbasicSet setNode = currentNode as CRegexpbasicSet; CThompsonBasicSet setTemplate = new CThompsonBasicSet(this.GetHashCode()); m_currentNFA = setTemplate.Synthesize(setNode.MSet); m_currentNFA.PrefixGraphElementLabels(m_currentRegularExpression.M_StatementID, GraphElementType.ET_NODE); m_ReportingServices.ExctractThompsonStep(m_currentNFA, @"BasicSet_" + setNode.MSet.ToString() + ".dot", this.GetHashCode()); m_ReportingServices.AddThompsonStepToReporting(m_currentNFA, this.GetHashCode()); return(m_currentNFA); }