// ----------------------------------------------------------------------------- // file="RegexAnalyzer.SourceGen" // Project: StgSharp // Copyright (c) Nitload. // SPDX-License-Identifier: MIT // ----------------------------------------------------------------------------- using Microsoft.CodeAnalysis; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace StgSharp.RegularAnalysis.Text { public partial class RegexAnalyzer { internal static StringBuilder GenerateSource( List ir ) { StringBuilder sb = new(); List sub_match_list = []; ReadOnlySpan source = CollectionsMarshal.AsSpan(ir); RegexIR[] window = new RegexIR[8]; Span scan_win = window; _ = sb.AppendLine(@"public abstract MatchResult Match(ReadOnlySpan text)")// .AppendLine(@"{"); int index = 0; do { int count = int.Min(8, source.Length - index); source.Slice(index, count).CopyTo(scan_win); } while (index < ir.Count); foreach (StringBuilder _sub in sub_match_list) { _ = sb.AppendLine() // .Append(_sub); } return sb; /* int TryGenerateMatch( Span scan_win, StringBuilder sb ) { if (scan_win[0] is RegexMatchSeqIR seq) { _ = sb.AppendLine(string.Empty); } } /**/ } } }