mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +08:00
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace UnityExplorer.UI.Main.CSConsole.Lexer
|
|
{
|
|
public class NumberMatch : Matcher
|
|
{
|
|
public override Color HighlightColor => new Color(0.58f, 0.33f, 0.33f, 1.0f);
|
|
|
|
public override bool IsImplicitMatch(CSLexerHighlighter lexer)
|
|
{
|
|
if (!char.IsWhiteSpace(lexer.Previous) &&
|
|
!lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool matchedNumber = false;
|
|
|
|
while (!lexer.EndOfStream)
|
|
{
|
|
if (IsNumberOrDecimalPoint(lexer.ReadNext()))
|
|
{
|
|
matchedNumber = true;
|
|
lexer.Commit();
|
|
}
|
|
else
|
|
{
|
|
lexer.Rollback();
|
|
break;
|
|
}
|
|
}
|
|
|
|
return matchedNumber;
|
|
}
|
|
|
|
private bool IsNumberOrDecimalPoint(char character) => char.IsNumber(character) || character == '.';
|
|
}
|
|
|
|
}
|