|
6 | 6 | #include "token.h" |
7 | 7 | #include "yaml-cpp/exceptions.h" // IWYU pragma: keep |
8 | 8 |
|
| 9 | +namespace { |
| 10 | +// IsWhitespaceToBeEaten |
| 11 | +// . We can eat whitespace if it's a space or tab |
| 12 | +// . Note: originally tabs in block context couldn't be eaten |
| 13 | +// "where a simple key could be allowed |
| 14 | +// (i.e., not at the beginning of a line, or following '-', '?', or |
| 15 | +// ':')" |
| 16 | +// I think this is wrong, since tabs can be non-content whitespace; it's just |
| 17 | +// that they can't contribute to indentation, so once you've seen a tab in a |
| 18 | +// line, you can't start a simple key |
| 19 | +bool IsWhitespaceToBeEaten(char ch) { return (ch == ' ') || (ch == '\t'); } |
| 20 | +} // namespace |
| 21 | + |
9 | 22 | namespace YAML { |
10 | 23 | Scanner::Scanner(std::istream& in) |
11 | 24 | : INPUT(in), |
@@ -213,27 +226,6 @@ void Scanner::ScanToNextToken() { |
213 | 226 | /////////////////////////////////////////////////////////////////////// |
214 | 227 | // Misc. helpers |
215 | 228 |
|
216 | | -// IsWhitespaceToBeEaten |
217 | | -// . We can eat whitespace if it's a space or tab |
218 | | -// . Note: originally tabs in block context couldn't be eaten |
219 | | -// "where a simple key could be allowed |
220 | | -// (i.e., not at the beginning of a line, or following '-', '?', or |
221 | | -// ':')" |
222 | | -// I think this is wrong, since tabs can be non-content whitespace; it's just |
223 | | -// that they can't contribute to indentation, so once you've seen a tab in a |
224 | | -// line, you can't start a simple key |
225 | | -bool Scanner::IsWhitespaceToBeEaten(char ch) { |
226 | | - if (ch == ' ') { |
227 | | - return true; |
228 | | - } |
229 | | - |
230 | | - if (ch == '\t') { |
231 | | - return true; |
232 | | - } |
233 | | - |
234 | | - return false; |
235 | | -} |
236 | | - |
237 | 229 | const RegEx& Scanner::GetValueRegex() const { |
238 | 230 | if (InBlockContext()) { |
239 | 231 | return Exp::Value(); |
@@ -269,7 +261,7 @@ Token* Scanner::PushToken(Token::TYPE type) { |
269 | 261 | return &m_tokens.back(); |
270 | 262 | } |
271 | 263 |
|
272 | | -Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) const { |
| 264 | +Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) { |
273 | 265 | switch (type) { |
274 | 266 | case IndentMarker::SEQ: |
275 | 267 | return Token::BLOCK_SEQ_START; |
|
0 commit comments