private static RegexNode CreateQuantifier(QuantifierParams quantifierParams, RegexNode child, int index, string pattern) { if (quantifierParams.Shorthand != null) { switch (quantifierParams.Shorthand) { case '?': if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return(new LazyQuestionMark(child, index, pattern)); } return(new PossessiveQuestionMark(child, index, pattern)); } return(new GreedyQuestionMark(child, index, pattern)); case '*': if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return(new LazyStar(child, index, pattern)); } return(new PossessiveStar(child, index, pattern)); } return(new GreedyStar(child, index, pattern)); case '+': if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return(new LazyPlus(child, index, pattern)); } return(new PossessivePlus(child, index, pattern)); } return(new GreedyPlus(child, index, pattern)); } } Debug.Assert(quantifierParams.Min != null); if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return(new LazyQuantifier(quantifierParams.Min.Value, quantifierParams.Max, child, index, pattern)); } return(new PossessiveQuantifier(quantifierParams.Min.Value, quantifierParams.Max, child, index, pattern)); } return(new GreedyQuantifier(quantifierParams.Min.Value, quantifierParams.Max, child, index, pattern)); }
private static RegexNode CreateQuantifier(QuantifierParams quantifierParams, RegexNode child, int index, string pattern) { if (quantifierParams.Shorthand != null) { switch (quantifierParams.Shorthand) { case '?': if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return new LazyQuestionMark(child, index, pattern); } return new PossessiveQuestionMark(child, index, pattern); } return new GreedyQuestionMark(child, index, pattern); case '*': if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return new LazyStar(child, index, pattern); } return new PossessiveStar(child, index, pattern); } return new GreedyStar(child, index, pattern); case '+': if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return new LazyPlus(child, index, pattern); } return new PossessivePlus(child, index, pattern); } return new GreedyPlus(child, index, pattern); } } Debug.Assert(quantifierParams.Min != null); if (quantifierParams.Optional != null) { if (quantifierParams.Optional == '?') { return new LazyQuantifier(quantifierParams.Min.Value, quantifierParams.Max, child, index, pattern); } return new PossessiveQuantifier(quantifierParams.Min.Value, quantifierParams.Max, child, index, pattern); } return new GreedyQuantifier(quantifierParams.Min.Value, quantifierParams.Max, child, index, pattern); }