mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using ZoneCodeGenerator.Parsing.Matching;
|
|
|
|
namespace ZoneCodeGeneratorTests.Parsing.Matching.Matchers
|
|
{
|
|
class TestMatcher : TokenMatcher
|
|
{
|
|
private readonly int tokenCount;
|
|
private readonly string tokenName;
|
|
|
|
public bool Successful { get; set; }
|
|
public int TestTokenOffset { get; private set; }
|
|
public bool WasTested { get; private set; }
|
|
|
|
public TestMatcher(bool successful, int tokenCount, string tokenName = "")
|
|
{
|
|
Successful = successful;
|
|
this.tokenCount = tokenCount;
|
|
this.tokenName = tokenName;
|
|
TestTokenOffset = 0;
|
|
WasTested = false;
|
|
}
|
|
|
|
protected override string GetIdentifier()
|
|
{
|
|
return "TestMatcher";
|
|
}
|
|
|
|
protected override TokenMatchingResult PerformTest(MatchingContext context, int tokenOffset)
|
|
{
|
|
var result = new TokenMatchingResult(Successful, Successful ? tokenCount : 0);
|
|
|
|
if(!string.IsNullOrEmpty(tokenName))
|
|
result.AddNamedMatch(tokenName, "test");
|
|
|
|
TestTokenOffset = tokenOffset;
|
|
WasTested = true;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|