Files
UnityExplorer_Fix/src/CSConsole/Lexer/Matcher.cs

33 lines
869 B
C#
Raw Normal View History

using System.Collections.Generic;
2020-11-09 16:43:19 +11:00
using UnityExplorer.Unstrip;
using UnityEngine;
2020-11-11 00:16:01 +11:00
using System.Linq;
namespace UnityExplorer.CSConsole.Lexer
{
public abstract class Matcher
{
2020-10-26 01:07:59 +11:00
public abstract Color HighlightColor { get; }
public string HexColor => htmlColor ?? (htmlColor = "<color=#" + HighlightColor.ToHex() + ">");
2020-11-11 00:16:01 +11:00
private string htmlColor;
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-11-11 00:16:01 +11:00
public abstract bool IsImplicitMatch(CSharpLexer lexer);
2020-11-11 00:16:01 +11:00
public bool IsMatch(CSharpLexer lexer)
{
2020-10-26 01:07:59 +11:00
if (IsImplicitMatch(lexer))
{
lexer.Commit();
2020-10-26 01:07:59 +11:00
return true;
}
2020-10-26 01:07:59 +11:00
lexer.Rollback();
return false;
}
}
}