diff options
author | sobols <sobols@yandex-team.ru> | 2022-02-10 16:47:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:08 +0300 |
commit | 09961b69c61f471ddd594e0fd877df62a8021562 (patch) | |
tree | 54a7b60a9526a7104557a033eb0a8d70d64b604c /contrib/libs/yaml-cpp/src/scanner.cpp | |
parent | 4ce8835206f981afa4a61915a49a21fb750416ec (diff) | |
download | ydb-09961b69c61f471ddd594e0fd877df62a8021562.tar.gz |
Restoring authorship annotation for <sobols@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/yaml-cpp/src/scanner.cpp')
-rw-r--r-- | contrib/libs/yaml-cpp/src/scanner.cpp | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/contrib/libs/yaml-cpp/src/scanner.cpp b/contrib/libs/yaml-cpp/src/scanner.cpp index b5cfcc12b2..7176d6d6d0 100644 --- a/contrib/libs/yaml-cpp/src/scanner.cpp +++ b/contrib/libs/yaml-cpp/src/scanner.cpp @@ -51,9 +51,9 @@ void Scanner::EnsureTokensInQueue() { Token& token = m_tokens.front(); // if this guy's valid, then we're done - if (token.status == Token::VALID) { + if (token.status == Token::VALID) { return; - } + } // here's where we clean up the impossible tokens if (token.status == Token::INVALID) { @@ -65,9 +65,9 @@ void Scanner::EnsureTokensInQueue() { } // no token? maybe we've actually finished - if (m_endedStream) { + if (m_endedStream) { return; - } + } // no? then scan... ScanNextToken(); @@ -75,13 +75,13 @@ void Scanner::EnsureTokensInQueue() { } void Scanner::ScanNextToken() { - if (m_endedStream) { + if (m_endedStream) { return; - } + } - if (!m_startedStream) { + if (!m_startedStream) { return StartStream(); - } + } // get rid of whitespace, etc. (in between tokens it should be irrelevent) ScanToNextToken(); @@ -94,75 +94,75 @@ void Scanner::ScanNextToken() { // ***** // end of stream - if (!INPUT) { + if (!INPUT) { return EndStream(); - } + } - if (INPUT.column() == 0 && INPUT.peek() == Keys::Directive) { + if (INPUT.column() == 0 && INPUT.peek() == Keys::Directive) { return ScanDirective(); - } + } // document token - if (INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) { + if (INPUT.column() == 0 && Exp::DocStart().Matches(INPUT)) { return ScanDocStart(); - } + } - if (INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) { + if (INPUT.column() == 0 && Exp::DocEnd().Matches(INPUT)) { return ScanDocEnd(); - } + } // flow start/end/entry - if (INPUT.peek() == Keys::FlowSeqStart || - INPUT.peek() == Keys::FlowMapStart) { + if (INPUT.peek() == Keys::FlowSeqStart || + INPUT.peek() == Keys::FlowMapStart) { return ScanFlowStart(); - } + } - if (INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) { + if (INPUT.peek() == Keys::FlowSeqEnd || INPUT.peek() == Keys::FlowMapEnd) { return ScanFlowEnd(); - } + } - if (INPUT.peek() == Keys::FlowEntry) { + if (INPUT.peek() == Keys::FlowEntry) { return ScanFlowEntry(); - } + } // block/map stuff - if (Exp::BlockEntry().Matches(INPUT)) { + if (Exp::BlockEntry().Matches(INPUT)) { return ScanBlockEntry(); - } + } - if ((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) { + if ((InBlockContext() ? Exp::Key() : Exp::KeyInFlow()).Matches(INPUT)) { return ScanKey(); - } + } - if (GetValueRegex().Matches(INPUT)) { + if (GetValueRegex().Matches(INPUT)) { return ScanValue(); - } + } // alias/anchor - if (INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) { + if (INPUT.peek() == Keys::Alias || INPUT.peek() == Keys::Anchor) { return ScanAnchorOrAlias(); - } + } // tag - if (INPUT.peek() == Keys::Tag) { + if (INPUT.peek() == Keys::Tag) { return ScanTag(); - } + } // special scalars if (InBlockContext() && (INPUT.peek() == Keys::LiteralScalar || - INPUT.peek() == Keys::FoldedScalar)) { + INPUT.peek() == Keys::FoldedScalar)) { return ScanBlockScalar(); - } + } - if (INPUT.peek() == '\'' || INPUT.peek() == '\"') { + if (INPUT.peek() == '\'' || INPUT.peek() == '\"') { return ScanQuotedScalar(); - } + } // plain scalars if ((InBlockContext() ? Exp::PlainScalar() : Exp::PlainScalarInFlow()) - .Matches(INPUT)) { + .Matches(INPUT)) { return ScanPlainScalar(); - } + } // don't know what it is! throw ParserException(INPUT.mark(), ErrorMsg::UNKNOWN_TOKEN); @@ -172,24 +172,24 @@ void Scanner::ScanToNextToken() { while (1) { // first eat whitespace while (INPUT && IsWhitespaceToBeEaten(INPUT.peek())) { - if (InBlockContext() && Exp::Tab().Matches(INPUT)) { + if (InBlockContext() && Exp::Tab().Matches(INPUT)) { m_simpleKeyAllowed = false; - } + } INPUT.eat(1); } // then eat a comment if (Exp::Comment().Matches(INPUT)) { // eat until line break - while (INPUT && !Exp::Break().Matches(INPUT)) { + while (INPUT && !Exp::Break().Matches(INPUT)) { INPUT.eat(1); - } + } } // if it's NOT a line break, then we're done! - if (!Exp::Break().Matches(INPUT)) { + if (!Exp::Break().Matches(INPUT)) { break; - } + } // otherwise, let's eat the line break and keep going int n = Exp::Break().Match(INPUT); @@ -199,9 +199,9 @@ void Scanner::ScanToNextToken() { InvalidateSimpleKey(); // new line - we may be able to accept a simple key now - if (InBlockContext()) { + if (InBlockContext()) { m_simpleKeyAllowed = true; - } + } } } @@ -218,21 +218,21 @@ void Scanner::ScanToNextToken() { // that they can't contribute to indentation, so once you've seen a tab in a // line, you can't start a simple key bool Scanner::IsWhitespaceToBeEaten(char ch) { - if (ch == ' ') { + if (ch == ' ') { return true; - } + } - if (ch == '\t') { + if (ch == '\t') { return true; - } + } return false; } const RegEx& Scanner::GetValueRegex() const { - if (InBlockContext()) { + if (InBlockContext()) { return Exp::Value(); - } + } return m_canBeJSONFlow ? Exp::ValueInJSONFlow() : Exp::ValueInFlow(); } @@ -240,17 +240,17 @@ const RegEx& Scanner::GetValueRegex() const { void Scanner::StartStream() { m_startedStream = true; m_simpleKeyAllowed = true; - std::unique_ptr<IndentMarker> pIndent( - new IndentMarker(-1, IndentMarker::NONE)); - m_indentRefs.push_back(std::move(pIndent)); + std::unique_ptr<IndentMarker> pIndent( + new IndentMarker(-1, IndentMarker::NONE)); + m_indentRefs.push_back(std::move(pIndent)); m_indents.push(&m_indentRefs.back()); } void Scanner::EndStream() { // force newline - if (INPUT.column() > 0) { + if (INPUT.column() > 0) { INPUT.ResetColumn(); - } + } PopAllIndents(); PopAllSimpleKeys(); @@ -281,72 +281,72 @@ Token::TYPE Scanner::GetStartTokenFor(IndentMarker::INDENT_TYPE type) const { Scanner::IndentMarker* Scanner::PushIndentTo(int column, IndentMarker::INDENT_TYPE type) { // are we in flow? - if (InFlowContext()) { + if (InFlowContext()) { return 0; - } + } - std::unique_ptr<IndentMarker> pIndent(new IndentMarker(column, type)); + std::unique_ptr<IndentMarker> pIndent(new IndentMarker(column, type)); IndentMarker& indent = *pIndent; const IndentMarker& lastIndent = *m_indents.top(); // is this actually an indentation? - if (indent.column < lastIndent.column) { + if (indent.column < lastIndent.column) { return 0; - } + } if (indent.column == lastIndent.column && !(indent.type == IndentMarker::SEQ && - lastIndent.type == IndentMarker::MAP)) { + lastIndent.type == IndentMarker::MAP)) { return 0; - } + } // push a start token indent.pStartToken = PushToken(GetStartTokenFor(type)); // and then the indent m_indents.push(&indent); - m_indentRefs.push_back(std::move(pIndent)); + m_indentRefs.push_back(std::move(pIndent)); return &m_indentRefs.back(); } void Scanner::PopIndentToHere() { // are we in flow? - if (InFlowContext()) { + if (InFlowContext()) { return; - } + } // now pop away while (!m_indents.empty()) { const IndentMarker& indent = *m_indents.top(); - if (indent.column < INPUT.column()) { + if (indent.column < INPUT.column()) { break; - } + } if (indent.column == INPUT.column() && !(indent.type == IndentMarker::SEQ && - !Exp::BlockEntry().Matches(INPUT))) { + !Exp::BlockEntry().Matches(INPUT))) { break; - } + } PopIndent(); } - while (!m_indents.empty() && - m_indents.top()->status == IndentMarker::INVALID) { + while (!m_indents.empty() && + m_indents.top()->status == IndentMarker::INVALID) { PopIndent(); - } + } } void Scanner::PopAllIndents() { // are we in flow? - if (InFlowContext()) { + if (InFlowContext()) { return; - } + } // now pop away while (!m_indents.empty()) { const IndentMarker& indent = *m_indents.top(); - if (indent.type == IndentMarker::NONE) { + if (indent.type == IndentMarker::NONE) { break; - } + } PopIndent(); } @@ -361,17 +361,17 @@ void Scanner::PopIndent() { return; } - if (indent.type == IndentMarker::SEQ) { + if (indent.type == IndentMarker::SEQ) { m_tokens.push(Token(Token::BLOCK_SEQ_END, INPUT.mark())); - } else if (indent.type == IndentMarker::MAP) { + } else if (indent.type == IndentMarker::MAP) { m_tokens.push(Token(Token::BLOCK_MAP_END, INPUT.mark())); - } + } } int Scanner::GetTopIndent() const { - if (m_indents.empty()) { + if (m_indents.empty()) { return 0; - } + } return m_indents.top()->column; } @@ -383,4 +383,4 @@ void Scanner::ThrowParserException(const std::string& msg) const { } throw ParserException(mark, msg); } -} // namespace YAML +} // namespace YAML |