process a potential data token up to 'cur', adding it to 'output_tokens'. ------------------------------------------------------------------------------------------------
| 94 | // process a potential data token up to 'cur', adding it to 'output_tokens'. |
| 95 | // ------------------------------------------------------------------------------------------------ |
| 96 | void ProcessDataToken(TokenList &output_tokens, StackAllocator &token_allocator, |
| 97 | const char*& start, const char*& end, |
| 98 | unsigned int line, |
| 99 | unsigned int column, |
| 100 | TokenType type = TokenType_DATA, |
| 101 | bool must_have_token = false) |
| 102 | { |
| 103 | if (start && end) { |
| 104 | // sanity check: |
| 105 | // tokens should have no whitespace outside quoted text and [start,end] should |
| 106 | // properly delimit the valid range. |
| 107 | bool in_double_quotes = false; |
| 108 | for (const char* c = start; c != end + 1; ++c) { |
| 109 | if (*c == '\"') { |
| 110 | in_double_quotes = !in_double_quotes; |
| 111 | } |
| 112 | |
| 113 | if (!in_double_quotes && IsSpaceOrNewLine(*c)) { |
| 114 | TokenizeError("unexpected whitespace in token", line, column); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | if (in_double_quotes) { |
| 119 | TokenizeError("non-terminated double quotes", line, column); |
| 120 | } |
| 121 | |
| 122 | output_tokens.push_back(new_Token(start,end + 1,type,line,column)); |
| 123 | } |
| 124 | else if (must_have_token) { |
| 125 | TokenizeError("unexpected character, expected data token", line, column); |
| 126 | } |
| 127 | |
| 128 | start = end = nullptr; |
| 129 | } |
| 130 | |
| 131 | } |
| 132 |
no test coverage detected