internal RegexNode MakePossessive()
        {
            var result = new RegexNode(Greedy, _options);

            result.AddChild(this);
            return(result);
        }
        internal RegexNode MakeQuantifier(bool lazy, int min, int max)
        {
            RegexNode result;

            if (min == 0 && max == 0)
            {
                return(new RegexNode(Empty, _options));
            }

            if (min == 1 && max == 1)
            {
                return(this);
            }

            switch (_type)
            {
            case One:
            case Notone:
            case Set:

                MakeRep(lazy ? Onelazy : Oneloop, min, max);
                return(this);

            default:
                result = new RegexNode(lazy ? Lazyloop : Loop, _options, min, max);
                result.AddChild(this);
                return(result);
            }
        }
Esempio n. 3
0
        private RegexNode CreatePseudoEndZNode()
        {
            // Create a lookahead, e.g.: (?=(?>\r\n|[\r\n])?\z)

            var options = _options & ~RegexOptions.RightToLeft;

            var lineCheckNode = CreateNewLineParseNode(GetNewlineTypes(), options);

            var maybeNode = new RegexNode(RegexNode.Loop, options, 0, 1);

            maybeNode.AddChild(lineCheckNode);

            var concatNode = new RegexNode(RegexNode.Concatenate, options);

            concatNode.AddChild(maybeNode);
            concatNode.AddChild(new RegexNode(RegexNode.End, options));

            var lookaheadNode = new RegexNode(RegexNode.Require, options);

            lookaheadNode.AddChild(concatNode);
            return(lookaheadNode);
        }
Esempio n. 4
0
        private RegexNode CreatePseudoCircumflexNode()
        {
            // Create a lookbehind, e.g.: (?<=(?>\A|\r\n|[\r\n]))

            var options = _options | RegexOptions.RightToLeft;

            var newlineTypes  = GetNewlineTypes() | NewlineTypes.DocumentStart;
            var lineCheckNode = CreateNewLineParseNode(newlineTypes, options);

            var lookaheadNode = new RegexNode(RegexNode.Require, options);

            lookaheadNode.AddChild(lineCheckNode);
            return(lookaheadNode);
        }
Esempio n. 5
0
        private RegexNode CreatePseudoDollarNode()
        {
            if (!UseOptionM())
            {
                Debug.Assert(!UseOptionDollarEndOnly());    // Could have been handled by a simple \z
                return(CreatePseudoEndZNode());
            }

            // Create a lookahead, e.g.: (?=(?>\z|\r\n|[\r\n]))

            var options = _options & ~RegexOptions.RightToLeft;

            var newlineTypes  = GetNewlineTypes() | NewlineTypes.DocumentEnd;
            var lineCheckNode = CreateNewLineParseNode(newlineTypes, options);

            var lookaheadNode = new RegexNode(RegexNode.Require, options);

            lookaheadNode.AddChild(lineCheckNode);
            return(lookaheadNode);
        }