Fix default field value parsing to skip whitespaces

This commit is contained in:
Wojtek Figat
2021-01-12 14:14:08 +01:00
parent d20cbf434f
commit a6d5fb318a
2 changed files with 19 additions and 1 deletions

View File

@@ -1038,7 +1038,7 @@ namespace Flax.Build.Bindings
var token = context.Tokenizer.ExpectAnyTokens(new[] { TokenType.SemiColon, TokenType.Equal, TokenType.LeftBracket, TokenType.Colon });
if (token.Type == TokenType.Equal)
{
context.Tokenizer.SkipUntil(TokenType.SemiColon, out desc.DefaultValue);
context.Tokenizer.SkipUntil(TokenType.SemiColon, out desc.DefaultValue, false);
}
else if (token.Type == TokenType.LeftBracket)
{

View File

@@ -460,6 +460,24 @@ namespace Flax.Build
}
}
/// <summary>
/// Skips all tokens until the tokenizer steps into token of given type (and it is also skipped, so, NextToken will give the next token).
/// </summary>
/// <param name="tokenType">The expected token type.</param>
/// <param name="context">The output contents of the skipped tokens.</param>
/// <param name="includeWhitespaces">When false, all white-space tokens will be ignored.</param>
public void SkipUntil(TokenType tokenType, out string context, bool includeWhitespaces)
{
context = string.Empty;
while (NextToken(true).Type != tokenType)
{
var token = CurrentToken;
if (!includeWhitespaces && (token.Type == TokenType.Newline || token.Type == TokenType.Whitespace))
continue;
context += token.Value;
}
}
/// <summary>
/// Disposes the <see cref="Tokenizer"/>.
/// </summary>