mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 08:35:43 +00:00
ZoneCodeGenerator: Extend count statement without being able to specify * to more precisely state which count should be set
This commit is contained in:
parent
032eb997ca
commit
6d1359c3d9
@ -12,14 +12,16 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
|||||||
class TestCount : TestWithEvaluation
|
class TestCount : TestWithEvaluation
|
||||||
{
|
{
|
||||||
private StructureInformation referencedType;
|
private StructureInformation referencedType;
|
||||||
private const string TypeNameToken = "typeName";
|
private const string TokenTypeName = "typeName";
|
||||||
|
private const string TokenPointerResolve = "pointerResolve";
|
||||||
|
|
||||||
// set count <typename> <calculationStatement>;
|
// set count <typename> <calculationStatement>;
|
||||||
private static readonly TokenMatcher[] matchers =
|
private static readonly TokenMatcher[] matchers =
|
||||||
{
|
{
|
||||||
new MatcherLiteral("set"),
|
new MatcherLiteral("set"),
|
||||||
new MatcherLiteral("count"),
|
new MatcherLiteral("count"),
|
||||||
new MatcherTypename().WithName(TypeNameToken),
|
new MatcherGroupLoop(MatcherGroupLoop.LoopMode.ZeroOneMultiple, new MatcherLiteral("*").WithName(TokenPointerResolve)),
|
||||||
|
new MatcherTypename().WithName(TokenTypeName),
|
||||||
new MatcherWithTag(TagEvaluation),
|
new MatcherWithTag(TagEvaluation),
|
||||||
new MatcherLiteral(";")
|
new MatcherLiteral(";")
|
||||||
};
|
};
|
||||||
@ -31,7 +33,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
|||||||
|
|
||||||
protected override void ProcessMatch(ICommandParserState state)
|
protected override void ProcessMatch(ICommandParserState state)
|
||||||
{
|
{
|
||||||
var typeName = NextMatch(TypeNameToken);
|
var typeName = NextMatch(TokenTypeName);
|
||||||
var typeNameParts = typeName.Split(new[] { "::" }, StringSplitOptions.None);
|
var typeNameParts = typeName.Split(new[] { "::" }, StringSplitOptions.None);
|
||||||
if (state.DataTypeInUse != null
|
if (state.DataTypeInUse != null
|
||||||
&& state.GetMembersFromParts(typeNameParts, state.DataTypeInUse, out var typeMembers))
|
&& state.GetMembersFromParts(typeNameParts, state.DataTypeInUse, out var typeMembers))
|
||||||
@ -59,8 +61,10 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
|||||||
var evaluation = ProcessEvaluation(state);
|
var evaluation = ProcessEvaluation(state);
|
||||||
|
|
||||||
var referencedMember = typeMembers.Last();
|
var referencedMember = typeMembers.Last();
|
||||||
var reference = referencedMember.Member.VariableType.References.OfType<ReferenceTypePointer>()
|
var reference = referencedMember.Member.VariableType.References
|
||||||
.LastOrDefault();
|
.OfType<ReferenceTypePointer>()
|
||||||
|
.Skip(GetMatcherTokenCount(TokenPointerResolve))
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (reference != null)
|
if (reference != null)
|
||||||
reference.Count = evaluation;
|
reference.Count = evaluation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user