MCPcopy Create free account
hub / github.com/apache/trafficserver / ScanBlockScalar

Method ScanBlockScalar

lib/yamlcpp/src/scantoken.cpp:375–436  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

373// of the scalar),
374// and then we need to figure out what level of indentation we'll be using.
375void 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

Callers

nothing calls this directly

Calls 9

ParserExceptionFunction · 0.85
ScanScalarFunction · 0.85
MatchesMethod · 0.80
eatMethod · 0.80
CommentFunction · 0.70
markMethod · 0.45
getMethod · 0.45
MatchMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected