2020-10-28 06:39:26 +11:00
|
|
|
|
using System.Collections.Generic;
|
2020-11-09 16:43:19 +11:00
|
|
|
|
using UnityExplorer.Unstrip;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
using UnityEngine;
|
2020-11-11 00:16:01 +11:00
|
|
|
|
using System.Linq;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-13 23:50:24 +11:00
|
|
|
|
namespace UnityExplorer.CSConsole.Lexer
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
public abstract class Matcher
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
2020-10-26 01:07:59 +11:00
|
|
|
|
public abstract Color HighlightColor { get; }
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-10 20:18:14 +11:00
|
|
|
|
public string HexColor => htmlColor ?? (htmlColor = "<color=#" + HighlightColor.ToHex() + ">");
|
2020-11-11 00:16:01 +11:00
|
|
|
|
private string htmlColor;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-11 00:16:01 +11:00
|
|
|
|
public virtual IEnumerable<char> StartChars => Enumerable.Empty<char>();
|
|
|
|
|
public virtual IEnumerable<char> EndChars => Enumerable.Empty<char>();
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-11 00:16:01 +11:00
|
|
|
|
public abstract bool IsImplicitMatch(CSharpLexer lexer);
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-11-11 00:16:01 +11:00
|
|
|
|
public bool IsMatch(CSharpLexer lexer)
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
2020-10-26 01:07:59 +11:00
|
|
|
|
if (IsImplicitMatch(lexer))
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
|
|
|
|
lexer.Commit();
|
2020-10-26 01:07:59 +11:00
|
|
|
|
return true;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-26 01:07:59 +11:00
|
|
|
|
lexer.Rollback();
|
|
|
|
|
return false;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|