File: Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\RegexGenerator.g.cs
Project: Microsoft.Build.Framework.csproj (Microsoft.Build.Framework)
// <auto-generated/>
#nullable enable
#pragma warning disable

namespace Microsoft.Build.Framework
{
    partial class NodeModeHelper
    {
        /// <remarks>
        /// Pattern:<br/>
        /// <code>(?:^|\s)"?(?:--?|/)(?:nodemode|nmode):"?(?&lt;nodemode&gt;[a-zA-Z0-9]+)"?(?:\s|$)</code><br/>
        /// Options:<br/>
        /// <code>RegexOptions.IgnoreCase</code><br/>
        /// Explanation:<br/>
        /// <code>
        /// ○ Match with 2 alternative expressions.<br/>
        ///     ○ Match if at the beginning of the string.<br/>
        ///     ○ Match a whitespace character.<br/>
        /// ○ Match '"' atomically, optionally.<br/>
        /// ○ Match with 2 alternative expressions.<br/>
        ///     ○ Match '-' atomically at least 1 and at most 2 times.<br/>
        ///     ○ Match '/'.<br/>
        /// ○ Match a character in the set [Nn].<br/>
        /// ○ Match with 2 alternative expressions.<br/>
        ///     ○ Match a sequence of expressions.<br/>
        ///         ○ Match a character in the set [Oo].<br/>
        ///         ○ Match a character in the set [Dd].<br/>
        ///         ○ Match a character in the set [Ee].<br/>
        ///         ○ Match a character in the set [Mm].<br/>
        ///         ○ Match a character in the set [Oo].<br/>
        ///         ○ Match a character in the set [Dd].<br/>
        ///         ○ Match a character in the set [Ee].<br/>
        ///     ○ Match a sequence of expressions.<br/>
        ///         ○ Match a character in the set [Mm].<br/>
        ///         ○ Match a character in the set [Oo].<br/>
        ///         ○ Match a character in the set [Dd].<br/>
        ///         ○ Match a character in the set [Ee].<br/>
        /// ○ Match ':'.<br/>
        /// ○ Match '"' atomically, optionally.<br/>
        /// ○ "nodemode" capture group.<br/>
        ///     ○ Match a character in the set [0-9A-Za-z\u212A] atomically at least once.<br/>
        /// ○ Match '"' atomically, optionally.<br/>
        /// ○ Match with 2 alternative expressions, atomically.<br/>
        ///     ○ Match a whitespace character.<br/>
        ///     ○ Match if at the end of the string or if before an ending newline.<br/>
        /// </code>
        /// </remarks>
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "12.0.15.2434")]
        private static partial global::System.Text.RegularExpressions.Regex CommandLineNodeModeRegex => global::System.Text.RegularExpressions.Generated.CommandLineNodeModeRegex_0.Instance;
    }
}

namespace System.Text.RegularExpressions.Generated
{
    using System;
    using System.Buffers;
    using System.CodeDom.Compiler;
    using System.Collections;
    using System.ComponentModel;
    using System.Globalization;
    using System.Runtime.CompilerServices;
    using System.Text.RegularExpressions;
    using System.Threading;

