using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Mods.ModManager
{
///
/// Lexical colouring for fenced documentation examples. Follows the site's
/// explicit-language approach and custom scenario/filestree/jsonc rules,
/// returning literal text spans rather than HTML or BBCode. Unknown languages,
/// oversized examples and timeouts retain their complete uncoloured source.
///
public static class ModCodeSyntax
{
private const string Strings = "(?\"\"\"[\\s\\S]*?\"\"\"|'''[\\s\\S]*?'''|(?:\\$@|@\\$|@)\"(?:\"\"|[^\"])*\"|\\$?\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*')";
private const string Tokens = @"(?\b(?:0[xX][0-9a-fA-F]+|\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[fFdDmM]?\b)|(?\$\{[^}\r\n]+\}|\$[A-Za-z_]\w*)|(?[A-Za-z_]\w*)|(?[{}\[\](),:;=+*/<>!&|.\-?])";
private static readonly Regex CStyle = Create(@"(?//[^\r\n]*|/\*[\s\S]*?\*/)|" + Strings + "|" + Tokens);
private static readonly Regex Json = Create(Strings + "|" + Tokens);
private static readonly Regex HashStyle = Create(@"(?\#[^\r\n]*)|" + Strings + "|" + Tokens);
private static readonly Regex Scenario = Create(@"(?^---[ \t]*$)|(?\#[^\r\n]*|--[^\r\n]*)|" + Strings + @"|(?