public override FA VisitRegexpClosure(CASTElement currentNode) { CRegexpClosure closNode = currentNode as CRegexpClosure; //1.Create FA CThompsonClosureTemplate newFA = new CThompsonClosureTemplate(this.GetHashCode(), currentNode.M_Text); //2.Check the type of the closure if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_NONEORMULTIPLE) { FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesizeNoneOrMul(customFA); } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_ONEORMULTIPLE) { FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesisOneOrMul(customFA); } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_ONEORZERO) { FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesizeOneOrNone(customFA); } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_FINITECLOSURE) { CClosureRange rangeNode = closNode.GetChild(ContextType.CT_REGEXPCLOSURE_QUANTIFIER, 0) as CClosureRange; FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesizeFinite(customFA, rangeNode.M_ClosureMultiplicityLB, rangeNode.M_ClosureMultiplicityUB); } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_NONEORMULTIPLE_NONGREEDY) { //TODO } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_ONEORMULTIPLE_NONGREEDY) { //TODO } else { Console.WriteLine("No proper input"); } // Prefix the nodes of the new NFA with the prefix for the current regular expression CIt_GraphNodes it = new CIt_GraphNodes(m_currentNFA); for (it.Begin(); !it.End(); it.Next()) { m_currentNFA.PrefixElementLabel(m_currentRegularExpression.M_StatementID, it.M_CurrentItem); } m_ReportingServices.ExctractThompsonStep(m_currentNFA, @"Closure_" + m_currentNFA.M_Label + ".dot", this.GetHashCode()); m_ReportingServices.AddThompsonStepToReporting(m_currentNFA, this.GetHashCode()); //4.Pass FA to the predecessor return(m_currentNFA); }
public override FA VisitRegexpClosure(CASTElement currentNode) { CRegexpClosure closNode = currentNode as CRegexpClosure; //1.Create FA CThompsonClosureTemplate newFA = new CThompsonClosureTemplate(); //2.Check the type of the closure if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_NONEORMULTIPLE) { FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesizeNoneOrMul(customFA); } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_ONEORMULTIPLE) { FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesisOneOrMul(customFA); } else if (closNode.M_ClosureType == CRegexpClosure.ClosureType.CLT_ONEORZERO) { FA customFA = Visit(closNode.GetChild(ContextType.CT_REGEXPCLOSURE_REGEXP, 0)); m_currentNFA = newFA.SynthesizeOneOrNone(customFA); } else { Console.WriteLine("No proper input"); } CIt_GraphNodes it = new CIt_GraphNodes(m_currentNFA); for (it.Begin(); !it.End(); it.Next()) { m_currentNFA.PrefixElementLabel(m_currentRegularExpression.M_StatementID, it.M_CurrentItem); } m_ReportingServices.ExctractThompsonStep(m_currentNFA, @"../bin/Debug/Closure_" + m_currentNFA.M_Label + ".dot"); m_ReportingServices.AddThompsonStepToReporting(m_currentNFA); //4.Pass FA to the predecessor return(m_currentNFA); }