ZoneCodeGenerator: Fix operationType tokens not being sorted by length so shorter tokens can be matched before longer ones

This commit is contained in:
Jan 2019-11-19 12:55:04 +01:00
parent 8d4e4c0025
commit 31b279c1e6
2 changed files with 2 additions and 1 deletions

View File

@ -330,7 +330,7 @@ set count GfxPixelShaderLoadDef::program programSize;
// MaterialShaderArgument // MaterialShaderArgument
use MaterialShaderArgument; use MaterialShaderArgument;
//set condition u::literalConst type == MTL_ARG_LITERAL_VERTEX_CONST || type == MTL_ARG_LITERAL_PIXEL_CONST; //set condition u::literalConst type == MTL_ARG_LITERAL_VERTEX_CONST || type == MTL_ARG_LITERAL_PIXEL_CONST;
//set condition u::literalConst type == 1 || type == 7; set condition u::literalConst type == 1 || type == 7;
set reusable u::literalConst; set reusable u::literalConst;
set count u::literalConst 1; set count u::literalConst 1;

View File

@ -44,6 +44,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
// operationType ::= + | - | * | / | << | >> | ... // operationType ::= + | - | * | / | << | >> | ...
private static readonly TokenMatcher operationType = new MatcherGroupOr( private static readonly TokenMatcher operationType = new MatcherGroupOr(
OperationType.Types OperationType.Types
.OrderByDescending(type => type.Syntax.Length)
.Select(type => new MatcherLiteral(type.Syntax.ToCharArray().Select(c => c.ToString()).ToArray()).WithName(TokenOperationType)) .Select(type => new MatcherLiteral(type.Syntax.ToCharArray().Select(c => c.ToString()).ToArray()).WithName(TokenOperationType))
.Cast<TokenMatcher>().ToArray() .Cast<TokenMatcher>().ToArray()
).WithTag(TagOperationType); ).WithTag(TagOperationType);