private RegexFactor VisitRegexFactorNode(IInternalTreeNode internalNode) { RegexAtom atom = null; RegexIterator?iterator = null; for (var c = 0; c < internalNode.Children.Count; c++) { var child = internalNode.Children[c]; if (child.NodeType != TreeNodeType.Internal) { continue; } var childInternalNode = child as IInternalTreeNode; var childInternalNodeSymbolValue = childInternalNode.Symbol.Value; if (RegexGrammar.Atom == childInternalNodeSymbolValue) { atom = VisitRegexAtomNode(childInternalNode); } else if (RegexGrammar.Iterator == childInternalNodeSymbolValue) { iterator = VisitRegexIteratorNode(childInternalNode); } } if (iterator.HasValue) { return(new RegexFactorIterator( atom, iterator.Value)); } return(new RegexFactor(atom)); }
private static INfa Atom(RegexAtom atom) { switch (atom.NodeType) { case RegexNodeType.RegexAtomAny: return(Any()); case RegexNodeType.RegexAtomCharacter: var regexAtomCharacter = atom as RegexAtomCharacter; return(Character(regexAtomCharacter.Character)); case RegexNodeType.RegexAtomExpression: var regexAtomExpression = atom as RegexAtomExpression; return(Expression(regexAtomExpression.Expression)); case RegexNodeType.RegexAtomSet: var regexAtomSet = atom as RegexAtomSet; return(Set(regexAtomSet)); } throw new InvalidOperationException("Unrecognized regex atom"); }
public RegexFactorIterator(RegexAtom atom, RegexIterator iterator) : base(atom) { Iterator = iterator; _hashCode = ComputeHashCode(); }
public RegexFactor(RegexAtom atom) { Atom = atom; _hashCode = ComputeHashCode(); }