Fix default field value parsing to skip whitespaces
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user