BlockScalarToken . These need a little extra processing beforehand. . We need to scan the line where the indicator is (this doesn't count as part of the scalar), and then we need to figure out what level of indentation we'll be using.
| 373 | // of the scalar), |
| 374 | // and then we need to figure out what level of indentation we'll be using. |
| 375 | void Scanner::ScanBlockScalar() { |
| 376 | std::string scalar; |
| 377 | |
| 378 | ScanScalarParams params; |
| 379 | params.indent = 1; |
| 380 | params.detectIndent = true; |
| 381 | |
| 382 | // eat block indicator ('|' or '>') |
| 383 | Mark mark = INPUT.mark(); |
| 384 | char indicator = INPUT.get(); |
| 385 | params.fold = (indicator == Keys::FoldedScalar ? FOLD_BLOCK : DONT_FOLD); |
| 386 | |
| 387 | // eat chomping/indentation indicators |
| 388 | params.chomp = CLIP; |
| 389 | int n = Exp::Chomp().Match(INPUT); |
| 390 | for (int i = 0; i < n; i++) { |
| 391 | char ch = INPUT.get(); |
| 392 | if (ch == '+') |
| 393 | params.chomp = KEEP; |
| 394 | else if (ch == '-') |
| 395 | params.chomp = STRIP; |
| 396 | else if (Exp::Digit().Matches(ch)) { |
| 397 | if (ch == '0') |
| 398 | throw ParserException(INPUT.mark(), ErrorMsg::ZERO_INDENT_IN_BLOCK); |
| 399 | |
| 400 | params.indent = ch - '0'; |
| 401 | params.detectIndent = false; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | // now eat whitespace |
| 406 | while (Exp::Blank().Matches(INPUT)) |
| 407 | INPUT.eat(1); |
| 408 | |
| 409 | // and comments to the end of the line |
| 410 | if (Exp::Comment().Matches(INPUT)) |
| 411 | while (INPUT && !Exp::Break().Matches(INPUT)) |
| 412 | INPUT.eat(1); |
| 413 | |
| 414 | // if it's not a line break, then we ran into a bad character inline |
| 415 | if (INPUT && !Exp::Break().Matches(INPUT)) |
| 416 | throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_BLOCK); |
| 417 | |
| 418 | // set the initial indentation |
| 419 | if (GetTopIndent() >= 0) |
| 420 | params.indent += GetTopIndent(); |
| 421 | |
| 422 | params.eatLeadingWhitespace = false; |
| 423 | params.trimTrailingSpaces = false; |
| 424 | params.onTabInIndentation = THROW; |
| 425 | |
| 426 | scalar = ScanScalar(INPUT, params); |
| 427 | |
| 428 | // simple keys always ok after block scalars (since we're gonna start a new |
| 429 | // line anyways) |
| 430 | m_simpleKeyAllowed = true; |
| 431 | m_canBeJSONFlow = false; |
| 432 |
nothing calls this directly
no test coverage detected