    /// <summary>Custom <see cref="Regex"/>-derived type for the CommandLineNodeModeRegex method.</summary>
    [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "12.0.15.2434")]
    [SkipLocalsInit]
    file sealed class CommandLineNodeModeRegex_0 : Regex
    {
        /// <summary>Cached, thread-safe singleton instance.</summary>
        internal static readonly CommandLineNodeModeRegex_0 Instance = new();
    
        /// <summary>Initializes the instance.</summary>
        private CommandLineNodeModeRegex_0()
        {
            base.pattern = "(?:^|\\s)\"?(?:--?|/)(?:nodemode|nmode):\"?(?<nodemode>[a-zA-Z0-9]+)\"?(?:\\s|$)";
            base.roptions = RegexOptions.IgnoreCase;
            ValidateMatchTimeout(Utilities.s_defaultTimeout);
            base.internalMatchTimeout = Utilities.s_defaultTimeout;
            base.factory = new RunnerFactory();
            base.CapNames = new Hashtable { { "0", 0 } ,  { "nodemode", 1 }  };
            base.capslist = new string[] {"0", "nodemode" };
            base.capsize = 2;
        }
            
        /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see cref="Regex"/>.</summary>
        private sealed class RunnerFactory : RegexRunnerFactory
        {
            /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</summary>
            protected override RegexRunner CreateInstance() => new Runner();
        
            /// <summary>Provides the runner that contains the custom logic implementing the specified regular expression.</summary>
            private sealed class Runner : RegexRunner
            {
                /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</summary>
                /// <param name="inputSpan">The text being scanned by the regular expression.</param>
                protected override void Scan(ReadOnlySpan<char> inputSpan)
                {
                    // Search until we can't find a valid starting position, we find a match, or we reach the end of the input.
                    while (TryFindNextPossibleStartingPosition(inputSpan) &&
                           !TryMatchAtCurrentPosition(inputSpan) &&
                           base.runtextpos != inputSpan.Length)
                    {
                        base.runtextpos++;
                        if (Utilities.s_hasTimeout)
                        {
                            base.CheckTimeout();
                        }
                    }
                }
        
                /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a match could possibly start.</summary>
                /// <param name="inputSpan">The text being scanned by the regular expression.</param>
                /// <returns>true if a possible match was found; false if no more matches are possible.</returns>
                private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan)
                {
                    int pos = base.runtextpos;
                    
                    // Any possible match is at least 8 characters.
                    if (pos <= inputSpan.Length - 8)
                    {
                        // The pattern begins with a character in the set ["\-/\s].
                        // Find the next occurrence. If it can't be found, there's no match.
                        int i = inputSpan.Slice(pos).IndexOfNonAsciiOrAny_F3AB3F3F4FCE6B47736BA4E76A9A11DA2B4447C69F4C9FA350AE81D34C1A226B();
                        if (i >= 0)
                        {
                            base.runtextpos = pos + i;
                            return true;
                        }
                    }
                    
                    // No match found.
                    base.runtextpos = inputSpan.Length;
                    return false;
                }
        
                /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regular expression.</summary>
                /// <param name="inputSpan">The text being scanned by the regular expression.</param>
                /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns>
                private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan)
                {
                    int pos = base.runtextpos;
                    int matchStart = pos;
                    int alternation_branch = 0;
                    int alternation_starting_capturepos = 0;
                    int alternation_starting_pos = 0;
                    int capture_starting_pos = 0;
                    ReadOnlySpan<char> slice = inputSpan.Slice(pos);
                    
                    // Match with 2 alternative expressions.
                    //{
                        alternation_starting_pos = pos;
                        alternation_starting_capturepos = base.Crawlpos();
                        
                        // Branch 0
                        //{
                            // Match if at the beginning of the string.
                            if (pos != 0)
                            {
                                goto AlternationBranch;
                            }
                            
                            alternation_branch = 0;
                            goto AlternationMatch;
                            
                            AlternationBranch:
                            pos = alternation_starting_pos;
                            slice = inputSpan.Slice(pos);
                            UncaptureUntil(alternation_starting_capturepos);
                        //}
                        
                        // Branch 1
                        //{
                            // Match a whitespace character.
                            if (slice.IsEmpty || !char.IsWhiteSpace(slice[0]))
                            {
                                UncaptureUntil(0);
                                return false; // The input didn't match.
                            }
                            
                            alternation_branch = 1;
                            pos++;
                            slice = inputSpan.Slice(pos);
                            goto AlternationMatch;
                        //}
                        
                        AlternationBacktrack:
                        if (Utilities.s_hasTimeout)
                        {
                            base.CheckTimeout();
                        }
                        
                        switch (alternation_branch)
                        {
                            case 0:
                                goto AlternationBranch;
                            case 1:
                                UncaptureUntil(0);
                                return false; // The input didn't match.
                        }
                        
                        AlternationMatch:;
                    //}
                    
                    // Match '"' atomically, optionally.
                    {
                        if (!slice.IsEmpty && slice[0] == '"')
                        {
                            slice = slice.Slice(1);
                            pos++;
                        }
                    }
                    
                    // Match with 2 alternative expressions.
                    //{
                        if (slice.IsEmpty)
                        {
                            goto AlternationBacktrack;
                        }
                        
                        switch (slice[0])
                        {
                            case '-':
                                // Match '-' atomically at least 1 and at most 2 times.
                                {
                                    int iteration = 0;
                                    while (iteration < 2 && (uint)iteration < (uint)slice.Length && slice[iteration] == '-')
                                    {
                                        iteration++;
                                    }
                                    
                                    if (iteration == 0)
                                    {
                                        goto AlternationBacktrack;
                                    }
                                    
                                    slice = slice.Slice(iteration);
                                    pos += iteration;
                                }
                                
                                break;
                                
                            case '/':
                                pos++;
                                slice = inputSpan.Slice(pos);
                                break;
                                
                            default:
                                goto AlternationBacktrack;
                        }
                    //}
                    
                    // Match a character in the set [Nn].
                    if (slice.IsEmpty || ((slice[0] | 0x20) != 'n'))
                    {
                        goto AlternationBacktrack;
                    }
                    
                    // Match with 2 alternative expressions.
                    //{
                        if ((uint)slice.Length < 2)
                        {
                            goto AlternationBacktrack;
                        }
                        
                        switch (slice[1])
                        {
                            case 'O' or 'o':
                                
                                if ((uint)slice.Length < 8 ||
                                    !slice.Slice(2).StartsWith("demode", StringComparison.OrdinalIgnoreCase)) // Match the string "demode" (ordinal case-insensitive)
                                {
                                    goto AlternationBacktrack;
                                }
                                
                                pos += 8;
                                slice = inputSpan.Slice(pos);
                                break;
                                
                            case 'M' or 'm':
                                
                                if ((uint)slice.Length < 5 ||
                                    !slice.Slice(2).StartsWith("ode", StringComparison.OrdinalIgnoreCase)) // Match the string "ode" (ordinal case-insensitive)
                                {
                                    goto AlternationBacktrack;
                                }
                                
                                pos += 5;
                                slice = inputSpan.Slice(pos);
                                break;
                                
                            default:
                                goto AlternationBacktrack;
                        }
                    //}
                    
                    // Match ':'.
                    if (slice.IsEmpty || slice[0] != ':')
                    {
                        goto AlternationBacktrack;
                    }
                    
                    // Match '"' atomically, optionally.
                    {
                        if ((uint)slice.Length > (uint)1 && slice[1] == '"')
                        {
                            slice = slice.Slice(1);
                            pos++;
                        }
                    }
                    
                    // "nodemode" capture group.
                    {
                        pos++;
                        slice = inputSpan.Slice(pos);
                        capture_starting_pos = pos;
                        
                        // Match a character in the set [0-9A-Za-z\u212A] atomically at least once.
                        {
                            int iteration1 = slice.IndexOfAnyExcept(Utilities.s_asciiLettersAndDigitsAndKelvinSign);
                            if (iteration1 < 0)
                            {
                                iteration1 = slice.Length;
                            }
                            
                            if (iteration1 == 0)
                            {
                                goto AlternationBacktrack;
                            }
                            
                            slice = slice.Slice(iteration1);
                            pos += iteration1;
                        }
                        
                        base.Capture(1, capture_starting_pos, pos);
                    }
                    
                    // Match '"' atomically, optionally.
                    {
                        if (!slice.IsEmpty && slice[0] == '"')
                        {
                            slice = slice.Slice(1);
                            pos++;
                        }
                    }
                    
                    // Match with 2 alternative expressions, atomically.
                    {
                        int alternation_starting_pos1 = pos;
                        
                        // Branch 0
                        {
                            // Match a whitespace character.
                            if (slice.IsEmpty || !char.IsWhiteSpace(slice[0]))
                            {
                                goto AlternationBranch1;
                            }
                            
                            pos++;
                            slice = inputSpan.Slice(pos);
                            goto AlternationMatch1;
                            
                            AlternationBranch1:
                            pos = alternation_starting_pos1;
                            slice = inputSpan.Slice(pos);
                        }
                        
                        // Branch 1
                        {
                            // Match if at the end of the string or if before an ending newline.
                            if (pos < inputSpan.Length - 1 || ((uint)pos < (uint)inputSpan.Length && inputSpan[pos] != '\n'))
                            {
                                goto AlternationBacktrack;
                            }
                            
                        }
                        
                        AlternationMatch1:;
                    }
                    
                    // The input matched.
                    base.runtextpos = pos;
                    base.Capture(0, matchStart, pos);
                    return true;
                    
                    // <summary>Undo captures until it reaches the specified capture position.</summary>
                    [MethodImpl(MethodImplOptions.AggressiveInlining)]
                    void UncaptureUntil(int capturePosition)
                    {
                        while (base.Crawlpos() > capturePosition)
                        {
                            base.Uncapture();
                        }
                    }
                }
            }
        }

    }
    
    /// <summary>Helper methods used by generated <see cref="Regex"/>-derived implementations.</summary>
    [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "12.0.15.2434")]
    file static class Utilities
    {
        /// <summary>Default timeout value set in <see cref="AppContext"/>, or <see cref="Regex.InfiniteMatchTimeout"/> if none was set.</summary>
        internal static readonly TimeSpan s_defaultTimeout = AppContext.GetData("REGEX_DEFAULT_MATCH_TIMEOUT") is TimeSpan timeout ? timeout : Regex.InfiniteMatchTimeout;
        
        /// <summary>Whether <see cref="s_defaultTimeout"/> is non-infinite.</summary>
        internal static readonly bool s_hasTimeout = s_defaultTimeout != Regex.InfiniteMatchTimeout;
        
        /// <summary>Finds the next index of any character that matches a character in the set ["\-/\s].</summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        internal static int IndexOfNonAsciiOrAny_F3AB3F3F4FCE6B47736BA4E76A9A11DA2B4447C69F4C9FA350AE81D34C1A226B(this ReadOnlySpan<char> span)
        {
            int i = span.IndexOfAnyExcept(Utilities.s_ascii_FFC1FFFFFA5FFFFFFFFFFFFFFFFFFFFF);
            if ((uint)i < (uint)span.Length)
            {
                if (char.IsAscii(span[i]))
                {
                    return i;
                }
        
                char ch;
                do
                {
                    if (((ch = span[i]) < 128 ? ("㸀\0ꀅ\0\0\0\0\0"[ch >> 4] & (1 << (ch & 0xF))) != 0 : RegexRunner.CharInClass((char)ch, "\0\u0006\u0001\"#-./0d")))
                    {
                        return i;
                    }
                    i++;
                }
                while ((uint)i < (uint)span.Length);
            }
        
            return -1;
        }
        
        /// <summary>Supports searching for characters in or not in "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzK".</summary>
        internal static readonly SearchValues<char> s_asciiLettersAndDigitsAndKelvinSign = SearchValues.Create("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzK");
        
        /// <summary>Supports searching for characters in or not in "\0\u0001\u0002\u0003\u0004\u0005\u0006\a\b\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f!#$%&amp;'()*+,.0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f".</summary>
        internal static readonly SearchValues<char> s_ascii_FFC1FFFFFA5FFFFFFFFFFFFFFFFFFFFF = SearchValues.Create("\0\u0001\u0002\u0003\u0004\u0005\u0006\a\b\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f!#$%&'()*+,.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f");
    }
}