diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-05-06 23:00:45 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-05-06 23:00:45 +0000 |
commit | fe6f1865bcfbc63f3014fe2c5503b1fec16ed8cc (patch) | |
tree | fef6d391f907655a184a708e8d81fd63b5ce5a11 /llvm/lib/Support | |
parent | cc151ccdcf5fb1b267b47759b1fd8bcf74ceb2cf (diff) | |
download | bcm5719-llvm-fe6f1865bcfbc63f3014fe2c5503b1fec16ed8cc.tar.gz bcm5719-llvm-fe6f1865bcfbc63f3014fe2c5503b1fec16ed8cc.zip |
YAML: Extract the code that skips a comment into a separate method, NFC.
This commit extracts the code that skips over a YAML comment from
the 'scanToNextToken' method into a separate 'skipComment' method.
This refactoring is motivated by a patch that implements parsing
of YAML block scalars (http://reviews.llvm.org/D9503), as the
method that parses a block scalar reuses the 'skipComment' method.
llvm-svn: 236663
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/YAMLParser.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 93aec7c0438..cb21eb58e94 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -417,6 +417,10 @@ private: , Token::TokenKind Kind , TokenQueueT::iterator InsertPoint); + /// @brief Skip a single-line comment when the comment starts at the current + /// position of the scanner. + void skipComment(); + /// @brief Skip whitespace and comments until the start of the next token. void scanToNextToken(); @@ -962,24 +966,27 @@ bool Scanner::rollIndent( int ToColumn return true; } +void Scanner::skipComment() { + if (*Current != '#') + return; + while (true) { + // This may skip more than one byte, thus Column is only incremented + // for code points. + StringRef::iterator I = skip_nb_char(Current); + if (I == Current) + break; + Current = I; + ++Column; + } +} + void Scanner::scanToNextToken() { while (true) { while (*Current == ' ' || *Current == '\t') { skip(1); } - // Skip comment. - if (*Current == '#') { - while (true) { - // This may skip more than one byte, thus Column is only incremented - // for code points. - StringRef::iterator i = skip_nb_char(Current); - if (i == Current) - break; - Current = i; - ++Column; - } - } + skipComment(); // Skip EOL. StringRef::iterator i = skip_b_break(Current); |