mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 11:40:05 +00:00
Getting the next word ends at a comment (;)
This commit is contained in:
parent
e3f70b9a85
commit
574884cd7e
@ -155,6 +155,7 @@ spv_result_t spvTextWordGet(const spv_text text,
|
||||
while (true) {
|
||||
switch (text->str[endPosition->index]) {
|
||||
case ' ':
|
||||
case ';':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\0': { // NOTE: End of word found!
|
||||
|
@ -85,7 +85,9 @@ spv_result_t spvTextAdvanceLine(const spv_text text, spv_position_t *pPosition);
|
||||
/// @return result code
|
||||
spv_result_t spvTextAdvance(const spv_text text, spv_position_t *pPosition);
|
||||
|
||||
/// @brief Fetch the next word from the text stream
|
||||
/// @brief Fetch the next word from the text stream.
|
||||
///
|
||||
/// A word ends at the next comment or whitespace.
|
||||
///
|
||||
/// @param[in] text stream to read from
|
||||
/// @param[in] startPosition current position in text stream
|
||||
|
@ -68,6 +68,20 @@ TEST(TextWordGet, SpaceTerminator) {
|
||||
ASSERT_STREQ("Word", word.c_str());
|
||||
}
|
||||
|
||||
TEST(TextWordGet, SemicolonTerminator) {
|
||||
char textStr[] = "Wo;rd ";
|
||||
spv_text_t text = {textStr, strlen(textStr)};
|
||||
spv_position_t startPosition = {};
|
||||
std::string word;
|
||||
spv_position_t endPosition = {};
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
spvTextWordGet(&text, &startPosition, word, &endPosition));
|
||||
ASSERT_EQ(2, endPosition.column);
|
||||
ASSERT_EQ(0, endPosition.line);
|
||||
ASSERT_EQ(2, endPosition.index);
|
||||
ASSERT_STREQ("Wo", word.c_str());
|
||||
}
|
||||
|
||||
TEST(TextWordGet, MultipleWords) {
|
||||
char textStr[] = "Words in a sentence";
|
||||
spv_text_t text = {textStr, strlen(textStr)};
|
||||
|
Loading…
Reference in New Issue
Block a user