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

32 lines
845 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-05 17:33:04 +11:00
namespace UnityExplorer.Console.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-10-26 01:07:59 +11:00
private string htmlColor = null;
2020-10-26 01:07:59 +11:00
public virtual IEnumerable<char> StartChars { get { yield break; } }
public virtual IEnumerable<char> EndChars { get { yield break; } }
public abstract bool IsImplicitMatch(InputLexer lexer);
public bool IsMatch(InputLexer 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;
}
}
}