Exemplo n.º 1
0
            private void RecordSimpleGroupingCapture(RegexSimpleGroupingNode node, RegexOptions options)
            {
                if (HasOption(options, RegexOptions.ExplicitCapture))
                {
                    // Don't automatically add simple groups if the explicit capture option is on.
                    // Only add captures for 'CaptureGrouping' and 'BalancingGrouping' nodes.
                    return;
                }

                // Don't count a bogus (? node as a capture node.  We only have this to keep our error
                // messages in line with the native parser.  i.e. even though the bogus (? code would
                // cause an exception, we might get an earlier exception if there's a reference to
                // this grouping.  So if we note this grouping we'll end up not causing that error
                // to happen, bringing out behavior out of sync with the native system.
                var expr = node.Expression;

                while (expr is RegexAlternationNode alternation)
                {
                    expr = alternation.Left;
                }

                if (expr is RegexSequenceNode sequence &&
                    sequence.ChildCount > 0)
                {
                    var leftMost = sequence.ChildAt(0);
                    if (leftMost.Node is RegexTextNode textNode &&
                        IsTextChar(textNode.TextToken, '?'))
                    {
                        return;
                    }
                }

                AddIfMissing(_captureNumberToSpan, list: null, _autoNumber++, GetGroupingSpan(node));
            }
Exemplo n.º 2
0
 public void Visit(RegexSimpleGroupingNode node)
 => ClassifyGrouping(node);