feat(yaml_parser): Correct parsing whitespaces-separated strings

Fix given scenarios in yaml parsings:
- Correct reading string containing multiple words separated by a
whitespace (space/tab) on token value retrieving
- Remove any unnecessary whitespaces from the end of a string on token
value retrieving

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
Kacper Nowak
2022-11-14 16:12:26 +00:00
committed by Compute-Runtime-Automation
parent bddf1bbe76
commit 966aa460f7
6 changed files with 84 additions and 8 deletions

View File

@@ -275,10 +275,12 @@ bool tokenize(ConstStringRef text, LinesCache &outLines, TokensCache &outTokens,
context.isParsingIdent = false;
auto tokEnd = consumeNameIdentifier(text, context.pos);
if (tokEnd != context.pos) {
auto tokenData = ConstStringRef(context.pos, tokEnd - context.pos);
tokenData = tokenData.trimEnd(isWhitespace);
if (context.lineTraits.hasDictionaryEntry) {
outTokens.push_back(Token(ConstStringRef(context.pos, tokEnd - context.pos), Token::LiteralString));
outTokens.push_back(Token(tokenData, Token::LiteralString));
} else {
outTokens.push_back(Token(ConstStringRef(context.pos, tokEnd - context.pos), Token::Identifier));
outTokens.push_back(Token(tokenData, Token::Identifier));
}
} else {
tokEnd = consumeNumberOrSign(text, context.pos);