mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
ZoneCodeGenerator: Fix GroupLoop adding Tags to result even when not successful
This commit is contained in:
parent
23f82894b7
commit
d5ecaa186d
@ -22,43 +22,43 @@ namespace ZoneCodeGenerator.Parsing.Matching.Matchers
|
|||||||
|
|
||||||
protected override TokenMatchingResult PerformTest(MatchingContext context, int tokenOffset)
|
protected override TokenMatchingResult PerformTest(MatchingContext context, int tokenOffset)
|
||||||
{
|
{
|
||||||
var result = new TokenMatchingResult(false, 0);
|
var successfulResult = new TokenMatchingResult(true, 0);
|
||||||
result.AppendTag(Tag);
|
successfulResult.AppendTag(Tag);
|
||||||
|
|
||||||
var matchedTimes = 0;
|
var matchedTimes = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var matcherResult = matcher.Test(context, tokenOffset + result.ConsumedTokenCount);
|
var matcherResult = matcher.Test(context, tokenOffset + successfulResult.ConsumedTokenCount);
|
||||||
|
|
||||||
if (!matcherResult.Successful)
|
if (!matcherResult.Successful)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
matcherResult.CopyTo(result);
|
matcherResult.CopyTo(successfulResult);
|
||||||
matchedTimes++;
|
matchedTimes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int minAmountOfMatches;
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case LoopMode.ZeroOneMultiple:
|
case LoopMode.ZeroOneMultiple:
|
||||||
result.Successful = true;
|
minAmountOfMatches = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoopMode.OneMultiple:
|
case LoopMode.OneMultiple:
|
||||||
result.Successful = matchedTimes > 0;
|
minAmountOfMatches = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LoopMode.Multiple:
|
case LoopMode.Multiple:
|
||||||
result.Successful = matchedTimes > 1;
|
minAmountOfMatches = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.Successful)
|
return matchedTimes < minAmountOfMatches
|
||||||
result.ConsumedTokenCount = 0;
|
? new TokenMatchingResult(false, 0)
|
||||||
|
: successfulResult;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetIdentifier()
|
protected override string GetIdentifier()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user