2020-10-28 06:39:26 +11:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using ExplorerBeta.Unstrip.ColorUtility;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
2020-10-25 20:57:34 +11:00
|
|
|
|
{
|
|
|
|
|
public abstract class MatchLexer
|
|
|
|
|
{
|
2020-10-26 01:07:59 +11:00
|
|
|
|
public abstract Color HighlightColor { get; }
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-10-26 01:07:59 +11:00
|
|
|
|
public string HexColor => htmlColor ?? (htmlColor = "<#" + HighlightColor.ToHex() + ">");
|
|
|
|
|
private string htmlColor = null;
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
2020-10-26 01:07:59 +11:00
|
|
|
|
public virtual IEnumerable<char> StartChars { get { yield break; } }
|
|
|
|
|
public virtual IEnumerable<char> EndChars { get { yield break; } }
|
2020-10-25 20:57:34 +11:00
|
|
|
|
|
|
|
|
|
public abstract bool IsImplicitMatch(ILexer lexer);
|
|
|
|
|
|
|
|
|
|
public bool IsMatch(ILexer lexer)
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|